Bug 1345990 - Switch to an options object for BTU.openNewForegroundTab. r=mconley

MozReview-Commit-ID: HkFXpiWICge

--HG--
extra : rebase_source : f7739afebaa74976b4ce5100bde29cbcd33c9526
This commit is contained in:
Blake Kaplan 2017-04-26 17:08:32 -07:00
Родитель b299a459d1
Коммит a7595ea509
1 изменённых файлов: 34 добавлений и 2 удалений

Просмотреть файл

@ -96,7 +96,7 @@ this.BrowserTestUtils = {
* *
* @param {tabbrowser} tabbrowser * @param {tabbrowser} tabbrowser
* The tabbrowser to open the tab new in. * The tabbrowser to open the tab new in.
* @param {string} opening * @param {string} opening (or url)
* May be either a string URL to load in the tab, or a function that * 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". * will be called to open a foreground tab. Defaults to "about:blank".
* @param {boolean} waitForLoad * @param {boolean} waitForLoad
@ -104,12 +104,44 @@ this.BrowserTestUtils = {
* @param {boolean} waitForStateStop * @param {boolean} waitForStateStop
* True to wait for the web progress listener to send STATE_STOP for the * True to wait for the web progress listener to send STATE_STOP for the
* document in the tab. Defaults to false. * document in the tab. Defaults to false.
* @param {boolean} forceNewProcess
* True to force the new tab to load in a new process. Defaults to
* false.
* NB: tabbrowser may be an options object containing the rest of the
* parameters.
* *
* @return {Promise} * @return {Promise}
* Resolves when the tab is ready and loaded as necessary. * Resolves when the tab is ready and loaded as necessary.
* @resolves The new tab. * @resolves The new tab.
*/ */
openNewForegroundTab(tabbrowser, opening = "about:blank", aWaitForLoad = true, aWaitForStateStop = false) { openNewForegroundTab(tabbrowser, ...args) {
let options;
if (tabbrowser instanceof Ci.nsIDOMXULElement) {
// tabbrowser is a tabbrowser, read the rest of the arguments from args.
let [
opening = "about:blank",
waitForLoad = true,
waitForStateStop = false,
] = args;
options = { opening, waitForLoad, waitForStateStop };
} else {
if ("url" in tabbrowser && !("opening" in tabbrowser)) {
tabbrowser.opening = tabbrowser.url;
}
let {
opening = "about:blank",
waitForLoad = true,
waitForStateStop = false,
} = tabbrowser;
tabbrowser = tabbrowser.gBrowser;
options = { opening, waitForLoad, waitForStateStop };
}
let { opening: opening, waitForLoad: aWaitForLoad, waitForStateStop: aWaitForStateStop } = options;
let tab; let tab;
let promises = [ let promises = [
BrowserTestUtils.switchTab(tabbrowser, function () { BrowserTestUtils.switchTab(tabbrowser, function () {