shownotification-window.https.html (1388B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/resources/testdriver.js"></script> 6 <script src="/resources/testdriver-vendor.js"></script> 7 <script src="resources/helpers.js"></script> 8 <iframe id="iframe" src="resources/shownotification-window-iframe.html"></iframe> 9 <script> 10 /** @type {ServiceWorkerRegistration} */ 11 let registration; 12 13 promise_setup(async (t) => { 14 await trySettingPermission("granted"); 15 registration = await prepareActiveServiceWorker("noop-sw.js"); 16 await closeAllNotifications(); 17 }); 18 19 promise_test(async (t) => { 20 t.add_cleanup(closeAllNotifications); 21 22 if (iframe.contentDocument.readyState !== "complete") { 23 await new Promise(resolve => iframe.onload = resolve); 24 } 25 26 await iframe.contentWindow.showNotification(); 27 let notifications = await registration.getNotifications(); 28 assert_equals(notifications.length, 1, "Should persist the notification"); 29 30 iframe.contentWindow.location.reload(); 31 // Wait for some time for potential notification close requests to be sent 32 await new Promise(resolve => iframe.onload = resolve); 33 notifications = await registration.getNotifications(); 34 assert_equals(notifications.length, 1, "Should keep the notification"); 35 }, 'Refreshing window does not clear persistent notifications'); 36 </script> 37 </body>