Bug 1079303 - Fix tests to not expect sync behaviour from notification.reshow. r=dolske, a=sledru
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 25 Nov 2014 01:06:36 +0000
changeset 242738 46551ecd26867264fa64899738cd3012c0c62285
parent 242737 0ffff4dc528d004d6e249cb83aa66f9edef566ea
child 242739 b777575191d95185e8b822c8632edfbcfd1de034
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske, sledru
bugs1079303
milestone36.0a2
Bug 1079303 - Fix tests to not expect sync behaviour from notification.reshow. r=dolske, a=sledru
browser/base/content/test/general/browser_bug1045809.js
browser/base/content/test/general/browser_bug906190.js
browser/base/content/test/general/browser_customize_popupNotification.js
browser/base/content/test/general/browser_devices_get_user_media.js
browser/base/content/test/general/head.js
browser/base/content/test/plugins/browser_CTP_crashreporting.js
browser/base/content/test/plugins/browser_CTP_data_urls.js
browser/base/content/test/plugins/head.js
browser/base/content/test/popupNotifications/browser_popupNotification_2.js
browser/devtools/webconsole/test/browser_webconsole_block_mixedcontent_securityerrors.js
--- a/browser/base/content/test/general/browser_bug1045809.js
+++ b/browser/base/content/test/general/browser_bug1045809.js
@@ -18,60 +18,60 @@ add_task(function* () {
 
   var url =
     "https://test1.example.com/browser/browser/base/content/test/general/" +
     "file_bug1045809_1.html";
   let tab = gBrowser.selectedTab = gBrowser.addTab();
 
   // Test 1: mixed content must be blocked
   yield promiseTabLoadEvent(tab, url);
-  test1(gBrowser.getBrowserForTab(tab));
+  yield* test1(gBrowser.getBrowserForTab(tab));
 
   yield promiseTabLoadEvent(tab);
   // Test 2: mixed content must NOT be blocked
-  test2(gBrowser.getBrowserForTab(tab));
+  yield* test2(gBrowser.getBrowserForTab(tab));
 
   // Test 3: mixed content must be blocked again
   yield promiseTabLoadEvent(tab);
-  test3(gBrowser.getBrowserForTab(tab));
+  yield* test3(gBrowser.getBrowserForTab(tab));
 });
 
-function test1(gTestBrowser) {
+function* test1(gTestBrowser) {
   var notification =
     PopupNotifications.getNotification("bad-content", gTestBrowser);
   isnot(notification, null, "Mixed Content Doorhanger did appear in Test1");
-  notification.reshow();
+  yield promiseNotificationShown(notification);
   isnot(PopupNotifications.panel.firstChild.isMixedContentBlocked, 0,
     "Mixed Content is being blocked in Test1");
 
   var x = content.document.getElementsByTagName('iframe')[0].contentDocument.getElementById('mixedContentContainer');
   is(x, null, "Mixed Content is NOT to be found in Test1");
 
   // Disable Mixed Content Protection for the page (and reload)
   PopupNotifications.panel.firstChild.disableMixedContentProtection();
 }
 
-function test2(gTestBrowser) {
+function* test2(gTestBrowser) {
   var notification =
     PopupNotifications.getNotification("bad-content", gTestBrowser);
   isnot(notification, null, "Mixed Content Doorhanger did appear in Test2");
-  notification.reshow();
+  yield promiseNotificationShown(notification);
   is(PopupNotifications.panel.firstChild.isMixedContentBlocked, 0,
     "Mixed Content is NOT being blocked in Test2");
 
   var x = content.document.getElementsByTagName('iframe')[0].contentDocument.getElementById('mixedContentContainer');
   isnot(x, null, "Mixed Content is to be found in Test2");
 
   // Re-enable Mixed Content Protection for the page (and reload)
   PopupNotifications.panel.firstChild.enableMixedContentProtection();
 }
 
-function test3(gTestBrowser) {
+function* test3(gTestBrowser) {
   var notification =
     PopupNotifications.getNotification("bad-content", gTestBrowser);
   isnot(notification, null, "Mixed Content Doorhanger did appear in Test3");
-  notification.reshow();
+  yield promiseNotificationShown(notification);
   isnot(PopupNotifications.panel.firstChild.isMixedContentBlocked, 0,
     "Mixed Content is being blocked in Test3");
 
   var x = content.document.getElementsByTagName('iframe')[0].contentDocument.getElementById('mixedContentContainer');
   is(x, null, "Mixed Content is NOT to be found in Test3");
 }
--- a/browser/base/content/test/general/browser_bug906190.js
+++ b/browser/base/content/test/general/browser_bug906190.js
@@ -140,22 +140,23 @@ function waitForSomeTabToLoad(callback) 
   }, true);
 }
 
 function checkPopUpNotification() {
   waitForSomeTabToLoad(reloadedTabAfterDisablingMCB);
 
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in " + curTestName + "!");
-  notification.reshow();
-  ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in " + curTestName + "!");
+  promiseNotificationShown(notification).then(function() {
+    ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in " + curTestName + "!");
 
-  // Disable Mixed Content Protection for the page (and reload page)
-  gTestWin.PopupNotifications.panel.firstChild.disableMixedContentProtection();
-  notification.remove();
+    // Disable Mixed Content Protection for the page (and reload page)
+    gTestWin.PopupNotifications.panel.firstChild.disableMixedContentProtection();
+    notification.remove();
+  });
 }
 
 function reloadedTabAfterDisablingMCB() {
   var expected = "Mixed Content Blocker disabled";
   waitForCondition(
     function() gTestWin.content.document.getElementById('mctestdiv').innerHTML == expected,
     makeSureMCBisDisabled, "Error: Waited too long for mixed script to run in " + curTestName + "!");
 }
@@ -188,25 +189,26 @@ function test1() {
 
 function test1A() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true,
   // because our decision of disabling the mixed content blocker is persistent across tabs.
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 1A!");
-  notification.reshow();
-  ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 1A!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 1A!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1A");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1A");
 
-  gTestWin.gBrowser.removeCurrentTab();
-  test1B();
+    gTestWin.gBrowser.removeCurrentTab();
+    test1B();
+  });
 }
 
 function test1B() {
   curContextMenu = function (e) { contextMenuOpenHandler(e, test1C) };
   gTestWin.document.addEventListener("popupshown", curContextMenu, false);
 
   // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
   let targetElt = gTestWin.content.document.getElementById("Test1");
@@ -216,30 +218,31 @@ function test1B() {
 
 function test1C() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true,
   // because our decision of disabling the mixed content blocker is persistent across tabs.
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 1C!");
-  notification.reshow();
-  ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 1C!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 1C!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1C");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1C");
 
-  // remove tabs
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
-  gTestWin.gBrowser.selectTabAtIndex(0);
+    // remove tabs
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
+    gTestWin.gBrowser.selectTabAtIndex(0);
 
-  var childTabLink = gHttpTestRoot2 + "file_bug906190_2.html";
-  setUpTest("Test2", "linkForTest2", test2, childTabLink);
+    var childTabLink = gHttpTestRoot2 + "file_bug906190_2.html";
+    setUpTest("Test2", "linkForTest2", test2, childTabLink);
+  });
 }
 
 //------------------------ Test 2 ------------------------------
 
 function test2() {
   curClickHandler = function (e) { clickHandler(e, test2A) };
   gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
 
@@ -250,25 +253,26 @@ function test2() {
 
 function test2A() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<,
   // because our decision of disabling the mixed content blocker should only persist if pages are from the same domain.
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 2A!");
-  notification.reshow();
-  ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 2A!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 2A!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2A");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2A");
 
-  gTestWin.gBrowser.removeCurrentTab();
-  test2B();
+    gTestWin.gBrowser.removeCurrentTab();
+    test2B();
+  });
 }
 
 function test2B() {
   curContextMenu = function (e) { contextMenuOpenHandler(e, test2C) };
   gTestWin.document.addEventListener("popupshown", curContextMenu, false);
 
   // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
   let targetElt = gTestWin.content.document.getElementById("Test2");
@@ -278,31 +282,32 @@ function test2B() {
 
 function test2C() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<,
   // because our decision of disabling the mixed content blocker should only persist if pages are from the same domain.
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 2C!");
-  notification.reshow();
-  ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 2C!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 2C!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2C");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2C");
 
-  // remove tabs
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
-  gTestWin.gBrowser.selectTabAtIndex(0);
+    // remove tabs
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
+    gTestWin.gBrowser.selectTabAtIndex(0);
 
-  // file_bug906190_3_4.html redirects to page test1.example.com/* using meta-refresh
-  var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html";
-  setUpTest("Test3", "linkForTest3", test3, childTabLink);
+    // file_bug906190_3_4.html redirects to page test1.example.com/* using meta-refresh
+    var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html";
+    setUpTest("Test3", "linkForTest3", test3, childTabLink);
+  });
 }
 
 //------------------------ Test 3 ------------------------------
 
 function test3() {
   curClickHandler = function (e) { clickHandler(e, test3A) };
   gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
   // simulating |CTRL-CLICK|
@@ -316,26 +321,27 @@ function test3A() {
 }
 
 function test3B() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true!
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 3B!");
-  notification.reshow();
-  ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 3B!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 3B!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3B");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3B");
 
-  // remove tabs
-  gTestWin.gBrowser.removeCurrentTab();
-  test3C();
+    // remove tabs
+    gTestWin.gBrowser.removeCurrentTab();
+    test3C();
+  });
 }
 
 function test3C() {
   curContextMenu = function (e) { contextMenuOpenHandler(e, test3D) };
   gTestWin.document.addEventListener("popupshown", curContextMenu, false);
 
   // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
   let targetElt = gTestWin.content.document.getElementById("Test3");
@@ -348,30 +354,31 @@ function test3D() {
 }
 
 function test3E() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true!
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 3E!");
-  notification.reshow();
-  ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 3E!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 3E!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3E");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3E");
 
-  // remove tabs
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
-  gTestWin.gBrowser.selectTabAtIndex(0);
+    // remove tabs
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
+    gTestWin.gBrowser.selectTabAtIndex(0);
 
-  var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html";
-  setUpTest("Test4", "linkForTest4", test4, childTabLink);
+    var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html";
+    setUpTest("Test4", "linkForTest4", test4, childTabLink);
+  });
 }
 
 //------------------------ Test 4 ------------------------------
 
 function test4() {
   curClickHandler = function (e) { clickHandler(e, test4A) };
   gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
 
@@ -386,26 +393,27 @@ function test4A() {
 }
 
 function test4B() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 4B!");
-  notification.reshow();
-  ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 4B!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 4B!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4B");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4B");
 
-  // remove tabs
-  gTestWin.gBrowser.removeCurrentTab();
-  test4C();
+    // remove tabs
+    gTestWin.gBrowser.removeCurrentTab();
+    test4C();
+  });
 }
 
 function test4C() {
   curContextMenu = function (e) { contextMenuOpenHandler(e, test4D) };
   gTestWin.document.addEventListener("popupshown", curContextMenu, false);
 
   // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
   let targetElt = gTestWin.content.document.getElementById("Test4");
@@ -418,31 +426,32 @@ function test4D() {
 }
 
 function test4E() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 4E!");
-  notification.reshow();
-  ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 4E!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 4E!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4E");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4E");
 
-  // remove tabs
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
-  gTestWin.gBrowser.selectTabAtIndex(0);
+    // remove tabs
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
+    gTestWin.gBrowser.selectTabAtIndex(0);
 
-  // the sjs files returns a 302 redirect- note, same origins
-  var childTabLink = gHttpTestRoot1 + "file_bug906190.sjs";
-  setUpTest("Test5", "linkForTest5", test5, childTabLink);
+    // the sjs files returns a 302 redirect- note, same origins
+    var childTabLink = gHttpTestRoot1 + "file_bug906190.sjs";
+    setUpTest("Test5", "linkForTest5", test5, childTabLink);
+  });
 }
 
 //------------------------ Test 5 ------------------------------
 
 function test5() {
   curClickHandler = function (e) { clickHandler(e, test5A) };
   gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
 
@@ -453,26 +462,27 @@ function test5() {
 
 function test5A() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true
   // Currently it is >> TRUE << - see follow up bug 914860
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 5A!");
-  notification.reshow();
-  todo(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 5A!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    todo(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 5A!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5A!");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5A!");
 
-  // remove tabs
-  gTestWin.gBrowser.removeCurrentTab();
-  test5B();
+    // remove tabs
+    gTestWin.gBrowser.removeCurrentTab();
+    test5B();
+  });
 }
 
 function test5B() {
   curContextMenu = function (e) { contextMenuOpenHandler(e, test5C) };
   gTestWin.document.addEventListener("popupshown", curContextMenu, false);
 
   // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
   let targetElt = gTestWin.content.document.getElementById("Test5");
@@ -482,31 +492,32 @@ function test5B() {
 function test5C() {
   // move the tab again
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear but isMixedContentBlocked should be >> NOT << true
   // Currently it is >> TRUE << - see follow up bug 914860
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 5C!");
-  notification.reshow();
-  todo(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 5C!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    todo(!gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is NOT being blocked in Test 5C!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5C!");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5C!");
 
-  // remove tabs
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
-  gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
-  gTestWin.gBrowser.selectTabAtIndex(0);
+    // remove tabs
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
+    gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
+    gTestWin.gBrowser.selectTabAtIndex(0);
 
-  // the sjs files returns a 302 redirect - note, different origins
-  var childTabLink = gHttpTestRoot2 + "file_bug906190.sjs";
-  setUpTest("Test6", "linkForTest6", test6, childTabLink);
+    // the sjs files returns a 302 redirect - note, different origins
+    var childTabLink = gHttpTestRoot2 + "file_bug906190.sjs";
+    setUpTest("Test6", "linkForTest6", test6, childTabLink);
+  });
 }
 
 //------------------------ Test 6 ------------------------------
 
 function test6() {
   curClickHandler = function (e) { clickHandler(e, test6A) };
   gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
 
@@ -516,26 +527,27 @@ function test6() {
 }
 
 function test6A() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 6A!");
-  notification.reshow();
-  ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 6A!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 6A!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6A");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6A");
 
-  // done
-  gTestWin.gBrowser.removeCurrentTab();
-  test6B();
+    // done
+    gTestWin.gBrowser.removeCurrentTab();
+    test6B();
+  });
 }
 
 function test6B() {
   curContextMenu = function (e) { contextMenuOpenHandler(e, test6C) };
   gTestWin.document.addEventListener("popupshown", curContextMenu, false);
 
   // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
   let targetElt = gTestWin.content.document.getElementById("Test6");
@@ -543,25 +555,26 @@ function test6B() {
 }
 
 function test6C() {
   gTestWin.gBrowser.selectTabAtIndex(2);
 
   // The Doorhanger should appear and isMixedContentBlocked should be >> TRUE <<
   var notification = PopupNotifications.getNotification("bad-content", gTestWin.gBrowser.selectedBrowser);
   ok(notification, "OK: Mixed Content Doorhanger did appear in Test 6C!");
-  notification.reshow();
-  ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 6C!");
-  notification.remove();
+  promiseNotificationShown(notification).then(function() {
+    ok(gTestWin.PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked in Test 6C!");
+    notification.remove();
 
-  var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
-  is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6C");
+    var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
+    is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6C");
 
-  gTestWin.close();
-  finish();
+    gTestWin.close();
+    finish();
+  });
 }
 
 //------------------------ SETUP ------------------------------
 
 function setupTestBrowserWindow() {
   // Inject links in content.
   let doc = gTestWin.content.document;
   let mainDiv = doc.createElement("div");
--- a/browser/base/content/test/general/browser_customize_popupNotification.js
+++ b/browser/base/content/test/general/browser_customize_popupNotification.js
@@ -1,30 +1,35 @@
 /*
 Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/
 */
 
 function test() {
   waitForExplicitFinish();
   let newWin = OpenBrowserWindow();
+  registerCleanupFunction(() => {
+    newWin.close()
+    newWin = null;
+  });
   whenDelayedStartupFinished(newWin, function () {
     // Remove the URL bar
     newWin.gURLBar.parentNode.removeChild(newWin.gURLBar);
 
     waitForFocus(function () {
       let PN = newWin.PopupNotifications;
-      PN.transitionsEnabled = false;
       try {
+        let panelPromise = promisePopupShown(PN.panel);
         let notification = PN.show(newWin.gBrowser.selectedBrowser, "some-notification", "Some message");
-        ok(notification, "showed the notification");
-        ok(PN.isPanelOpen, "panel is open");
-        is(PN.panel.anchorNode, newWin.gBrowser.selectedTab, "notification is correctly anchored to the tab");
-        PN.panel.hidePopup();
+        panelPromise.then(function() {
+          ok(notification, "showed the notification");
+          ok(PN.isPanelOpen, "panel is open");
+          is(PN.panel.anchorNode, newWin.gBrowser.selectedTab, "notification is correctly anchored to the tab");
+          PN.panel.hidePopup();
+          finish();
+        });
       } catch (ex) {
         ok(false, "threw exception: " + ex);
+        finish();
       }
-      PN.transitionsEnabled = true;
-      newWin.close();
-      finish();
     }, newWin);
   });
 }
--- a/browser/base/content/test/general/browser_devices_get_user_media.js
+++ b/browser/base/content/test/general/browser_devices_get_user_media.js
@@ -432,17 +432,17 @@ let gTests = [
     });
     expectObserverCalled("getUserMedia:response:allow");
     expectObserverCalled("recording-device-events");
     is(getMediaCaptureState(), "CameraAndMicrophone",
        "expected camera and microphone to be shared");
 
     yield checkSharingUI({video: true, audio: true});
 
-    PopupNotifications.getNotification("webRTC-sharingDevices").reshow();
+    yield promiseNotificationShown(PopupNotifications.getNotification("webRTC-sharingDevices"));
     activateSecondaryAction(kActionDeny);
 
     yield promiseObserverCalled("recording-device-events");
     expectObserverCalled("getUserMedia:revoke");
 
     yield promiseNoPopupNotification("webRTC-sharingDevices");
     expectObserverCalled("recording-window-ended");
 
@@ -697,17 +697,17 @@ let gTests = [
       yield promiseMessage("ok", () => {
         content.wrappedJSObject.requestDevice(aRequestAudio, aRequestVideo);
       });
       expectObserverCalled("getUserMedia:request");
       expectObserverCalled("getUserMedia:response:allow");
       expectObserverCalled("recording-device-events");
       yield checkSharingUI({video: aRequestVideo, audio: aRequestAudio});
 
-      PopupNotifications.getNotification("webRTC-sharingDevices").reshow();
+      yield promiseNotificationShown(PopupNotifications.getNotification("webRTC-sharingDevices"));
       let expectedIcon = "webRTC-sharingDevices";
       if (aRequestAudio && !aRequestVideo)
         expectedIcon = "webRTC-sharingMicrophone";
       is(PopupNotifications.getNotification("webRTC-sharingDevices").anchorID,
          expectedIcon + "-notification-icon", "anchored to correct icon");
       is(PopupNotifications.panel.firstChild.getAttribute("popupid"), expectedIcon,
          "panel using correct icon");
 
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -775,16 +775,26 @@ function promisePopupEvent(popup, eventS
 function promisePopupShown(popup) {
   return promisePopupEvent(popup, "shown");
 }
 
 function promisePopupHidden(popup) {
   return promisePopupEvent(popup, "hidden");
 }
 
+function promiseNotificationShown(notification) {
+  let win = notification.browser.ownerDocument.defaultView;
+  if (win.PopupNotifications.panel.state == "open") {
+    return Promise.resolved();
+  }
+  let panelPromise = promisePopupShown(win.PopupNotifications.panel);
+  notification.reshow();
+  return panelPromise;
+}
+
 // NOTE: If you're using this, and attempting to interact with one of the
 // autocomplete results, your test is likely to be unreliable on Linux.
 // See bug 1073339.
 let gURLBarOnSearchComplete = null;
 function promiseSearchComplete() {
   info("Waiting for onSearchComplete");
   return new Promise(resolve => {
     if (!gURLBarOnSearchComplete) {
--- a/browser/base/content/test/plugins/browser_CTP_crashreporting.js
+++ b/browser/base/content/test/plugins/browser_CTP_crashreporting.js
@@ -127,21 +127,21 @@ function afterBindingAttached() {
   let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(popupNotification, "Should have a click-to-play notification");
 
   let plugin = gTestBrowser.contentDocument.getElementById("test");
   let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(!objLoadingContent.activated, "Plugin should not be activated");
 
   // Simulate clicking the "Allow Always" button.
-  popupNotification.reshow();
-  PopupNotifications.panel.firstChild._primaryButton.click();
-
-  let condition = function() objLoadingContent.activated;
-  waitForCondition(condition, pluginActivated, "Waited too long for plugin to activate");
+  waitForNotificationShown(popupNotification, function() {
+    PopupNotifications.panel.firstChild._primaryButton.click();
+    let condition = function() objLoadingContent.activated;
+    waitForCondition(condition, pluginActivated, "Waited too long for plugin to activate");
+  });
 }
 
 function pluginActivated() {
   let mm = gTestBrowser.messageManager;
   mm.sendAsyncMessage("test:crash-plugin");
 }
 
 function onSubmitStatus(subj, topic, data) {
--- a/browser/base/content/test/plugins/browser_CTP_data_urls.js
+++ b/browser/base/content/test/plugins/browser_CTP_data_urls.js
@@ -80,21 +80,22 @@ function test1b() {
   let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(popupNotification, "Test 1b, Should have a click-to-play notification");
 
   let plugin = gTestBrowser.contentDocument.getElementById("test");
   let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(!objLoadingContent.activated, "Test 1b, Plugin should not be activated");
 
   // Simulate clicking the "Allow Always" button.
-  popupNotification.reshow();
-  PopupNotifications.panel.firstChild._primaryButton.click();
+  waitForNotificationShown(popupNotification, function() {
+    PopupNotifications.panel.firstChild._primaryButton.click();
 
-  let condition = function() objLoadingContent.activated;
-  waitForCondition(condition, test1c, "Test 1b, Waited too long for plugin to activate");
+    let condition = function() objLoadingContent.activated;
+    waitForCondition(condition, test1c, "Test 1b, Waited too long for plugin to activate");
+  });
 }
 
 function test1c() {
   clearAllPluginPermissions();
   prepareTest(runAfterPluginBindingAttached(test2a), gHttpTestRoot + "plugin_data_url.html");
 }
 
 // Test that the click-to-play notification doesn't break when navigating to data URLs with multiple plugins
@@ -109,46 +110,47 @@ function test2a() {
   gTestBrowser.contentDocument.getElementById("data-link-2").click();
 }
 
 function test2b() {
   let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(notification, "Test 2b, Should have a click-to-play notification");
 
   // Simulate choosing "Allow now" for the test plugin
-  notification.reshow();
-  is(notification.options.pluginData.size, 2, "Test 2b, Should have two types of plugin in the notification");
+  waitForNotificationShown(notification, function() {
+    is(notification.options.pluginData.size, 2, "Test 2b, Should have two types of plugin in the notification");
 
-  var centerAction = null;
-  for (var action of notification.options.pluginData.values()) {
-    if (action.pluginName == "Test") {
-      centerAction = action;
-      break;
+    var centerAction = null;
+    for (var action of notification.options.pluginData.values()) {
+      if (action.pluginName == "Test") {
+        centerAction = action;
+        break;
+      }
     }
-  }
-  ok(centerAction, "Test 2b, found center action for the Test plugin");
+    ok(centerAction, "Test 2b, found center action for the Test plugin");
 
-  var centerItem = null;
-  for (var item of PopupNotifications.panel.firstChild.childNodes) {
-    is(item.value, "block", "Test 2b, all plugins should start out blocked");
-    if (item.action == centerAction) {
-      centerItem = item;
-      break;
+    var centerItem = null;
+    for (var item of PopupNotifications.panel.firstChild.childNodes) {
+      is(item.value, "block", "Test 2b, all plugins should start out blocked");
+      if (item.action == centerAction) {
+        centerItem = item;
+        break;
+      }
     }
-  }
-  ok(centerItem, "Test 2b, found center item for the Test plugin");
+    ok(centerItem, "Test 2b, found center item for the Test plugin");
+
+    // "click" the button to activate the Test plugin
+    centerItem.value = "allownow";
+    PopupNotifications.panel.firstChild._primaryButton.click();
 
-  // "click" the button to activate the Test plugin
-  centerItem.value = "allownow";
-  PopupNotifications.panel.firstChild._primaryButton.click();
-
-  let plugin = gTestBrowser.contentDocument.getElementById("test1");
-  let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
-  let condition = function() objLoadingContent.activated;
-  waitForCondition(condition, test2c, "Test 2b, Waited too long for plugin to activate");
+    let plugin = gTestBrowser.contentDocument.getElementById("test1");
+    let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
+    let condition = function() objLoadingContent.activated;
+    waitForCondition(condition, test2c, "Test 2b, Waited too long for plugin to activate");
+  });
 }
 
 function test2c() {
   let plugin = gTestBrowser.contentDocument.getElementById("test1");
   let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(objLoadingContent.activated, "Test 2c, Plugin should be activated");
 
   clearAllPluginPermissions();
@@ -159,21 +161,22 @@ function test2c() {
 function test3a() {
   let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(popupNotification, "Test 3a, Should have a click-to-play notification");
   let plugin = gTestBrowser.contentDocument.getElementById("test");
   let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(!objLoadingContent.activated, "Test 3a, Plugin should not be activated");
 
   // Simulate clicking the "Allow Always" button.
-  popupNotification.reshow();
-  PopupNotifications.panel.firstChild._primaryButton.click();
+  waitForNotificationShown(popupNotification, function() {
+    PopupNotifications.panel.firstChild._primaryButton.click();
 
-  let condition = function() objLoadingContent.activated;
-  waitForCondition(condition, test3b, "Test 3a, Waited too long for plugin to activate");
+    let condition = function() objLoadingContent.activated;
+    waitForCondition(condition, test3b, "Test 3a, Waited too long for plugin to activate");
+  });
 }
 
 function test3b() {
   gNextTest = test3c;
   gTestBrowser.contentDocument.getElementById("data-link-1").click();
 }
 
 function test3c() {
@@ -190,19 +193,20 @@ function test3c() {
 function test4a() {
   let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(popupNotification, "Test 4a, Should have a click-to-play notification");
   let plugin = gTestBrowser.contentDocument.getElementById("test");
   let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
   ok(!objLoadingContent.activated, "Test 4a, Plugin should not be activated");
 
   // Simulate clicking the "Allow Always" button.
-  popupNotification.reshow();
-  PopupNotifications.panel.firstChild._primaryButton.click();
+  waitForNotificationShown(popupNotification, function() {
+    PopupNotifications.panel.firstChild._primaryButton.click();
 
-  let condition = function() objLoadingContent.activated;
-  waitForCondition(condition, test4b, "Test 4a, Waited too long for plugin to activate");
+    let condition = function() objLoadingContent.activated;
+    waitForCondition(condition, test4b, "Test 4a, Waited too long for plugin to activate");
+  });
 }
 
 function test4b() {
   clearAllPluginPermissions();
   finishTest();
 }
--- a/browser/base/content/test/plugins/head.js
+++ b/browser/base/content/test/plugins/head.js
@@ -149,16 +149,36 @@ function waitForNotificationBar(notifica
         resolve(notification);
       },
       `Waited too long for the ${notificationID} notification bar`
     );
   });
 }
 
 /**
+ * Reshow a notification and call a callback when it is reshown.
+ * @param notification
+ *        The notification to reshow
+ * @param callback
+ *        A function to be called when the notification has been reshown
+ */
+function waitForNotificationShown(notification, callback)
+{
+  if (PopupNotifications.panel.state == "open") {
+    executeSoon(callback);
+    return;
+  }
+  PopupNotifications.panel.addEventListener("popupshown", function onShown(e) {
+    PopupNotifications.panel.removeEventListener("popupshown", onShown);
+    callback();
+  }, false);
+  notification.reshow();
+}
+
+/**
  * Due to layout being async, "PluginBindAttached" may trigger later.
  * This returns a Promise that resolves once we've forced a layout
  * flush, which triggers the PluginBindAttached event to fire.
  *
  * @param browser
  *        The browser to force plugin bindings in.
  *
  * @return Promise
--- a/browser/base/content/test/popupNotifications/browser_popupNotification_2.js
+++ b/browser/base/content/test/popupNotifications/browser_popupNotification_2.js
@@ -221,22 +221,22 @@ let tests = [
     }
   },
   // Test notification when chrome is hidden
   { id: "Test#10",
     run: function () {
       window.locationbar.visible = false;
       this.notifyObj = new BasicNotification(this.id);
       this.notification = showNotification(this.notifyObj);
-      window.locationbar.visible = true;
     },
     onShown: function (popup) {
       checkPopup(popup, this.notifyObj);
       is(popup.anchorNode.className, "tabbrowser-tab", "notification anchored to tab");
       dismissNotification(popup);
     },
     onHidden: function (popup) {
       ok(this.notifyObj.dismissalCallbackTriggered, "dismissal callback triggered");
       this.notification.remove();
       ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered");
+      window.locationbar.visible = true;
     }
   }
 ];
--- a/browser/devtools/webconsole/test/browser_webconsole_block_mixedcontent_securityerrors.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_block_mixedcontent_securityerrors.js
@@ -49,21 +49,40 @@ function blockMixedContentTest1()
         testClickOpenNewTab(hud, result);
         // Call the second (MCB override) test.
         mixedContentOverrideTest2(hud);
       });
     });
   }, true);
 }
 
+function waitForNotificationShown(notification, callback)
+{
+  if (PopupNotifications.panel.state == "open") {
+    executeSoon(callback);
+    return;
+  }
+  PopupNotifications.panel.addEventListener("popupshown", function onShown(e) {
+    PopupNotifications.panel.removeEventListener("popupshown", onShown);
+    callback();
+  }, false);
+  notification.reshow();
+}
+
 function mixedContentOverrideTest2(hud)
 {
   var notification = PopupNotifications.getNotification("bad-content", browser);
   ok(notification, "Mixed Content Doorhanger did appear");
-  notification.reshow();
+  waitForNotificationShown(notification, () => {
+    afterNotificationShown(hud, notification);
+  });
+}
+
+function afterNotificationShown(hud, notification)
+{
   ok(PopupNotifications.panel.firstChild.isMixedContentBlocked, "OK: Mixed Content is being blocked");
   // Click on the doorhanger.
   PopupNotifications.panel.firstChild.disableMixedContentProtection();
   notification.remove();
 
   waitForMessages({
     webconsole: hud,
     messages: [