summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/clients-matchall-exact-controller.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/service-workers/service-worker/clients-matchall-exact-controller.https.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/clients-matchall-exact-controller.https.html')
-rw-r--r--testing/web-platform/tests/service-workers/service-worker/clients-matchall-exact-controller.https.html67
1 files changed, 67 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/clients-matchall-exact-controller.https.html b/testing/web-platform/tests/service-workers/service-worker/clients-matchall-exact-controller.https.html
new file mode 100644
index 0000000000..a61c8af701
--- /dev/null
+++ b/testing/web-platform/tests/service-workers/service-worker/clients-matchall-exact-controller.https.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<title>Service Worker: Clients.matchAll with exact controller</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.sub.js"></script>
+<script>
+const scope = 'resources/blank.html?clients-matchAll';
+let frames = [];
+
+function checkWorkerClients(worker, expected) {
+ return new Promise((resolve, reject) => {
+ let channel = new MessageChannel();
+ channel.port1.onmessage = evt => {
+ try {
+ assert_equals(evt.data.length, expected.length);
+ for (let i = 0; i < expected.length; ++i) {
+ assert_array_equals(evt.data[i], expected[i]);
+ }
+ resolve();
+ } catch (e) {
+ reject(e);
+ }
+ };
+
+ worker.postMessage({port:channel.port2}, [channel.port2]);
+ });
+}
+
+let expected = [
+ // visibilityState, focused, url, type, frameType
+ ['visible', true, new URL(scope + '#1', location).toString(), 'window', 'nested'],
+ ['visible', false, new URL(scope + '#2', location).toString(), 'window', 'nested']
+];
+
+promise_test(t => {
+ let script = 'resources/clients-matchall-worker.js';
+ return service_worker_unregister_and_register(t, script, scope)
+ .then(registration => {
+ t.add_cleanup(() => service_worker_unregister(t, scope));
+
+ return wait_for_state(t, registration.installing, 'activated');
+ })
+ .then(_ => with_iframe(scope + '#1') )
+ .then(frame1 => {
+ frames.push(frame1);
+ frame1.focus();
+ return with_iframe(scope + '#2');
+ })
+ .then(frame2 => {
+ frames.push(frame2);
+ return navigator.serviceWorker.register(script + '?updated', { scope: scope });
+ })
+ .then(registration => {
+ return wait_for_state(t, registration.installing, 'installed')
+ .then(_ => registration);
+ })
+ .then(registration => {
+ return Promise.all([
+ checkWorkerClients(registration.waiting, []),
+ checkWorkerClients(registration.active, expected),
+ ]);
+ })
+ .then(_ => {
+ frames.forEach(f => f.remove() );
+ });
+}, 'Test Clients.matchAll() with exact controller');
+</script>