mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
test code for sw state changes
This commit is contained in:
parent
eaaf18fb82
commit
e290822a32
18
index.html
18
index.html
@ -29,10 +29,24 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script id="service-worker" type="disabled">
|
<script id="service-worker" type="module">
|
||||||
if('serviceWorker' in navigator) {
|
if('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.register('sw.js')
|
navigator.serviceWorker.register('sw.js')
|
||||||
.then(function() { console.log("Service Worker registered"); });
|
.then(function(registration) {
|
||||||
|
console.log("Service Worker registered");
|
||||||
|
registration.onupdatefound = function() {
|
||||||
|
const newWorker = registration.installing;
|
||||||
|
alert("update found!");
|
||||||
|
newWorker.onstatechange = function() {
|
||||||
|
if (newWorker.state === "installed") {
|
||||||
|
alert("new worker is now on state " + newWorker.state);
|
||||||
|
// if (confirm("update installed! shall I skip waiting?")) {
|
||||||
|
// newWorker.skipWaiting();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user