author | Gijs Kruitbosch <gijskruitbosch@gmail.com> |
Fri, 26 Feb 2016 21:26:43 +0000 | |
changeset 285785 | 7ac5c16b31f48e5449e346e93dd8dcd217634f14 |
parent 285784 | decc59e7a6d33bf289ecf4369250fca73cdb69cb |
child 285786 | 1ee2382828fb99eec75ba40d6521f60ea9ed56a1 |
push id | 30035 |
push user | cbook@mozilla.com |
push date | Mon, 29 Feb 2016 10:16:00 +0000 |
treeherder | mozilla-central@4972f77869de [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mconley |
bugs | 1088710 |
milestone | 47.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
|
--- a/browser/components/customizableui/test/browser_967000_button_charEncoding.js +++ b/browser/components/customizableui/test/browser_967000_button_charEncoding.js @@ -20,17 +20,17 @@ add_task(function*() { ok(charEncodingButton, "The Character Encoding button was added to the Panel Menu"); is(charEncodingButton.getAttribute("disabled"), "true", "The Character encoding button is initially disabled"); let panelHidePromise = promisePanelHidden(window); PanelUI.hide(); yield panelHidePromise; - let newTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE, true); + let newTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE, true, true); yield PanelUI.show(); ok(!charEncodingButton.hasAttribute("disabled"), "The Character encoding button gets enabled"); let characterEncodingView = document.getElementById("PanelUI-characterEncodingView"); let subviewShownPromise = subviewShown(characterEncodingView); charEncodingButton.click(); yield subviewShownPromise;
--- a/browser/components/customizableui/test/browser_987640_charEncoding.js +++ b/browser/components/customizableui/test/browser_987640_charEncoding.js @@ -8,17 +8,17 @@ const TEST_PAGE = "http://mochi.test:888 add_task(function*() { info("Check Character Encoding panel functionality"); // add the Character Encoding button to the panel CustomizableUI.addWidgetToArea("characterencoding-button", CustomizableUI.AREA_PANEL); - let newTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE, true); + let newTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE, true, true); yield PanelUI.show(); let charEncodingButton = document.getElementById("characterencoding-button"); let characterEncodingView = document.getElementById("PanelUI-characterEncodingView"); let subviewShownPromise = subviewShown(characterEncodingView); charEncodingButton.click(); yield subviewShownPromise;
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -73,38 +73,44 @@ this.BrowserTestUtils = { * * @param {tabbrowser} tabbrowser * The tabbrowser to open the tab new in. * @param {string} opening * May be either a string URL to load in the tab, or a function that * will be called to open a foreground tab. Defaults to "about:blank". * @param {boolean} waitForLoad * True to wait for the page in the new tab to load. Defaults to true. + * @param {boolean} waitForStateStop + * True to wait for the web progress listener to send STATE_STOP for the + * document in the tab. Defaults to false. * * @return {Promise} * Resolves when the tab is ready and loaded as necessary. * @resolves The new tab. */ - openNewForegroundTab(tabbrowser, opening = "about:blank", aWaitForLoad = true) { + openNewForegroundTab(tabbrowser, opening = "about:blank", aWaitForLoad = true, aWaitForStateStop = false) { let tab; let promises = [ BrowserTestUtils.switchTab(tabbrowser, function () { if (typeof opening == "function") { opening(); tab = tabbrowser.selectedTab; } else { tabbrowser.selectedTab = tab = tabbrowser.addTab(opening); } }) ]; if (aWaitForLoad) { promises.push(BrowserTestUtils.browserLoaded(tab.linkedBrowser)); } + if (aWaitForStateStop) { + promises.push(BrowserTestUtils.browserStopped(tab.linkedBrowser)); + } return Promise.all(promises).then(() => tab); }, /** * Switches to a tab and resolves when it is ready. * * @param {tabbrowser} tabbrowser @@ -174,16 +180,52 @@ this.BrowserTestUtils = { mm.removeMessageListener("browser-test-utils:loadEvent", onLoad); resolve(msg.data.url); } }); }); }, /** + * Waits for the web progress listener associated with this tab to fire a + * STATE_STOP for the toplevel document. + * + * @param {xul:browser} browser + * A xul:browser. + * + * @return {Promise} + * @resolves When STATE_STOP reaches the tab's progress listener + */ + browserStopped(browser) { + return new Promise(resolve => { + let wpl = { + onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { + if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP && + aWebProgress.isTopLevel) { + browser.webProgress.removeProgressListener(filter); + filter.removeProgressListener(wpl); + resolve(); + }; + }, + onSecurityChange() {}, + onStatusChange() {}, + onLocationChange() {}, + QueryInterface: XPCOMUtils.generateQI([ + Ci.nsIWebProgressListener, + Ci.nsIWebProgressListener2, + ]), + }; + const filter = Cc["@mozilla.org/appshell/component/browser-status-filter;1"] + .createInstance(Ci.nsIWebProgress); + filter.addProgressListener(wpl, Ci.nsIWebProgress.NOTIFY_ALL); + browser.webProgress.addProgressListener(filter, Ci.nsIWebProgress.NOTIFY_ALL); + }); + }, + + /** * Waits for the next tab to open and load a given URL. * * The method doesn't wait for the tab contents to load. * * @param {tabbrowser} tabbrowser * The tabbrowser to look for the next new tab in. * @param {string} url * A string URL to look for in the new tab. If null, allows any non-blank URL.