blob: 2e6dbf992d052d9f1e3e518dd7b0e851ef2000a7 [file] [log] [blame]
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
var scope = "/workers/service/serviceworkerclients-claim.https.html";
var activeWorker;
promise_test(async (test) => {
var registration = await navigator.serviceWorker.getRegistration(scope);
if (registration && registration.scope === scope)
await registration.unregister();
var registration = await navigator.serviceWorker.register("serviceworkerclients-matchAll-worker.js", { scope : scope });
activeWorker = registration.active;
if (activeWorker)
return;
activeWorker = registration.installing;
return new Promise(resolve => {
activeWorker.addEventListener('statechange', () => {
if (activeWorker.state === "activated")
resolve();
});
});
}, "Setup worker");
promise_test(async (test) => {
const serviceWorkerClientIdentifier = internals.serviceWorkerClientIdentifier(document);
var promise = new Promise((resolve, reject) => {
navigator.serviceWorker.addEventListener("message", test.step_func((event) => {
assert_equals(event.data, "PASS");
resolve();
}));
});
activeWorker.postMessage({test: "checkClientIsUncontrolled", identifier: serviceWorkerClientIdentifier });
await promise;
}, "Test self.clients.matchAll");
</script>
</body>
</html>