Bug 1312224: Fix race in browser_ext_browserAction_popup_resize.js. r=me
authorKris Maglione <maglione.k@gmail.com>
Sat, 22 Oct 2016 14:22:43 -0700
changeset 428353 795b9e63823c3750fd9c1a573cdbb0961c994bad
parent 428352 c20146f38762bfc9849ec976ab39b3e63ad5f97e
child 428354 ee09f4fefd0b157eb10c4de871000101334f8cca
child 428355 2e4ece3f9c1182564e5b9127657e954c71f07072
child 428356 d0639cc7c53a898e3339c7958a9a23d4a015519a
child 428363 a8cc44c79c30946426314285c6f63c0f4d2b0295
push id33292
push usercykesiopka.bmo@gmail.com
push dateSun, 23 Oct 2016 05:07:56 +0000
reviewersme
bugs1312224
milestone52.0a1
Bug 1312224: Fix race in browser_ext_browserAction_popup_resize.js. r=me MozReview-Commit-ID: 6pSsJDfNJzO
browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
browser/components/extensions/test/browser/head.js
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
@@ -171,16 +171,18 @@ function* testPopupSize(standardsMode, b
       ok(panelRect.bottom, origPanelRect.bottom, "Panel has not moved upwards");
       ok(panelRect.top <= origPanelRect.top, `Panel has not shrunk from original size (${panelRect.top} <= ${origPanelRect.top})`);
 
       let panelTop = browserWin.mozInnerScreenY + panelRect.top;
       ok(panelTop >= browserWin.screen.availTop, `Top of popup should be on-screen. (${panelTop} >= ${browserWin.screen.availTop})`);
     }
   };
 
+  yield awaitBrowserLoaded(browser);
+
   // Wait long enough to make sure the initial resize debouncing timer has
   // expired.
   yield new Promise(resolve => setTimeout(resolve, 100));
 
   let dims = yield promiseContentDimensions(browser);
 
   is(dims.isStandards, standardsMode, "Document has the expected compat mode");
 
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -125,29 +125,31 @@ function alterContent(browser, task, arg
 
 function getPanelForNode(node) {
   while (node.localName != "panel") {
     node = node.parentNode;
   }
   return node;
 }
 
+var awaitBrowserLoaded = browser => ContentTask.spawn(browser, null, () => {
+  if (content.document.readyState !== "complete") {
+    return ContentTaskUtils.waitForEvent(content, "load").then(() => {});
+  }
+});
+
 var awaitExtensionPanel = Task.async(function* (extension, win = window, awaitLoad = true) {
   let {originalTarget: browser} = yield BrowserTestUtils.waitForEvent(
     win.document, "WebExtPopupLoaded", true,
     event => event.detail.extension.id === extension.id);
 
   yield Promise.all([
     promisePopupShown(getPanelForNode(browser)),
 
-    awaitLoad && ContentTask.spawn(browser, null, () => {
-      if (content.document.readyState !== "complete") {
-        return ContentTaskUtils.waitForEvent(content, "load").then(() => {});
-      }
-    }),
+    awaitLoad && awaitBrowserLoaded(browser),
   ]);
 
   return browser;
 });
 
 function getBrowserActionWidget(extension) {
   return CustomizableUI.getWidget(makeWidgetId(extension.id) + "-browser-action");
 }