Bug 976513 - Australis - Yield all the close windows in tests to avoid randomorange. a=sledru
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 28 Feb 2014 17:46:27 +0000
changeset 183141 fbac1671ae4af0dd87df8542ad8aa6694a274a32
parent 183140 d78ce87f31a609eaa892dd7268c364d597512619
child 183142 a8c6900388bddbfa48266e0a44a41d757d3b4b7b
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssledru
bugs976513
milestone29.0a2
Bug 976513 - Australis - Yield all the close windows in tests to avoid randomorange. a=sledru
browser/components/customizableui/test/browser_876926_customize_mode_wrapping.js
browser/components/customizableui/test/browser_880164_customization_context_menus.js
browser/components/customizableui/test/browser_885530_showInPrivateBrowsing.js
browser/components/customizableui/test/browser_888817_currentset_updating.js
browser/components/customizableui/test/browser_909779_overflow_toolbars_new_window.js
browser/components/customizableui/test/browser_943683_migration_test.js
browser/components/customizableui/test/browser_945739_showInPrivateBrowsing_customize_mode.js
browser/components/customizableui/test/browser_947987_removable_default.js
browser/components/customizableui/test/browser_972267_customizationchange_events.js
browser/components/customizableui/test/head.js
--- a/browser/components/customizableui/test/browser_876926_customize_mode_wrapping.js
+++ b/browser/components/customizableui/test/browser_876926_customize_mode_wrapping.js
@@ -124,19 +124,16 @@ add_task(function MoveWidgetsInTwoWindow
       checkToolbar(widgetId, method);
       checkPanel(widgetId, method);
       checkPalette(widgetId, method);
       checkPanel(widgetId, method);
       checkToolbar(widgetId, method);
       checkPalette(widgetId, method);
     }
   }
-  otherWin.close();
+  yield promiseWindowClosed(otherWin);
   otherWin = null;
-  if (otherWin) {
-    otherWin.close();
-  }
   yield endCustomizing();
 });
 
 add_task(function asyncCleanup() {
   yield resetCustomization();
 });
--- a/browser/components/customizableui/test/browser_880164_customization_context_menus.js
+++ b/browser/components/customizableui/test/browser_880164_customization_context_menus.js
@@ -218,17 +218,17 @@ add_task(function() {
     [".viewCustomizeToolbar", false]
   ];
   checkContextMenu(contextMenu, expectedEntries, this.otherWin);
 
   let hiddenContextPromise = contextMenuHidden(contextMenu);
   contextMenu.hidePopup();
   yield hiddenContextPromise;
   yield endCustomizing(this.otherWin);
-  this.otherWin.close();
+  yield promiseWindowClosed(this.otherWin);
   this.otherWin = null;
 });
 
 // Bug 945191 - Combined buttons show wrong context menu options
 // when they are in the toolbar.
 add_task(function() {
   yield startCustomizing();
   let contextMenu = document.getElementById("customizationPanelItemContextMenu");
--- a/browser/components/customizableui/test/browser_885530_showInPrivateBrowsing.js
+++ b/browser/components/customizableui/test/browser_885530_showInPrivateBrowsing.js
@@ -67,20 +67,17 @@ add_task(function() {
   assertWidgetExists(private2, false);
 
   CustomizableUI.removeWidgetFromArea("some-widget");
   assertWidgetExists(plain1, false);
   assertWidgetExists(plain2, false);
   assertWidgetExists(private1, false);
   assertWidgetExists(private2, false);
 
-  plain1.close();
-  plain2.close();
-  private1.close();
-  private2.close();
+  yield Promise.all([plain1, plain2, private1, private2].map(promiseWindowClosed));
 
   CustomizableUI.destroyWidget("some-widget");
 });
 
 // Add a widget via the API with showInPrivateBrowsing set to true,
 // and ensure that it appears in pre-existing or newly created
 // private browsing windows.
 add_task(function() {
@@ -122,19 +119,16 @@ add_task(function() {
   assertWidgetExists(private2, true);
 
   CustomizableUI.removeWidgetFromArea("some-widget");
   assertWidgetExists(plain1, false);
   assertWidgetExists(plain2, false);
   assertWidgetExists(private1, false);
   assertWidgetExists(private2, false);
 
-  plain1.close();
-  plain2.close();
-  private1.close();
-  private2.close();
+  yield Promise.all([plain1, plain2, private1, private2].map(promiseWindowClosed));
 
   CustomizableUI.destroyWidget("some-widget");
 });
 
 add_task(function asyncCleanup() {
   yield resetCustomization();
 });
--- a/browser/components/customizableui/test/browser_888817_currentset_updating.js
+++ b/browser/components/customizableui/test/browser_888817_currentset_updating.js
@@ -41,17 +41,17 @@ add_task(function() {
 
   CustomizableUI.removeWidgetFromArea("home-button");
   personalbarCurrentset = personalbarCurrentset.replace(",home-button", "");
   is(personalbar.getAttribute("currentset"), personalbarCurrentset,
      "Should have updated currentSet after remove.");
   is(otherPersonalbar.getAttribute("currentset"), personalbarCurrentset,
      "Should have updated other window's currentSet after remove.");
 
-  otherWin.close();
+  yield promiseWindowClosed(otherWin);
   // Reset in asyncCleanup will put our button back for us.
 });
 
 add_task(function asyncCleanup() {
   let personalbar = document.getElementById(CustomizableUI.AREA_BOOKMARKS);
   setToolbarVisibility(personalbar, false);
   yield resetCustomization();
 });
--- a/browser/components/customizableui/test/browser_909779_overflow_toolbars_new_window.js
+++ b/browser/components/customizableui/test/browser_909779_overflow_toolbars_new_window.js
@@ -14,17 +14,17 @@ add_task(function() {
   yield waitForCondition(() => navbar.hasAttribute("overflowing"));
   ok(navbar.hasAttribute("overflowing"), "Should have an overflowing toolbar.");
 
   ok(navbar.customizationTarget.childElementCount < oldChildCount, "Should have fewer children.");
   let newWindow = yield openAndLoadWindow();
   let otherNavBar = newWindow.document.getElementById(CustomizableUI.AREA_NAVBAR);
   yield waitForCondition(() => otherNavBar.hasAttribute("overflowing"));
   ok(otherNavBar.hasAttribute("overflowing"), "Other window should have an overflowing toolbar.");
-  newWindow.close();
+  yield promiseWindowClosed(newWindow);
 
   window.resizeTo(originalWindowWidth, window.outerHeight);
   yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
   ok(!navbar.hasAttribute("overflowing"), "Should no longer have an overflowing toolbar.");
 });
 
 add_task(function asyncCleanup() {
   yield resetCustomization();
--- a/browser/components/customizableui/test/browser_943683_migration_test.js
+++ b/browser/components/customizableui/test/browser_943683_migration_test.js
@@ -37,14 +37,14 @@ add_task(function() {
        "Other window should have the same number of migrated items.");
     if (migrationArray.length == otherMigrationArray.length) {
       for (let widget of migrationArray) {
         isnot(otherMigrationArray.indexOf(widget), -1,
               "Migrated widget " + widget + " should also be listed as migrated in the other window.");
       }
     }
   } finally {
-    otherWindow.close();
+    yield promiseWindowClosed(otherWindow);
   }
   btn.remove();
   btn2.remove();
   CustomizableUI.reset();
 });
--- a/browser/components/customizableui/test/browser_945739_showInPrivateBrowsing_customize_mode.js
+++ b/browser/components/customizableui/test/browser_945739_showInPrivateBrowsing_customize_mode.js
@@ -20,16 +20,16 @@ add_task(function testPrivateBrowsingCus
   ok(normalWidgetArray.indexOf(kWidgetId) > -1,
      "Widget should appear as unused in non-private window");
 
   let privateWindow = yield openAndLoadWindow({private: true});
   let privateWidgetArray = CustomizableUI.getUnusedWidgets(privateWindow.gNavToolbox.palette);
   privateWidgetArray = privateWidgetArray.map((w) => w.id);
   is(privateWidgetArray.indexOf(kWidgetId), -1,
      "Widget should not appear as unused in private window");
-  privateWindow.close();
+  yield promiseWindowClosed(privateWindow);
 
   CustomizableUI.destroyWidget(kWidgetId); 
 });
 
 add_task(function asyncCleanup() {
   yield resetCustomization();
 });
--- a/browser/components/customizableui/test/browser_947987_removable_default.js
+++ b/browser/components/customizableui/test/browser_947987_removable_default.js
@@ -54,14 +54,14 @@ add_task(function() {
   if (singleWrapper) {
     ok(singleWrapper.node, "Widget node should exist in other window.");
     if (singleWrapper.node) {
       let expectedParent = CustomizableUI.getCustomizeTargetForArea(kNavBar, otherWin);
       is(singleWrapper.node.parentNode, expectedParent,
          "Widget should be in navbar in other window.");
     }
   }
-  otherWin.close();
+  yield promiseWindowClosed(otherWin);
 });
 
 add_task(function asyncCleanup() {
   yield resetCustomization();
 });
--- a/browser/components/customizableui/test/browser_972267_customizationchange_events.js
+++ b/browser/components/customizableui/test/browser_972267_customizationchange_events.js
@@ -33,15 +33,15 @@ add_task(function() {
 
   handlerCalledCount = 0;
   gCustomizeMode.addToToolbar(homeButton);
   is(handlerCalledCount, 2, "Should be called for both windows.");
 
   gNavToolbox.removeEventListener("customizationchange", handler);
   otherToolbox.removeEventListener("customizationchange", handler);
 
-  newWindow.close();
+  yield promiseWindowClosed(newWindow);
 });
 
 add_task(function asyncCleanup() {
   yield resetCustomization();
 });
 
--- a/browser/components/customizableui/test/head.js
+++ b/browser/components/customizableui/test/head.js
@@ -197,16 +197,21 @@ function openAndLoadWindow(aOptions, aWa
     win.addEventListener("load", function onLoad() {
       win.removeEventListener("load", onLoad);
       deferred.resolve(win);
     });
   }
   return deferred.promise;
 }
 
+function promiseWindowClosed(win) {
+  win.close();
+  return waitForCondition(() => win.closed);
+}
+
 function promisePanelShown(win) {
   let panelEl = win.PanelUI.panel;
   return promisePanelElementShown(win, panelEl);
 }
 
 function promiseOverflowShown(win) {
   let panelEl = win.document.getElementById("widget-overflow");
   return promisePanelElementShown(win, panelEl);