Bug 1385882 - Intermittent browser/base/content/test/urlbar/browser_page_action_menu.js | Test timed out. r=Gijs

MozReview-Commit-ID: 8uzQAPQEldP

--HG--
extra : rebase_source : 3f7723da3e0b52abb6edcd4e571b37bed8ab965d
This commit is contained in:
Drew Willcoxon 2017-10-02 10:55:00 -07:00
parent afef2bdd01
commit b852f82f5a
2 changed files with 58 additions and 41 deletions

View File

@ -224,21 +224,27 @@ function promiseNewSearchEngine(basename) {
}
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);
});
}
@ -275,28 +281,30 @@ function promisePanelEvent(panelIDOrNode, eventType) {
}
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;
});
}
function promiseSpeculativeConnection(httpserver) {
return BrowserTestUtils.waitForCondition(() => {
if (httpserver) {

View File

@ -974,21 +974,28 @@ add_task(async function migrate1() {
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);
});
}
@ -1025,24 +1032,26 @@ function promisePanelEvent(panelIDOrNode, eventType) {
}
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;
});
}