Bug 1396362 - Fix intermittent test_ext_notifications.html, r=mixedpuppy
authorBob Silverberg <bsilverberg@mozilla.com>
Wed, 06 Sep 2017 08:59:36 -0400
changeset 429281 98e8ee4d55ddf9ffecc2e40b4ef7fe3a8220ab3a
parent 429280 20f6207757f3f493b5613ac3e862850cff4fcb97
child 429282 40df319376b8b788ce75435c17117a0134a447f8
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1396362
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1396362 - Fix intermittent test_ext_notifications.html, r=mixedpuppy MozReview-Commit-ID: 67LDQuEvDZI
toolkit/components/extensions/test/mochitest/test_ext_notifications.html
--- a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_notifications.html
@@ -41,53 +41,59 @@ add_task(async function test_notificatio
   await extension.startup();
   let x = await extension.awaitMessage("running");
   is(x, "0", "got correct id from notifications.create");
   await extension.awaitFinish();
   await extension.unload();
 });
 
 add_task(async function test_notification_events() {
-  async function background() {
+  function background() {
     let opts = {
       type: "basic",
       title: "Testing Notification",
       message: "Carry on",
     };
 
+    let createdId = "98";
+
     // Test an ignored listener.
     browser.notifications.onButtonClicked.addListener(function() {});
 
     // We cannot test onClicked listener without a mock
     // but we can attempt to add a listener.
     browser.notifications.onClicked.addListener(function() {});
 
-    // Test onClosed listener.
-    browser.notifications.onClosed.addListener(id => {
-      browser.test.sendMessage("closed", id);
-      browser.test.notifyPass("background test passed");
+    browser.notifications.onShown.addListener(async function listener(id) {
+      browser.notifications.onShown.removeListener(listener);
+      browser.test.assertEq(createdId, id, "onShown received the expected id.");
+      let newId = await browser.notifications.create(id, opts);
+      browser.test.assertEq(createdId, newId, "create returned the expected id.");
+      browser.test.sendMessage("created");
     });
 
-    await browser.notifications.create("5", opts);
-    let id = await browser.notifications.create("5", opts);
-    browser.test.sendMessage("running", id);
+    // Test onClosed listener.
+    browser.notifications.onClosed.addListener(function listener(id) {
+      browser.notifications.onClosed.removeListener(listener);
+      browser.test.assertEq(createdId, id, "onClosed received the expected id.");
+      browser.test.sendMessage("closed");
+    });
+
+    browser.notifications.create(createdId, opts);
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: ["notifications"],
     },
     background,
   });
   await extension.startup();
-  let x = await extension.awaitMessage("closed");
-  is(x, "5", "got correct id from onClosed listener");
-  x = await extension.awaitMessage("running");
-  is(x, "5", "got correct id from notifications.create");
-  await extension.awaitFinish();
+  await extension.awaitMessage("closed");
+  await extension.awaitMessage("created");
   await extension.unload();
 });
 
 add_task(async function test_notification_clear() {
   function background() {
     let opts = {
       type: "basic",
       title: "Testing Notification",