test_notificationclick.html (1913B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=916893 5 --> 6 <head> 7 <title>Bug 1114554 - Test ServiceWorkerGlobalScope.notificationclick event.</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/dom/notification/test/mochitest/MockAlertsService.js"></script> 10 <script src="/tests/dom/notification/test/mochitest/NotificationTest.js"></script> 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 12 </head> 13 <body> 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1114554">Bug 1114554</a> 15 <p id="display"></p> 16 <div id="content" style="display: none"> 17 </div> 18 <pre id="test"> 19 </pre> 20 <script src="/tests/dom/serviceworkers/test/utils.js"></script> 21 <script> 22 SimpleTest.requestFlakyTimeout("Mock alert service dispatches show and click events."); 23 24 add_task(() => setupServiceWorker("notificationclick.serviceworker.js", "notificationclick.html")); 25 26 add_task(async function click() { 27 await MockAlertsService.enableAutoClick(); 28 29 const args = { data: { complex: ["jsval", 5] } }; 30 const event = await testFrame("notificationclick.html", args); 31 isDeeply(event.notification.data, args.data, "Got notificationclick event with the correct data.") 32 is(event.action, "", "Got notificationclick event with an empty action."); 33 is(event.notification.actions.length, 0, "Got notificationclick event with an empty action list."); 34 }); 35 36 add_task(async function clickWithAction() { 37 await MockAlertsService.enableAutoClick("foo"); 38 39 const args = { actions: [{ action: "foo", title: "bar" }] }; 40 const event = await testFrame("notificationclick.html", args); 41 is(event.action, "foo", "Got notificationclick event with the correct action."); 42 isDeeply(event.notification.actions, args.actions, "Got notificationclick event with a correct action list"); 43 }); 44 </script> 45 </body> 46 </html>