Bug 1307347 - Get rid of duplicated loadTab/removeTab code in webconsole tests. r=jmaher

This commit is contained in:
Patrick Brosset 2017-02-17 14:28:19 +01:00
Родитель d372a2bf32
Коммит cad940883f
2 изменённых файлов: 7 добавлений и 22 удалений

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

@ -112,6 +112,7 @@ registerCleanupFunction(function* cleanup() {
* - {Boolean} background If true, open the tab in background
* - {ChromeWindow} window Firefox top level window we should use to open the tab
* - {Number} userContextId The userContextId of the tab.
* - {String} preferredRemoteType
* @return a promise that resolves to the tab object when the url is loaded
*/
var addTab = Task.async(function* (url, options = { background: false, window: window }) {
@ -121,7 +122,8 @@ var addTab = Task.async(function* (url, options = { background: false, window: w
let { gBrowser } = options.window ? options.window : window;
let { userContextId } = options;
let tab = gBrowser.addTab(url, {userContextId});
let tab = gBrowser.addTab(url,
{userContextId, preferredRemoteType: options.preferredRemoteType});
if (!background) {
gBrowser.selectedTab = tab;
}

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

@ -47,16 +47,9 @@ const DOCS_GA_PARAMS = "?utm_source=mozilla" +
flags.testing = true;
function loadTab(url, preferredRemoteType) {
let deferred = promise.defer();
let tab = gBrowser.selectedTab = gBrowser.addTab(url, { preferredRemoteType });
let browser = gBrowser.getBrowserForTab(tab);
browser.addEventListener("load", function () {
deferred.resolve({tab: tab, browser: browser});
}, {capture: true, once: true});
return deferred.promise;
return addTab(url, { preferredRemoteType }).then( tab => {
return { tab, browser: tab.linkedBrowser };
});
}
function loadBrowser(browser) {
@ -64,17 +57,7 @@ function loadBrowser(browser) {
}
function closeTab(tab) {
let deferred = promise.defer();
let container = gBrowser.tabContainer;
container.addEventListener("TabClose", function () {
deferred.resolve(null);
}, {capture: true, once: true});
gBrowser.removeTab(tab);
return deferred.promise;
return removeTab(tab);
}
/**