diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/speculation-rules/prerender/clients-matchall.https.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
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> |