diff options
Diffstat (limited to 'testing/web-platform/tests/service-workers/service-worker/resources/partitioned-service-worker-third-party-iframe-getRegistrations.html')
-rw-r--r-- | testing/web-platform/tests/service-workers/service-worker/resources/partitioned-service-worker-third-party-iframe-getRegistrations.html | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/testing/web-platform/tests/service-workers/service-worker/resources/partitioned-service-worker-third-party-iframe-getRegistrations.html b/testing/web-platform/tests/service-workers/service-worker/resources/partitioned-service-worker-third-party-iframe-getRegistrations.html new file mode 100644 index 0000000000..747c058946 --- /dev/null +++ b/testing/web-platform/tests/service-workers/service-worker/resources/partitioned-service-worker-third-party-iframe-getRegistrations.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<title>Service Worker: 3P iframe for partitioned service workers</title> +<script src="./test-helpers.sub.js"></script> +<script src="/common/get-host-info.sub.js"></script> +<script src="./partitioned-utils.js"></script> + +<body> + This iframe will register a service worker when it loads and then will use + getRegistrations to get a handle to the SW. It will then postMessage to the + SW to retrieve the SW's ID. This iframe will then forward that message up, + eventually, to the test. + <script> + + async function onLoad() { + const scope = './partitioned-' + const absoluteScope = new URL(scope, window.location).href; + + await setupServiceWorker(); + + // Once the SW sends us its ID, forward it up to the window. + navigator.serviceWorker.addEventListener('message', evt => { + window.parent.postMessage(evt.data, '*'); + }); + + // Now get the SW with getRegistrations. + const retrieved_registrations = + await navigator.serviceWorker.getRegistrations(); + + // It's possible that other tests have left behind other service workers. + // This steps filters those other SWs out. + const filtered_registrations = + retrieved_registrations.filter(reg => reg.scope == absoluteScope); + + filtered_registrations[0].active.postMessage({type: "get-id"}); + + } + + self.addEventListener('load', onLoad); + </script> +</body>
\ No newline at end of file |