Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /push-api/worker-subscribe.https.window.html - WPT Dashboard Interop Dashboard
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=/notifications/resources/helpers.js
promise_setup(async () => {
await trySettingPermission("granted");
await prepareActiveServiceWorker("push-sw.js");
});
promise_test(async () => {
// (no `sender` URL parameter needed as this worker is the only sender)
const worker = new Worker("./resources/permission-worker.js", { type: "module" });
const { promise, resolve } = Promise.withResolvers();
worker.onmessage = ev => {
if ("subscribed" in ev.data) {
resolve(ev.data)
}
};
const result = await promise;
assert_true(result.subscribed, `subscription should happen`);
}, "Subscribing within a worker");