handler.html (860B)
1 <!doctype html> 2 <p>This popup can be closed if it does not close itself. 3 <p> 4 <script> 5 // This resource either gets navigated to through a service worker as a result of a URL that looks 6 // like: 7 // https://.../html/webappapis/system-state-and-capabilities/the-navigator-object/resources/handler/{type}/... 8 // (the host is excluded to not upset the lint tool) 9 // or it gets navigated to directly with the type appended to the end of the URL. In that case type 10 // can only be fragment or query. 11 12 let type = null; 13 let swString = null; 14 if (new URL(document.URL).pathname.endsWith("handler.html")) { 15 swString = ""; 16 type = (document.URL.endsWith("fragment")) ? "fragment" : "query"; 17 } else { 18 type = document.URL.split("/")[9]; 19 swString = "sw"; 20 } 21 new BroadcastChannel(`protocol-handler-${type}${swString}`).postMessage(document.URL); 22 window.close(); 23 </script>