Backed out 3 changesets (bug 1403349) for test-oop-extensions/browser_ext_webNavigation_onCreatedNavigationTarget_window_open.js | This test exceeded the timeout threshold

Backed out changeset 6c50dc08aa42 (bug 1403349)
Backed out changeset 5dbe3db9affc (bug 1403349)
Backed out changeset 0039b4539113 (bug 1403349)

MozReview-Commit-ID: 2jlfAoj8SPn
This commit is contained in:
Phil Ringnalda 2017-10-12 18:57:33 -07:00
Родитель b39b9e95d4
Коммит 802759e321
3 изменённых файлов: 23 добавлений и 211 удалений

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

@ -58,17 +58,7 @@ async function runTestCase({extension, openNavTarget, expectedWebNavProps}) {
is(completedNavMsg.url, url, "Got the expected webNavigation.onCompleted url property");
}
// Test that there are no pending createdNavigationTarget messages still tracked
// in WebNavigation.jsm (to be called before the extension is unloaded, because
// once the last extension which have subscribed a webNavigation event is unloaded
// all the pending created navigation target data is completely cleared).
function assertNoPendingCreatedNavigationTargetData() {
const {Manager} = Cu.import("resource://gre/modules/WebNavigation.jsm", {});
Assert.equal(Manager.createdNavigationTargetByOuterWindowId.size, 0,
"There should be no pending createdNavigationTarget messages in WebNavigation");
}
add_task(async function test_window_open() {
add_task(async function test_on_created_navigation_target_from_window_open() {
const tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
gBrowser.selectedTab = tab1;
@ -84,7 +74,7 @@ add_task(async function test_window_open() {
const expectedSourceTab = await extension.awaitMessage("expectedSourceTab");
info("open a url in a new tab from a window.open call");
info("open an url in a new tab from a window.open call");
await runTestCase({
extension,
@ -101,7 +91,7 @@ add_task(async function test_window_open() {
},
});
info("open a url in a new window from a window.open call");
info("open an url in a new window from a window.open call");
await runTestCase({
extension,
@ -118,14 +108,12 @@ add_task(async function test_window_open() {
},
});
assertNoPendingCreatedNavigationTargetData();
await BrowserTestUtils.removeTab(tab1);
await extension.unload();
});
add_task(async function test_window_open_from_subframe() {
add_task(async function test_on_created_navigation_target_from_window_open_subframe() {
const tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
gBrowser.selectedTab = tab1;
@ -141,7 +129,7 @@ add_task(async function test_window_open_from_subframe() {
const expectedSourceTab = await extension.awaitMessage("expectedSourceTab");
info("open a url in a new tab from subframe window.open call");
info("open an url in a new tab from subframe window.open call");
await runTestCase({
extension,
@ -158,7 +146,7 @@ add_task(async function test_window_open_from_subframe() {
},
});
info("open a url in a new window from subframe window.open call");
info("open an url in a new window from subframe window.open call");
await runTestCase({
extension,
@ -175,131 +163,6 @@ add_task(async function test_window_open_from_subframe() {
},
});
assertNoPendingCreatedNavigationTargetData();
await BrowserTestUtils.removeTab(tab1);
await extension.unload();
});
add_task(async function test_window_open_close_from_browserAction_popup() {
const tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
gBrowser.selectedTab = tab1;
function popup() {
window.open("", "_self").close();
browser.test.sendMessage("browserAction_popup_executed");
}
const extension = ExtensionTestUtils.loadExtension({
background,
manifest: {
browser_action: {
default_popup: "popup.html",
},
permissions: ["webNavigation", "tabs", "<all_urls>"],
},
files: {
"popup.html": `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="popup.js"></script>
</body>
</html>
`,
"popup.js": popup,
},
});
await extension.startup();
const expectedSourceTab = await extension.awaitMessage("expectedSourceTab");
clickBrowserAction(extension);
await extension.awaitMessage("browserAction_popup_executed");
info("open a url in a new tab from a window.open call");
await runTestCase({
extension,
openNavTarget() {
extension.sendMessage({
type: "execute-contentscript",
code: `window.open("${OPENED_PAGE}#new-tab-from-window-open"); true;`,
});
},
expectedWebNavProps: {
sourceTabId: expectedSourceTab.sourceTabId,
sourceFrameId: 0,
url: `${OPENED_PAGE}#new-tab-from-window-open`,
},
});
assertNoPendingCreatedNavigationTargetData();
await BrowserTestUtils.removeTab(tab1);
await extension.unload();
});
add_task(async function test_window_open_in_named_win() {
const tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, SOURCE_PAGE);
gBrowser.selectedTab = tab1;
const extension = ExtensionTestUtils.loadExtension({
background,
manifest: {
permissions: ["webNavigation", "tabs", "<all_urls>"],
},
});
await extension.startup();
const expectedSourceTab = await extension.awaitMessage("expectedSourceTab");
info("open a url in a new named window from a window.open call");
await runTestCase({
extension,
openNavTarget() {
extension.sendMessage({
type: "execute-contentscript",
code: `window.open("${OPENED_PAGE}#new-named-window-open", "TestWinName"); true;`,
});
},
expectedWebNavProps: {
sourceTabId: expectedSourceTab.sourceTabId,
sourceFrameId: 0,
url: `${OPENED_PAGE}#new-named-window-open`,
},
});
info("open a url in an existent named window from a window.open call");
await runTestCase({
extension,
openNavTarget() {
extension.sendMessage({
type: "execute-contentscript",
code: `window.open("${OPENED_PAGE}#existent-named-window-open", "TestWinName"); true;`,
});
},
expectedWebNavProps: {
sourceTabId: expectedSourceTab.sourceTabId,
sourceFrameId: 0,
url: `${OPENED_PAGE}#existent-named-window-open`,
},
});
assertNoPendingCreatedNavigationTargetData();
await BrowserTestUtils.removeTab(tab1);
await extension.unload();

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

@ -306,68 +306,29 @@ var Manager = {
},
onCreatedNavigationTarget(browser, data) {
const {
createdOuterWindowId,
isSourceTab,
sourceFrameId,
url,
} = data;
const {isSourceTab, createdWindowId, sourceFrameId, url} = data;
// We are going to receive two message manager messages for a single
// onCreatedNavigationTarget event related to a window.open that is happening
// in the child process (one from the source tab and one from the created tab),
// the unique createdWindowId (the outerWindowID of the created docShell)
// to pair them together.
const pairedMessage = this.createdNavigationTargetByOuterWindowId.get(createdOuterWindowId);
if (!isSourceTab) {
if (pairedMessage) {
// This should not happen, print a warning before overwriting the unexpected pending data.
Services.console.logStringMessage(
`Discarding onCreatedNavigationTarget for ${createdOuterWindowId}: ` +
"unexpected pending data while receiving the created tab data"
);
}
// Store a weak reference to the browser XUL element, so that we don't prevent
// it to be garbage collected if it has been destroyed.
const browserWeakRef = Cu.getWeakReference(browser);
this.createdNavigationTargetByOuterWindowId.set(createdOuterWindowId, {
browserWeakRef,
data,
});
return;
}
// We are going to potentially received two message manager messages for a single
// onCreatedNavigationTarget event that is happening in the child process,
// we are going to use the generate uuid to pair them together.
const pairedMessage = this.createdNavigationTargetByOuterWindowId.get(createdWindowId);
if (!pairedMessage) {
// The sourceTab should always be received after the message coming from the created
// top level frame because the "webNavigation-createdNavigationTarget-from-js" observers
// subscribed by WebNavigationContent.js are going to be executed in reverse order
// (See http://searchfox.org/mozilla-central/rev/f54c1723be/xpcom/ds/nsObserverList.cpp#76)
// and the observer subscribed to the created target will be the last one subscribed
// to the ObserverService (and the first one to be triggered).
Services.console.logStringMessage(
`Discarding onCreatedNavigationTarget for ${createdOuterWindowId}: ` +
"received source tab data without any created tab data available"
);
this.createdNavigationTargetByOuterWindowId.set(createdWindowId, {browser, data});
return;
}
this.createdNavigationTargetByOuterWindowId.delete(createdOuterWindowId);
this.createdNavigationTargetByOuterWindowId.delete(createdWindowId);
let sourceTabBrowser = browser;
let createdTabBrowser = pairedMessage.browserWeakRef.get();
let sourceTabBrowser;
let createdTabBrowser;
if (!createdTabBrowser) {
Services.console.logStringMessage(
`Discarding onCreatedNavigationTarget for ${createdOuterWindowId}: ` +
"the created tab has been already destroyed"
);
return;
if (isSourceTab) {
sourceTabBrowser = browser;
createdTabBrowser = pairedMessage.browser;
} else {
sourceTabBrowser = pairedMessage.browser;
createdTabBrowser = browser;
}
this.fire("onCreatedNavigationTarget", createdTabBrowser, {}, {

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

@ -10,17 +10,6 @@ Components.utils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "WebNavigationFrames",
"resource://gre/modules/WebNavigationFrames.jsm");
function getDocShellOuterWindowId(docShell) {
if (!docShell) {
return undefined;
}
return docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow)
.getInterface(Ci.nsIDOMWindowUtils)
.outerWindowID;
}
function loadListener(event) {
let document = event.target;
let window = document.defaultView;
@ -67,9 +56,8 @@ var CreatedNavigationTargetListener = {
}
const isSourceTab = docShell === sourceDocShell || isSourceTabDescendant;
const sourceFrameId = WebNavigationFrames.getDocShellFrameId(sourceDocShell);
const createdOuterWindowId = getDocShellOuterWindowId(sourceDocShell);
const createdWindowId = WebNavigationFrames.getDocShellFrameId(createdDocShell);
let url;
if (props.hasKey("url")) {
@ -79,7 +67,7 @@ var CreatedNavigationTargetListener = {
sendAsyncMessage("Extension:CreatedNavigationTarget", {
url,
sourceFrameId,
createdOuterWindowId,
createdWindowId,
isSourceTab,
});
},