mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-13 20:14:57 -10:00
Backed out changeset cf766413a25e (bug 1247493) for failures in browser_ext_tabs_update.js
This commit is contained in:
1 parent
7ba6a4f575
commit
16896018ab
4 files changed
+4
-169
No files matched your search
@@ -5,8 +5,6 @@
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
|
||||
"@mozilla.org/browser/aboutnewtab-service;1",
|
||||
"nsIAboutNewTabService");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
|
||||
var {
|
||||
@@ -70,27 +68,7 @@ extensions.registerSchemaAPI("windows", null, (extension, context) => {
|
||||
}
|
||||
|
||||
let args = Cc["@mozilla.org/supports-array;1"].createInstance(Ci.nsISupportsArray);
|
||||
|
||||
if (createData.tabId !== null) {
|
||||
if (createData.url !== null) {
|
||||
return Promise.reject({message: "`tabId` may not be used in conjunction with `url`"});
|
||||
}
|
||||
|
||||
let tab = TabManager.getTab(createData.tabId);
|
||||
if (tab == null) {
|
||||
return Promise.reject({message: `Invalid tab ID: ${createData.tabId}`});
|
||||
}
|
||||
|
||||
// Private browsing tabs can only be moved to private browsing
|
||||
// windows.
|
||||
let incognito = PrivateBrowsingUtils.isBrowserPrivate(tab.linkedBrowser);
|
||||
if (createData.incognito !== null && createData.incognito != incognito) {
|
||||
return Promise.reject({message: "`incognito` property must match the incognito state of tab"});
|
||||
}
|
||||
createData.incognito = incognito;
|
||||
|
||||
args.AppendElement(tab);
|
||||
} else if (createData.url !== null) {
|
||||
if (createData.url !== null) {
|
||||
if (Array.isArray(createData.url)) {
|
||||
let array = Cc["@mozilla.org/supports-array;1"].createInstance(Ci.nsISupportsArray);
|
||||
for (let url of createData.url) {
|
||||
|
||||
@@ -38,7 +38,6 @@ support-files =
|
||||
[browser_ext_tabs_sendMessage.js]
|
||||
[browser_ext_tabs_move.js]
|
||||
[browser_ext_tabs_move_window.js]
|
||||
[browser_ext_windows_create_tabId.js]
|
||||
[browser_ext_windows_update.js]
|
||||
[browser_ext_contentscript_connect.js]
|
||||
[browser_ext_tab_runtimeConnect.js]
|
||||
|
||||
@@ -41,12 +41,11 @@ add_task(function* testTabEvents() {
|
||||
}
|
||||
|
||||
browser.test.log("Create second browser window");
|
||||
let windowId;
|
||||
Promise.all([
|
||||
browser.windows.getCurrent(),
|
||||
browser.windows.create({}),
|
||||
]).then(windows => {
|
||||
windowId = windows[0].id;
|
||||
let windowId = windows[0].id;
|
||||
let otherWindowId = windows[1].id;
|
||||
let initialTab;
|
||||
|
||||
@@ -104,43 +103,10 @@ add_task(function* testTabEvents() {
|
||||
browser.test.assertEq(initialTab.id, removed.tabId, "Expected removed tab ID");
|
||||
browser.test.assertEq(otherWindowId, removed.windowId, "Expected removed tab window ID");
|
||||
browser.test.assertEq(true, removed.isWindowClosing, "Expected isWindowClosing value");
|
||||
}).then(() => {
|
||||
browser.test.notifyPass("tabs-events");
|
||||
});
|
||||
});
|
||||
}).then(() => {
|
||||
browser.test.log("Create additional tab in window 1");
|
||||
return browser.tabs.create({windowId, url: "about:blank"});
|
||||
}).then(tab => {
|
||||
return expectEvents(["onCreated"]).then(() => {
|
||||
browser.test.log("Create a new window, adopting the new tab");
|
||||
|
||||
// We have to explicitly wait for the event here, since its timing is
|
||||
// not predictable.
|
||||
let promiseAttached = new Promise(resolve => {
|
||||
browser.tabs.onAttached.addListener(function listener(tabId) {
|
||||
browser.tabs.onAttached.removeListener(listener);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
browser.windows.create({tabId: tab.id}),
|
||||
promiseAttached,
|
||||
]);
|
||||
}).then(([window]) => {
|
||||
return expectEvents(["onDetached", "onAttached"]).then(([detached, attached]) => {
|
||||
browser.test.assertEq(tab.id, detached.tabId, "Expected onDetached tab ID");
|
||||
|
||||
browser.test.assertEq(tab.id, attached.tabId, "Expected onAttached tab ID");
|
||||
browser.test.assertEq(0, attached.newPosition, "Expected onAttached new index");
|
||||
browser.test.assertEq(window.id, attached.newWindowId,
|
||||
"Expected onAttached new window id");
|
||||
|
||||
browser.test.log("Close the new window");
|
||||
return browser.windows.remove(window.id);
|
||||
});
|
||||
});
|
||||
}).then(() => {
|
||||
browser.test.notifyPass("tabs-events");
|
||||
}).catch(e => {
|
||||
try {
|
||||
browser.test.fail(`${e} :: ${e.stack}`);
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
add_task(function* testWindowCreate() {
|
||||
function background() {
|
||||
let promiseTabAttached = () => {
|
||||
return new Promise(resolve => {
|
||||
browser.tabs.onAttached.addListener(function listener() {
|
||||
browser.tabs.onAttached.removeListener(listener);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
let windowId;
|
||||
browser.windows.getCurrent().then(window => {
|
||||
windowId = window.id;
|
||||
|
||||
browser.test.log("Create additional tab in window 1");
|
||||
return browser.tabs.create({windowId, url: "about:blank"});
|
||||
}).then(tab => {
|
||||
browser.test.log("Create a new window, adopting the new tab");
|
||||
|
||||
// Note that we want to check against actual boolean values for
|
||||
// all of the `incognito` property tests.
|
||||
browser.test.assertEq(false, tab.incognito, "Tab is not private");
|
||||
|
||||
return Promise.all([
|
||||
promiseTabAttached(),
|
||||
browser.windows.create({tabId: tab.id}),
|
||||
]);
|
||||
}).then(([, window]) => {
|
||||
browser.test.assertEq(false, window.incognito, "New window is not private");
|
||||
|
||||
browser.test.log("Close the new window");
|
||||
return browser.windows.remove(window.id);
|
||||
}).then(() => {
|
||||
browser.test.log("Create a new private window");
|
||||
|
||||
return browser.windows.create({incognito: true});
|
||||
}).then(privateWindow => {
|
||||
browser.test.assertEq(true, privateWindow.incognito, "Private window is private");
|
||||
|
||||
browser.test.log("Create additional tab in private window");
|
||||
return browser.tabs.create({windowId: privateWindow.id}).then(privateTab => {
|
||||
browser.test.assertEq(true, privateTab.incognito, "Private tab is private");
|
||||
|
||||
browser.test.log("Create a new window, adopting the new private tab");
|
||||
|
||||
return Promise.all([
|
||||
promiseTabAttached(),
|
||||
browser.windows.create({tabId: privateTab.id}),
|
||||
]);
|
||||
}).then(([, newWindow]) => {
|
||||
browser.test.assertEq(true, newWindow.incognito, "New private window is private");
|
||||
|
||||
browser.test.log("Close the new private window");
|
||||
return browser.windows.remove(newWindow.id);
|
||||
}).then(() => {
|
||||
browser.test.log("Close the private window");
|
||||
return browser.windows.remove(privateWindow.id);
|
||||
});
|
||||
}).then(() => {
|
||||
return browser.tabs.query({windowId, active: true});
|
||||
}).then(([tab]) => {
|
||||
browser.test.log("Try to create a window with both a tab and a URL");
|
||||
|
||||
return browser.windows.create({tabId: tab.id, url: "http://example.com/"}).then(
|
||||
window => {
|
||||
browser.test.fail("Create call should have failed");
|
||||
},
|
||||
error => {
|
||||
browser.test.assertTrue(/`tabId` may not be used in conjunction with `url`/.test(error.message),
|
||||
"Create call failed as expected");
|
||||
}).then(() => {
|
||||
browser.test.log("Try to create a window with both a tab and an invalid incognito setting");
|
||||
|
||||
return browser.windows.create({tabId: tab.id, incognito: true});
|
||||
}).then(
|
||||
window => {
|
||||
browser.test.fail("Create call should have failed");
|
||||
},
|
||||
error => {
|
||||
browser.test.assertTrue(/`incognito` property must match the incognito state of tab/.test(error.message),
|
||||
"Create call failed as expected");
|
||||
});
|
||||
}).then(() => {
|
||||
browser.test.notifyPass("window-create");
|
||||
}).catch(e => {
|
||||
browser.test.fail(`${e} :: ${e.stack}`);
|
||||
browser.test.notifyFail("window-create");
|
||||
});
|
||||
}
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["tabs"],
|
||||
},
|
||||
|
||||
background,
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
yield extension.awaitFinish("window-create");
|
||||
yield extension.unload();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user