notificationclick-otherwindow.html (885B)
1 <!-- 2 Any copyright is dedicated to the Public Domain. 3 http://creativecommons.org/publicdomain/zero/1.0/ 4 --> 5 <!DOCTYPE HTML> 6 <html> 7 <head> 8 <title>Bug 1114554 - controlled page</title> 9 <script class="testbody" type="text/javascript"> 10 var testWindow = parent; 11 if (opener) { 12 testWindow = opener; 13 } 14 15 navigator.serviceWorker.ready.then(function(swr) { 16 const args = new URL(location.href).searchParams.get("args"); 17 const argsParsed = JSON.parse(args); 18 var ifr = document.createElement("iframe"); 19 document.documentElement.appendChild(ifr); 20 ifr.contentWindow.ServiceWorkerRegistration.prototype.showNotification 21 .call(swr, "Hi there. The ServiceWorker should receive a click event for this.", argsParsed); 22 }); 23 24 navigator.serviceWorker.onmessage = function(msg) { 25 testWindow.callback(msg.data); 26 }; 27 </script> 28 29 </head> 30 <body> 31 </body> 32 </html>