summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/speculation-rules/prerender/clients-matchall.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/speculation-rules/prerender/clients-matchall.https.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/speculation-rules/prerender/clients-matchall.https.html')
-rw-r--r--testing/web-platform/tests/speculation-rules/prerender/clients-matchall.https.html52
1 files changed, 52 insertions, 0 deletions
diff --git a/testing/web-platform/tests/speculation-rules/prerender/clients-matchall.https.html b/testing/web-platform/tests/speculation-rules/prerender/clients-matchall.https.html
new file mode 100644
index 0000000000..31fcc90391
--- /dev/null
+++ b/testing/web-platform/tests/speculation-rules/prerender/clients-matchall.https.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<title>Service Worker: Clients.matchAll with a prerender page</title>
+<meta name="timeout" content="long">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/utils.js"></script>
+<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
+<script src="../resources/utils.js"></script>
+<script src="resources/utils.js"></script>
+
+<body>
+<script>
+setup(() => assertSpeculationRulesIsSupported());
+
+promise_test(async t => {
+ const uid = token();
+ const workerUrl = 'resources/clients-matchall-service-worker.js';
+ const pageUrl = `resources/prerendered-page.html?uid=${uid}`;
+
+ // Start a service worker.
+ const registration =
+ await service_worker_unregister_and_register(t, workerUrl, workerUrl);
+ t.add_cleanup(_ => registration.unregister());
+
+ // Observe the message from a prerendered page.
+ const bc = new PrerenderChannel('prerender-channel', uid);
+ t.add_cleanup(_ => bc.close());
+ const messagePromise = new Promise(resolve => {
+ bc.addEventListener('message', e => {
+ resolve(e.data);
+ }, {once:true});
+ });
+
+ startPrerendering(pageUrl);
+
+ const result = await messagePromise;
+ assert_equals(result, 'prerender success');
+
+ // The service worker returns the list of client urls exposed by
+ // Clients#matchAll().
+ const message = await new Promise(resolve => {
+ navigator.serviceWorker.onmessage = resolve;
+ get_newest_worker(registration).postMessage('invoke clients.matchAll()');
+ });
+
+ assert_array_equals(
+ message.data,
+ [ window.location.href, new URL(pageUrl, location).toString() ]);
+}, 'The client urls (including a prerender page) are exposed by ' +
+ 'Clients#matchAll()');
+
+</script>