Skip to content

Commit

Permalink
Bug 1541389 - Fix browser_httpCrossOriginOpenerPolicy.js to remove ti…
Browse files Browse the repository at this point in the history
…meouts and not wait for SSTabRestored r=mattwoodrow

(Matt Woodrow (:mattwoodrow) in bug 1541389 comment #7)
> Nika did some work on top of DocumentChannel to make sure we delay
notifying the old docshell that it had been cancelled until we'd setup
the new one.

This patch removes the code that waits for the `SSTabRestored` event when a
process switch is expected.
It also removes the `setTimeout` in the test, and uses
`browser.frameLoader.remoteTab.osPid` instead of ContentTask.spawn to get the
PID of the content process.

Differential Revision: https://phabricator.services.mozilla.com/D54774

--HG--
extra : moz-landing-system : lando
  • Loading branch information
valenting committed Nov 26, 2019
1 parent f8447ef commit 164b071
Showing 1 changed file with 11 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";

const { E10SUtils } = ChromeUtils.import(
Expand Down Expand Up @@ -54,7 +53,6 @@ async function test_coop(
async function(_browser) {
info(`test_coop: Test tab ready: ${start}`);

await new Promise(resolve => setTimeout(resolve, 20));
let browser = gBrowser.selectedBrowser;
let firstRemoteType = browser.remoteType;
let firstProcessID = browser.frameLoader.remoteTab.osPid;
Expand All @@ -73,19 +71,10 @@ async function test_coop(
url: target,
maybeErrorPage: false,
},
async () => {
BrowserTestUtils.loadURI(browser, target);
if (expectedProcessSwitch) {
await BrowserTestUtils.waitForEvent(
gBrowser.getTabForBrowser(browser),
"SSTabRestored"
);
}
}
async () => BrowserTestUtils.loadURI(browser, target)
);

info(`Navigated to: ${target}`);
await new Promise(resolve => setTimeout(resolve, 20));
browser = gBrowser.selectedBrowser;
let secondRemoteType = browser.remoteType;
let secondProcessID = browser.frameLoader.remoteTab.osPid;
Expand Down Expand Up @@ -156,23 +145,12 @@ async function test_download_from(initCoop, downloadCoop) {
maybeErrorPage: false,
},
async () => {
BrowserTestUtils.loadURI(_browser, start);
info(`test_download: Loading download page ${start}`);

// Wait for process switch even the page is load from a new tab.
if (initCoop != "") {
await BrowserTestUtils.waitForEvent(
gBrowser.getTabForBrowser(_browser),
"SSTabRestored"
);
}
return BrowserTestUtils.loadURI(_browser, start);
}
);

info(`test_download: Download page ready ${start}`);

await new Promise(resolve => setTimeout(resolve, 20));

info(`Downloading ${downloadCoop}`);

let winPromise = waitForDownloadWindow();
Expand All @@ -199,10 +177,7 @@ add_task(async function test_multiple_nav_process_switches() {
waitForStateStop: true,
},
async function(browser) {
await new Promise(resolve => setTimeout(resolve, 20));
let prevPID = await ContentTask.spawn(browser, null, () => {
return Services.appinfo.processID;
});
let prevPID = browser.frameLoader.remoteTab.osPid;

let target = httpURL("coop_header.sjs?.", "https://example.org");
await performLoad(
Expand All @@ -211,14 +186,10 @@ add_task(async function test_multiple_nav_process_switches() {
url: target,
maybeErrorPage: false,
},
async () => {
BrowserTestUtils.loadURI(browser, target);
}
async () => BrowserTestUtils.loadURI(browser, target)
);

let currentPID = await ContentTask.spawn(browser, null, () => {
return Services.appinfo.processID;
});
let currentPID = browser.frameLoader.remoteTab.osPid;

Assert.equal(prevPID, currentPID);
prevPID = currentPID;
Expand All @@ -233,19 +204,10 @@ add_task(async function test_multiple_nav_process_switches() {
url: target,
maybeErrorPage: false,
},
async () => {
BrowserTestUtils.loadURI(browser, target);
await BrowserTestUtils.waitForEvent(
gBrowser.getTabForBrowser(browser),
"SSTabRestored"
);
}
async () => BrowserTestUtils.loadURI(browser, target)
);

await new Promise(resolve => setTimeout(resolve, 20));
currentPID = await ContentTask.spawn(browser, null, () => {
return Services.appinfo.processID;
});
currentPID = browser.frameLoader.remoteTab.osPid;

Assert.notEqual(prevPID, currentPID);
prevPID = currentPID;
Expand All @@ -260,19 +222,10 @@ add_task(async function test_multiple_nav_process_switches() {
url: target,
maybeErrorPage: false,
},
async () => {
BrowserTestUtils.loadURI(browser, target);
await BrowserTestUtils.waitForEvent(
gBrowser.getTabForBrowser(browser),
"SSTabRestored"
);
}
async () => BrowserTestUtils.loadURI(browser, target)
);

await new Promise(resolve => setTimeout(resolve, 20));
currentPID = await ContentTask.spawn(browser, null, () => {
return Services.appinfo.processID;
});
currentPID = browser.frameLoader.remoteTab.osPid;

Assert.notEqual(prevPID, currentPID);
prevPID = currentPID;
Expand All @@ -287,15 +240,10 @@ add_task(async function test_multiple_nav_process_switches() {
url: target,
maybeErrorPage: false,
},
async () => {
BrowserTestUtils.loadURI(browser, target);
}
async () => BrowserTestUtils.loadURI(browser, target)
);

await new Promise(resolve => setTimeout(resolve, 20));
currentPID = await ContentTask.spawn(browser, null, () => {
return Services.appinfo.processID;
});
currentPID = browser.frameLoader.remoteTab.osPid;

Assert.equal(prevPID, currentPID);
prevPID = currentPID;
Expand Down

0 comments on commit 164b071

Please sign in to comment.