diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/speculation-rules/prerender/clients-matchall.https.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
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.html | 52 |
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..bbd9ea2327 --- /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="/speculation-rules/prerender/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> +</body> |