notificationclose.html (890B)
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 1265841 - 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 return swr.showNotification( 17 "Hi there. The ServiceWorker should receive a close event for this.", 18 { data: { complex: ["jsval", 5] }}).then(function() { 19 return swr; 20 }); 21 }).then(function(swr) { 22 return swr.getNotifications(); 23 }).then(function(notifications) { 24 notifications.forEach(function(notification) { 25 notification.close(); 26 }); 27 }); 28 29 navigator.serviceWorker.onmessage = function(msg) { 30 testWindow.callback(msg.data); 31 }; 32 </script> 33 34 </head> 35 <body> 36 </body> 37 </html>