|
1 | 1 | <title>Proxy Sandbox Controller</title> |
2 | 2 | <script> |
3 | 3 | function wake(controller) { |
4 | | - console.log("wakling"); |
5 | 4 | window.parent.postMessage({ $sandboxsw$type: "ready" }, "*"); |
6 | 5 | } |
7 | 6 | navigator.serviceWorker |
8 | 7 | .register("/sw.js", { |
9 | 8 | scope: "./", |
10 | 9 | }) |
11 | 10 | .then((registration) => { |
12 | | - console.log("Service Worker registered with scope:", registration.scope); |
13 | | - console.log("Registration installing:", registration.installing); |
14 | | - console.log("Registration waiting:", registration.waiting); |
15 | | - console.log("Registration active:", registration.active); |
16 | | - |
17 | | - // Monitor the registration for changes |
18 | | - registration.addEventListener("updatefound", () => { |
19 | | - console.log("SW update found!"); |
20 | | - const newWorker = registration.installing; |
21 | | - console.log("New worker state:", newWorker?.state); |
22 | | - |
23 | | - newWorker?.addEventListener("statechange", () => { |
24 | | - console.log("SW state changed to:", newWorker.state); |
25 | | - }); |
26 | | - }); |
27 | | - |
28 | | - // Check current controller |
29 | | - console.log("Current controller:", navigator.serviceWorker.controller); |
30 | | - |
31 | 11 | if (navigator.serviceWorker.controller) { |
32 | 12 | // there's probably already a service worker |
33 | 13 | wake(navigator.serviceWorker.controller); |
|
0 commit comments