Bug 1385882 - Intermittent browser/base/content/test/urlbar/browser_page_action_menu.js | Test timed out. r=Gijs
authorDrew Willcoxon <adw@mozilla.com>
Mon, 02 Oct 2017 10:55:00 -0700
changeset 384158 01b425a64b974c258d1b7628e0268f71f5af7f4a
parent 384157 b2d7d2ca373dcc0a8b77f6755d33a3f2b6c7e517
child 384159 63c7cfadae7b24a90d956237ebb9ad5baf3e76c1
push id52518
push usergijskruitbosch@gmail.com
push dateTue, 03 Oct 2017 10:42:47 +0000
treeherderautoland@01b425a64b97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1385882
milestone58.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 1385882 - Intermittent browser/base/content/test/urlbar/browser_page_action_menu.js | Test timed out. r=Gijs MozReview-Commit-ID: 8uzQAPQEldP
browser/base/content/test/urlbar/head.js
browser/modules/test/browser/browser_PageActions.js
--- a/browser/base/content/test/urlbar/head.js
+++ b/browser/base/content/test/urlbar/head.js
@@ -219,31 +219,37 @@ function promiseNewSearchEngine(basename
         Assert.ok(false, "addEngine failed with error code " + errCode);
         reject();
       },
     });
   });
 }
 
 function promisePageActionPanelOpen() {
-  if (BrowserPageActions.panelNode.state == "open") {
-    return Promise.resolve();
-  }
-  // The main page action button is hidden for some URIs, so make sure it's
-  // visible before trying to click it.
   let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
                   .getInterface(Ci.nsIDOMWindowUtils);
   return BrowserTestUtils.waitForCondition(() => {
+    // Wait for the main page action button to become visible.  It's hidden for
+    // some URIs, so depending on when this is called, it may not yet be quite
+    // visible.  It's up to the caller to make sure it will be visible.
     info("Waiting for main page action button to have non-0 size");
     let bounds = dwu.getBoundsWithoutFlushing(BrowserPageActions.mainButtonNode);
     return bounds.width > 0 && bounds.height > 0;
   }).then(() => {
+    // Wait for the panel to become open, by clicking the button if necessary.
+    info("Waiting for main page action panel to be open");
+    if (BrowserPageActions.panelNode.state == "open") {
+      return Promise.resolve();
+    }
     let shownPromise = promisePageActionPanelShown();
     EventUtils.synthesizeMouseAtCenter(BrowserPageActions.mainButtonNode, {});
     return shownPromise;
+  }).then(() => {
+    // Wait for items in the panel to become visible.
+    return promisePageActionViewChildrenVisible(BrowserPageActions.mainViewNode);
   });
 }
 
 function promisePageActionPanelShown() {
   return promisePanelShown(BrowserPageActions.panelNode);
 }
 
 function promisePageActionPanelHidden() {
@@ -270,35 +276,37 @@ function promisePanelEvent(panelIDOrNode
     }
     panel.addEventListener(eventType, () => {
       executeSoon(resolve);
     }, { once: true });
   });
 }
 
 function promisePageActionViewShown() {
-  let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                  .getInterface(Ci.nsIDOMWindowUtils);
   info("promisePageActionViewShown waiting for ViewShown");
   return BrowserTestUtils.waitForEvent(BrowserPageActions.panelNode, "ViewShown").then(async event => {
     let panelViewNode = event.originalTarget;
-    // Wait for the subview to be really truly shown by making sure there's at
-    // least one child with non-zero bounds.
-    info("promisePageActionViewShown waiting for a child node to be visible");
-    await BrowserTestUtils.waitForCondition(() => {
-      let bodyNode = panelViewNode.firstChild;
-      for (let childNode of bodyNode.childNodes) {
-        let bounds = dwu.getBoundsWithoutFlushing(childNode);
-        if (bounds.width > 0 && bounds.height > 0) {
-          return true;
-        }
+    await promisePageActionViewChildrenVisible(panelViewNode);
+    return panelViewNode;
+  });
+}
+
+function promisePageActionViewChildrenVisible(panelViewNode) {
+  info("promisePageActionViewChildrenVisible waiting for a child node to be visible");
+  let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
+                  .getInterface(Ci.nsIDOMWindowUtils);
+  return BrowserTestUtils.waitForCondition(() => {
+    let bodyNode = panelViewNode.firstChild;
+    for (let childNode of bodyNode.childNodes) {
+      let bounds = dwu.getBoundsWithoutFlushing(childNode);
+      if (bounds.width > 0 && bounds.height > 0) {
+        return true;
       }
-      return false;
-    });
-    return panelViewNode;
+    }
+    return false;
   });
 }
 
 function promiseSpeculativeConnection(httpserver) {
   return BrowserTestUtils.waitForCondition(() => {
     if (httpserver) {
       return httpserver.connectionNumber == 1;
     }
--- a/browser/modules/test/browser/browser_PageActions.js
+++ b/browser/modules/test/browser/browser_PageActions.js
@@ -969,31 +969,38 @@ add_task(async function migrate1() {
   );
 
   // Done, clean up.
   await BrowserTestUtils.closeWindow(win);
   Services.prefs.clearUserPref(PageActions.PREF_PERSISTED_ACTIONS);
   PageActions.actionForID("copyURL")._shownInUrlbar = false;
 });
 
-
 function promisePageActionPanelOpen() {
-  let button = document.getElementById("pageActionButton");
-  // The main page action button is hidden for some URIs, so make sure it's
-  // visible before trying to click it.
   let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
                   .getInterface(Ci.nsIDOMWindowUtils);
   return BrowserTestUtils.waitForCondition(() => {
+    // Wait for the main page action button to become visible.  It's hidden for
+    // some URIs, so depending on when this is called, it may not yet be quite
+    // visible.  It's up to the caller to make sure it will be visible.
     info("Waiting for main page action button to have non-0 size");
-    let bounds = dwu.getBoundsWithoutFlushing(button);
+    let bounds = dwu.getBoundsWithoutFlushing(BrowserPageActions.mainButtonNode);
     return bounds.width > 0 && bounds.height > 0;
   }).then(() => {
+    // Wait for the panel to become open, by clicking the button if necessary.
+    info("Waiting for main page action panel to be open");
+    if (BrowserPageActions.panelNode.state == "open") {
+      return Promise.resolve();
+    }
     let shownPromise = promisePageActionPanelShown();
-    EventUtils.synthesizeMouseAtCenter(button, {});
+    EventUtils.synthesizeMouseAtCenter(BrowserPageActions.mainButtonNode, {});
     return shownPromise;
+  }).then(() => {
+    // Wait for items in the panel to become visible.
+    return promisePageActionViewChildrenVisible(BrowserPageActions.mainViewNode);
   });
 }
 
 function promisePageActionPanelShown() {
   return promisePanelShown(BrowserPageActions.panelNode);
 }
 
 function promisePageActionPanelHidden() {
@@ -1020,29 +1027,31 @@ function promisePanelEvent(panelIDOrNode
     }
     panel.addEventListener(eventType, () => {
       executeSoon(resolve);
     }, { once: true });
   });
 }
 
 function promisePageActionViewShown() {
-  let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
-                  .getInterface(Ci.nsIDOMWindowUtils);
   info("promisePageActionViewShown waiting for ViewShown");
   return BrowserTestUtils.waitForEvent(BrowserPageActions.panelNode, "ViewShown").then(async event => {
     let panelViewNode = event.originalTarget;
-    // Wait for the subview to be really truly shown by making sure there's at
-    // least one child with non-zero bounds.
-    info("promisePageActionViewShown waiting for a child node to be visible");
-    await BrowserTestUtils.waitForCondition(() => {
-      let bodyNode = panelViewNode.firstChild;
-      for (let childNode of bodyNode.childNodes) {
-        let bounds = dwu.getBoundsWithoutFlushing(childNode);
-        if (bounds.width > 0 && bounds.height > 0) {
-          return true;
-        }
-      }
-      return false;
-    });
+    await promisePageActionViewChildrenVisible(panelViewNode);
     return panelViewNode;
   });
 }
+
+function promisePageActionViewChildrenVisible(panelViewNode) {
+  info("promisePageActionViewChildrenVisible waiting for a child node to be visible");
+  let dwu = window.QueryInterface(Ci.nsIInterfaceRequestor)
+                  .getInterface(Ci.nsIDOMWindowUtils);
+  return BrowserTestUtils.waitForCondition(() => {
+    let bodyNode = panelViewNode.firstChild;
+    for (let childNode of bodyNode.childNodes) {
+      let bounds = dwu.getBoundsWithoutFlushing(childNode);
+      if (bounds.width > 0 && bounds.height > 0) {
+        return true;
+      }
+    }
+    return false;
+  });
+}