Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<script src="utils.js"></script>
<body>
<script type="module">
// Ask the worker to do a fetch request that will be handled by the service
// worker via postMessage.
const checkIfServiceWorkerCanControlWebWorker = async () => {
const dedicated_worker = new Worker('serviceWorker-dedicated-worker.js');
return new Promise((resolve, reject) => {
dedicated_worker.addEventListener('message', e => {
resolve(e.data)
});
dedicated_worker.postMessage('fetch');
})
}
const [key] = parseKeylist();
const url = new URL(location.href);
if (url.searchParams.get('useServiceWorkerInFencedFrame')) {
await navigator.serviceWorker.register('serviceWorker-dedicated-worker-sw.js');
await navigator.serviceWorker.ready;
}
const result = await checkIfServiceWorkerCanControlWebWorker();
writeValueToServer(key, result);
</script>
</body>