v147 · proposed IWA API · member reference
WebPrintJob.onjobstatechange
Event handler for job progress or state updates. Prefer addEventListener() when more than one listener may be needed.
Syntax
job.onjobstatechange = (event) => {
console.log(job.attributes());
};
// event type: "jobstatechange"Inputs
Assign an event handler or register job.addEventListener("jobstatechange", listener). The event has no specified custom payload; obtain current data with attributes().
Outputs
The user agent must fire when jobState or jobPagesCompleted changes. Chromium suppresses an update where neither changed.
Errors
There is no event error channel. Submission failures reject before a job object exists; terminal canceled and aborted are states, not exceptions.
Context and permission
The IDL requires a secure, isolated context. The specification also defines the web-printing Permissions Policy with default allowlist self; Chromium additionally checks an isolated context and cross-origin isolation before getPrinters(). The current proposal requires express, origin-specific consent triggered by enumeration. The exact chooser scope, persistence, and whether a later operation prompts again remain user-agent UX, not a settled web contract.
Lifecycle, cancellation, and cleanup
Register promptly after submission. The spec does not promise replay of earlier events. On a terminal state, remove listeners if the job object remains reachable; Chromium has no further updates after terminal state.
Examples
function waitForTerminalState(job) {
return new Promise((resolve) => {
const onChange = () => {
const snapshot = job.attributes();
if (["completed", "canceled", "aborted"].includes(snapshot.jobState)) {
job.removeEventListener("jobstatechange", onChange);
resolve(snapshot);
}
};
job.addEventListener("jobstatechange", onChange);
onChange();
});
}Browser compatibility
| Runtime | Status | Evidence |
|---|---|---|
| Chrome (general) | Proposed and not released. ChromeStatus lists I2S desktop target 147, which is not release proof. Do not infer general desktop Chrome support. | ChromeStatus |
| Current Chromium service | Implemented only when built with IS_CHROMEOS && USE_CUPS; otherwise getPrinters() has no service and throws SecurityError. | Chromium manager implementation |
| Android / mobile | ChromeStatus Android is null; no public mobile release exists. The current ChromeOS+CUPS-only service path does not expose the service on Android. | ChromeStatus; implementation guard |
| Firefox | No signal; no BCD member record found. | ChromeStatus position; BCD API data |
| Safari | No signal; no BCD member record found. | ChromeStatus position; BCD API data |
| webstatus.dev | No feature entry found for this query; this is not proof of absence from browsers. | webstatus query |
Security and privacy
Printer names, IDs, capabilities and state can fingerprint a device and reveal printing activity. A compromised IWA could create unwanted jobs or denial of service. Minimize enumeration and polling, do not expose attributes to untrusted content, validate documents before submitting, and offer an app-level confirmation/audit trail. The spec requires isolation and consent; it does not make printer information non-sensitive.