test_notification_worker_click.html (882B)
1 <!DOCTYPE HTML> 2 <meta charset="utf-8"> 3 <script src="/tests/SimpleTest/SimpleTest.js"></script> 4 <script src="/tests/dom/notification/test/mochitest/MockAlertsService.js"></script> 5 <script src="/tests/dom/notification/test/mochitest/NotificationTest.js"></script> 6 <link rel="stylesheet" href="/tests/SimpleTest/test.css" /> 7 8 <script> 9 add_task(async function test_notification_worker_click() { 10 await NotificationTest.allowNotifications(); 11 await MockAlertsService.register(); 12 await MockAlertsService.enableAutoClick(); 13 14 var w = new Worker(URL.createObjectURL(new Blob([` 15 new Notification("click").onclick = () => { 16 postMessage("clicked"); 17 }; 18 `]))); 19 await new Promise(resolve => { 20 w.onmessage = function(e) { 21 if (e.data === 'clicked') { 22 resolve(); 23 } 24 } 25 }); 26 ok(true, "notification click event happened from worker"); 27 }); 28 </script>