Bug 1206133 - Fix browser chrome mochitests broken by the popuppositioned patch. r=enn

--HG--
extra : rebase_source : d2aa631217a36a67a1becc3e65a6d8c81e079860
This commit is contained in:
Kirk Steuber 2016-06-22 13:41:44 -07:00
parent a40373dd0a
commit b20fbb66ac
6 changed files with 52 additions and 9 deletions

View File

@ -41,7 +41,11 @@ add_task(function* shift_left_click_test() {
// Wait for the initial browser to load.
let browser = win.gBrowser.selectedBrowser;
yield BrowserTestUtils.browserLoaded(browser);
let destinationURL = "http://" + TEST_VALUE + "/";
yield Promise.all([
BrowserTestUtils.browserLoaded(browser),
BrowserTestUtils.waitForLocationChange(win.gBrowser, destinationURL)
]);
info("URL should be loaded in a new window");
is(gURLBar.value, "", "Urlbar reverted to original value");

View File

@ -45,12 +45,15 @@ add_task(function* testAddOnBeforeCreatedWidget() {
try {
widgetNode.click();
let tempPanel = document.getElementById("customizationui-widget-panel");
let panelShownPromise = promisePanelElementShown(window, tempPanel);
let shownTimeout = setTimeout(() => viewShownDeferred.reject("Panel not shown within 20s"), 20000);
yield viewShownDeferred.promise;
yield panelShownPromise;
clearTimeout(shownTimeout);
ok(true, "Found view shown");
let tempPanel = document.getElementById("customizationui-widget-panel");
let panelHiddenPromise = promisePanelElementHidden(window, tempPanel);
tempPanel.hidePopup();
yield panelHiddenPromise;

View File

@ -82,9 +82,11 @@ var showSidebarPopup = Task.async(function*() {
let button = document.getElementById("sidebar-button");
let subview = document.getElementById("PanelUI-sidebar");
let popupShownPromise = BrowserTestUtils.waitForEvent(document, "popupshown");
let subviewShownPromise = subviewShown(subview);
EventUtils.synthesizeMouseAtCenter(button, {});
return subviewShownPromise;
return Promise.all([subviewShownPromise, popupShownPromise]);
});
// Check the sidebar widget shows the default items

View File

@ -297,6 +297,34 @@ this.BrowserTestUtils = {
});
},
/**
* Waits for onLocationChange.
*
* @param {tabbrowser} tabbrowser
* The tabbrowser to wait for the location change on.
* @param {string} url
* The string URL to look for. The URL must match the URL in the
* location bar exactly.
* @return {Promise}
* @resolves When onLocationChange fires.
*/
waitForLocationChange(tabbrowser, url) {
return new Promise((resolve, reject) => {
let progressListener = {
onLocationChange(aBrowser) {
if ((url && aBrowser.currentURI.spec != url) ||
(!url && aBrowser.currentURI.spec == "about:blank")) {
return;
}
tabbrowser.removeTabsProgressListener(progressListener);
resolve();
},
};
tabbrowser.addTabsProgressListener(progressListener);
});
},
/**
* Waits for the next browser window to open and be fully loaded.
*

View File

@ -38,7 +38,8 @@ add_task(function* test_fill() {
yield promiseAnchorShown;
let promiseShown = BrowserTestUtils.waitForEvent(PopupNotifications.panel,
"Shown");
"popupshown");
anchor.click();
yield promiseShown;
@ -47,9 +48,14 @@ add_task(function* test_fill() {
"list.childNodes.length === 1");
// The button will be focused after the "transitionend" event.
list.focus();
yield new Promise(resolve => executeSoon(resolve));
let details = document.getElementById("login-fill-details");
let promiseListFocus = BrowserTestUtils.waitForEvent(list, "focus");
let promiseSubviewHidden = BrowserTestUtils.waitForEvent(details,
"transitionend",
true,
e => e.target == details);
list.focus();
yield Promise.all([promiseListFocus, promiseSubviewHidden]);
let promiseSubview = BrowserTestUtils.waitForEvent(details,
"transitionend", true,
e => e.target == details);

View File

@ -162,7 +162,7 @@ add_task(function* test_edit_username() {
// Modify the username in the dialog if requested.
if (testCase.usernameChangedTo) {
notificationElement.querySelector("#password-notification-username")
.setAttribute("value", testCase.usernameChangedTo);
.value = testCase.usernameChangedTo;
}
// We expect a modifyLogin notification if the final username used by the
@ -288,13 +288,13 @@ add_task(function* test_edit_password() {
// Modify the username in the dialog if requested.
if (testCase.usernameChangedTo) {
notificationElement.querySelector("#password-notification-username")
.setAttribute("value", testCase.usernameChangedTo);
.value = testCase.usernameChangedTo;
}
// Modify the password in the dialog if requested.
if (testCase.passwordChangedTo) {
notificationElement.querySelector("#password-notification-password")
.setAttribute("value", testCase.passwordChangedTo);
.value = testCase.passwordChangedTo;
}
// We expect a modifyLogin notification if the final username used by the