Source code
Revision control
Copy as Markdown
Other Tools
<html>
<head>
<script>
window.addEventListener('message', async function(evt) {
if (evt.data === 'START') {
var w = window.open('./');
var sw = w.navigator.serviceWorker;
w.close();
w = null;
// Ensure sw.register receives a valid URL. The popup might have
// about:blank as base so sw.register('doestnmatter.js') would be invalid.
const swUrl = new URL('doestnmatter.js', document.baseURI).href;
try {
await sw.register(swUrl);
} finally {
parent.postMessage('OK', '*');
}
}
});
</script>
</head>
</html>