test_notification_child.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=916893
  5. -->
  6. <head>
  7. <title>Bug 916893 - Test Notifications in child workers.</title>
  8. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <script type="text/javascript" src="/tests/dom/tests/mochitest/notification/MockServices.js"></script>
  10. <script type="text/javascript" src="/tests/dom/tests/mochitest/notification/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=916893">Bug 916893</a>
  15. <p id="display"></p>
  16. <div id="content" style="display: none">
  17. </div>
  18. <pre id="test">
  19. </pre>
  20. <script type="text/javascript">
  21. SimpleTest.requestFlakyTimeout("Mock alert service dispatches show event.");
  22. function runTest() {
  23. MockServices.register();
  24. var w = new Worker("notification_worker_child-parent.js");
  25. w.onmessage = function(e) {
  26. if (e.data.type === 'finish') {
  27. MockServices.unregister();
  28. SimpleTest.finish();
  29. } else if (e.data.type === 'ok') {
  30. ok(e.data.test, e.data.message);
  31. } else if (e.data.type === 'is') {
  32. is(e.data.test1, e.data.test2, e.data.message);
  33. }
  34. }
  35. SimpleTest.waitForExplicitFinish();
  36. // turn on testing pref (used by notification.cpp, and mock the alerts
  37. SpecialPowers.setBoolPref("notification.prompt.testing", true);
  38. w.postMessage('start')
  39. }
  40. SimpleTest.waitForExplicitFinish();
  41. SpecialPowers.pushPrefEnv(
  42. {"set": [["dom.webnotifications.workers.enabled", true]]},
  43. runTest
  44. );
  45. </script>
  46. </body>
  47. </html>