зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1508306 - Part 2: Fix Large-Allocation tests for new changes, r=mattwoodrow
Differential Revision: https://phabricator.services.mozilla.com/D78999
This commit is contained in:
Родитель
47c0aeb539
Коммит
9c5d47c53f
|
@ -20,16 +20,15 @@
|
|||
* Test 2 | | "upgrade-insecure-requests" | http
|
||||
*
|
||||
* Test 1:
|
||||
* We load an iframe which uses 'upgrade-insecure-requests' which then
|
||||
* opens an "http" window which uses the header "Large-Allocation".
|
||||
* We observe that the initial request as well as the "Large-Allocation"
|
||||
* request get upgraded to use "https://test1.example.com".
|
||||
* We load an iframe which uses 'upgrade-insecure-requests' which then opens an
|
||||
* "http" window which uses the header "Large-Allocation". We observe that the
|
||||
* request gets upgraded to use "https://test1.example.com".
|
||||
*
|
||||
* Test 2:
|
||||
* We load an iframe which does not use any CSP and opens an "http" window
|
||||
* which uses the header "Large-Allocation" as well as a CSP of
|
||||
* "upgrade-insecure-requests". We observe that both requests do
|
||||
* not get upgraded to https but still use "http://test2.example.com".
|
||||
* "upgrade-insecure-requests". We observe that the request does not get
|
||||
* upgraded to https but still uses "http://test2.example.com".
|
||||
*/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -38,7 +37,7 @@ let httpsCounter = 0;
|
|||
let httpCounter = 0;
|
||||
|
||||
function checkTestComplete() {
|
||||
if (httpsCounter == 2 && httpCounter == 2) {
|
||||
if (httpsCounter == 1 && httpCounter == 1) {
|
||||
ok(true, "Frame with CSP caused upgrade; Frame with no CSP caused no upgrade");
|
||||
window.URLExaminer.remove();
|
||||
SimpleTest.finish();
|
||||
|
|
|
@ -56,9 +56,9 @@ support-files =
|
|||
beforeunload_test_page.html
|
||||
run-if = e10s
|
||||
[browser_largeAllocation_win32.js]
|
||||
skip-if = fission || !e10s || os != "win" || processor != "x86" # Large-Allocation requires e10s
|
||||
skip-if = fission || !e10s || os != "win" || processor != "x86" # Large-Allocation requires non-fission e10s
|
||||
[browser_largeAllocation_non_win32.js]
|
||||
skip-if = fission || !e10s || (os == "win" && (processor == "x86" || processor == "aarch64")) || (verify && debug && (os == 'linux')) || (os == 'linux') || (os == 'mac') || (os == "win" && debug) # Large-Allocation requires e10s # Bug 1336075
|
||||
skip-if = fission || !e10s || (os == "win" && processor == "x86") # Large-Allocation requires non-fission e10s
|
||||
[browser_localStorage_e10s.js]
|
||||
fail-if = fission
|
||||
skip-if = !e10s || verify # This is a test of e10s functionality.
|
||||
|
|
|
@ -28,26 +28,14 @@ function expectProcessCreated() {
|
|||
return promise;
|
||||
}
|
||||
|
||||
function expectNoProcess() {
|
||||
let os = Services.obs;
|
||||
let topic = "ipc:content-created";
|
||||
function observer() {
|
||||
ok(false, "A process was created!");
|
||||
os.removeObserver(observer, topic);
|
||||
}
|
||||
os.addObserver(observer, topic);
|
||||
|
||||
return () => os.removeObserver(observer, topic);
|
||||
}
|
||||
|
||||
function getPID(aBrowser) {
|
||||
return ContentTask.spawn(aBrowser, [], () => {
|
||||
return SpecialPowers.spawn(aBrowser, [], () => {
|
||||
return Services.appinfo.processID;
|
||||
});
|
||||
}
|
||||
|
||||
function getInLAProc(aBrowser) {
|
||||
return ContentTask.spawn(aBrowser, [], () => {
|
||||
return SpecialPowers.spawn(aBrowser, [], () => {
|
||||
return Services.appinfo.remoteType == "webLargeAllocation";
|
||||
});
|
||||
}
|
||||
|
@ -79,13 +67,17 @@ async function largeAllocSuccessTests() {
|
|||
let pid1 = await getPID(aBrowser);
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
let epc = expectProcessCreated();
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
let ready = Promise.all([
|
||||
expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
// Wait for the new process to be created
|
||||
await epc;
|
||||
await ready;
|
||||
|
||||
let pid2 = await getPID(aBrowser);
|
||||
|
||||
|
@ -104,10 +96,7 @@ async function largeAllocSuccessTests() {
|
|||
let pid1 = await getPID(aBrowser);
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
// Fail the test if we create a process
|
||||
let stopExpectNoProcess = expectNoProcess();
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
// eslint-disable-next-line no-unsanitized/property
|
||||
content.document.body.innerHTML = `<iframe src='${TEST_URI}'></iframe>`;
|
||||
|
||||
|
@ -123,8 +112,6 @@ async function largeAllocSuccessTests() {
|
|||
|
||||
is(pid1, pid2, "The PID should not have changed");
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
stopExpectNoProcess();
|
||||
});
|
||||
|
||||
// If you have an opener cross process navigation shouldn't work
|
||||
|
@ -135,62 +122,51 @@ async function largeAllocSuccessTests() {
|
|||
let pid1 = await getPID(aBrowser);
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
// Fail the test if we create a process
|
||||
let stopExpectNoProcess = expectNoProcess();
|
||||
|
||||
let loaded = ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
info(TEST_URI);
|
||||
content.document.body.innerHTML = "<button>CLICK ME</button>";
|
||||
|
||||
return new Promise(resolve => {
|
||||
content.document.querySelector("button").onclick = e => {
|
||||
let w = content.window.open(TEST_URI, "_blank");
|
||||
w.onload = () => {
|
||||
ok(true, "Window finished loading");
|
||||
w.close();
|
||||
resolve();
|
||||
};
|
||||
let w = content.window.open(TEST_URI, "_blank");
|
||||
w.onload = () => {
|
||||
ok(true, "Window finished loading");
|
||||
w.close();
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter("button", {}, aBrowser);
|
||||
|
||||
await loaded;
|
||||
|
||||
let pid2 = await getPID(aBrowser);
|
||||
|
||||
is(pid1, pid2, "The PID should not have changed");
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
stopExpectNoProcess();
|
||||
});
|
||||
|
||||
// Load Large-Allocation twice with about:blank load in between
|
||||
// Load Large-Allocation twice with example.com load in between
|
||||
await BrowserTestUtils.withNewTab("about:blank", async function(aBrowser) {
|
||||
info("Starting test 3");
|
||||
let pid1 = await getPID(aBrowser);
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
let epc = expectProcessCreated();
|
||||
let ready = Promise.all([
|
||||
expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
await epc;
|
||||
await ready;
|
||||
|
||||
let pid2 = await getPID(aBrowser);
|
||||
|
||||
isnot(pid1, pid2);
|
||||
is(true, await getInLAProc(aBrowser));
|
||||
|
||||
await BrowserTestUtils.browserLoaded(aBrowser);
|
||||
|
||||
await ContentTask.spawn(
|
||||
aBrowser,
|
||||
[],
|
||||
() => (content.document.location = "about:blank")
|
||||
);
|
||||
await SpecialPowers.spawn(aBrowser, [], () => {
|
||||
content.document.location = "http://example.com";
|
||||
});
|
||||
|
||||
await BrowserTestUtils.browserLoaded(aBrowser);
|
||||
|
||||
|
@ -198,13 +174,16 @@ async function largeAllocSuccessTests() {
|
|||
// load, meaning we're back in a non-fresh process
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
epc = expectProcessCreated();
|
||||
ready = Promise.all([
|
||||
expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
await epc;
|
||||
await ready;
|
||||
|
||||
let pid4 = await getPID(aBrowser);
|
||||
|
||||
|
@ -213,30 +192,31 @@ async function largeAllocSuccessTests() {
|
|||
is(true, await getInLAProc(aBrowser));
|
||||
});
|
||||
|
||||
// Load Large-Allocation then about:blank load, then back button press should load from bfcache.
|
||||
// Load Large-Allocation then example.com load, then back button press should load from bfcache.
|
||||
await BrowserTestUtils.withNewTab("about:blank", async function(aBrowser) {
|
||||
info("Starting test 4");
|
||||
let pid1 = await getPID(aBrowser);
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
let epc = expectProcessCreated();
|
||||
let ready = Promise.all([
|
||||
expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
await epc;
|
||||
await ready;
|
||||
|
||||
let pid2 = await getPID(aBrowser);
|
||||
|
||||
isnot(pid1, pid2, "PIDs 1 and 2 should not match");
|
||||
is(true, await getInLAProc(aBrowser));
|
||||
|
||||
await BrowserTestUtils.browserLoaded(aBrowser);
|
||||
|
||||
// Switch to about:blank, so we can navigate back
|
||||
await ContentTask.spawn(aBrowser, [], () => {
|
||||
content.document.location = "about:blank";
|
||||
await SpecialPowers.spawn(aBrowser, [], () => {
|
||||
content.document.location = "http://example.com";
|
||||
});
|
||||
|
||||
await BrowserTestUtils.browserLoaded(aBrowser);
|
||||
|
@ -247,15 +227,18 @@ async function largeAllocSuccessTests() {
|
|||
// load, meaning we're back in a non-large-allocation process.
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
epc = expectProcessCreated();
|
||||
ready = Promise.all([
|
||||
expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
// Navigate back to the previous page. As the large alloation process was
|
||||
// left, it won't be in bfcache and will have to be loaded fresh.
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.window.history.back();
|
||||
});
|
||||
|
||||
await epc;
|
||||
await ready;
|
||||
|
||||
let pid4 = await getPID(aBrowser);
|
||||
|
||||
|
@ -276,7 +259,7 @@ async function largeAllocSuccessTests() {
|
|||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
|
@ -287,27 +270,16 @@ async function largeAllocSuccessTests() {
|
|||
isnot(pid1, pid2, "PIDs 1 and 2 should not match");
|
||||
is(true, await getInLAProc(aBrowser));
|
||||
|
||||
let epc = expectProcessCreated();
|
||||
ready = Promise.all([
|
||||
expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI_2, TEST_URI_2 => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI_2], TEST_URI_2 => {
|
||||
content.document.location = TEST_URI_2;
|
||||
});
|
||||
|
||||
await epc;
|
||||
|
||||
// We just saw the creation of a new process. This is either the process we
|
||||
// are interested in, or, in a multi-e10s situation, the normal content
|
||||
// process which was created for the normal content to be loaded into as the
|
||||
// browsing context was booted out of the fresh process. If we discover that
|
||||
// this was not a fresh process, we'll need to wait for another process.
|
||||
// Start listening now.
|
||||
epc = expectProcessCreated();
|
||||
if (!(await getInLAProc(aBrowser))) {
|
||||
await epc;
|
||||
} else {
|
||||
epc.catch(() => {});
|
||||
epc.kill();
|
||||
}
|
||||
await ready;
|
||||
|
||||
let pid3 = await getPID(aBrowser);
|
||||
|
||||
|
@ -327,7 +299,7 @@ async function largeAllocSuccessTests() {
|
|||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
|
@ -338,11 +310,13 @@ async function largeAllocSuccessTests() {
|
|||
isnot(pid1, pid2, "PIDs 1 and 2 should not match");
|
||||
is(true, await getInLAProc(aBrowser));
|
||||
|
||||
let stopExpectNoProcess = expectNoProcess();
|
||||
|
||||
await ContentTask.spawn(aBrowser, [], () => {
|
||||
this.__newWindow = content.window.open("about:blank");
|
||||
content.document.location = "about:blank";
|
||||
let promiseTabOpened = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
"about:blank"
|
||||
);
|
||||
await SpecialPowers.spawn(aBrowser, [], () => {
|
||||
content.window.open("about:blank");
|
||||
content.document.location = "http://example.com";
|
||||
});
|
||||
|
||||
await BrowserTestUtils.browserLoaded(aBrowser);
|
||||
|
@ -352,12 +326,7 @@ async function largeAllocSuccessTests() {
|
|||
is(pid3, pid2, "PIDs 2 and 3 should match");
|
||||
is(true, await getInLAProc(aBrowser));
|
||||
|
||||
stopExpectNoProcess();
|
||||
|
||||
await ContentTask.spawn(aBrowser, [], () => {
|
||||
ok(this.__newWindow, "The window should have been stored");
|
||||
this.__newWindow.close();
|
||||
});
|
||||
BrowserTestUtils.removeTab(await promiseTabOpened);
|
||||
});
|
||||
|
||||
// Opening a window from the large-allocation window should prevent the
|
||||
|
@ -372,7 +341,7 @@ async function largeAllocSuccessTests() {
|
|||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
|
@ -383,17 +352,15 @@ async function largeAllocSuccessTests() {
|
|||
isnot(pid1, pid2, "PIDs 1 and 2 should not match");
|
||||
is(true, await getInLAProc(aBrowser));
|
||||
|
||||
let stopExpectNoProcess = expectNoProcess();
|
||||
|
||||
let firstTab = gBrowser.selectedTab;
|
||||
let promiseTabOpened = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
"about:blank"
|
||||
);
|
||||
await ContentTask.spawn(aBrowser, [], () => {
|
||||
this.__newWindow = content.window.open("about:blank");
|
||||
await SpecialPowers.spawn(aBrowser, [], () => {
|
||||
content.window.open("about:blank");
|
||||
});
|
||||
await promiseTabOpened;
|
||||
let newTab = await promiseTabOpened;
|
||||
|
||||
if (firstTab != gBrowser.selectedTab) {
|
||||
firstTab = await BrowserTestUtils.switchTab(gBrowser, firstTab);
|
||||
|
@ -408,12 +375,7 @@ async function largeAllocSuccessTests() {
|
|||
is(pid3, pid2, "PIDs 2 and 3 should match");
|
||||
is(true, await getInLAProc(aBrowser));
|
||||
|
||||
stopExpectNoProcess();
|
||||
|
||||
await ContentTask.spawn(aBrowser, [], () => {
|
||||
ok(this.__newWindow, "The window should have been stored");
|
||||
this.__newWindow.close();
|
||||
});
|
||||
BrowserTestUtils.removeTab(newTab);
|
||||
});
|
||||
|
||||
// Try dragging the tab into a new window when not at the maximum number of
|
||||
|
@ -428,7 +390,7 @@ async function largeAllocSuccessTests() {
|
|||
expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
|
@ -476,7 +438,7 @@ async function largeAllocSuccessTests() {
|
|||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
|
@ -493,7 +455,7 @@ async function largeAllocSuccessTests() {
|
|||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
let ready = Promise.all([BrowserTestUtils.browserLoaded(aBrowser)]);
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
await ready;
|
||||
|
@ -514,10 +476,7 @@ async function largeAllocSuccessTests() {
|
|||
let pid1 = await getPID(aBrowser);
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
// Fail the test if we create a process
|
||||
let stopExpectNoProcess = expectNoProcess();
|
||||
|
||||
await ContentTask.spawn(aBrowser, [], () => {
|
||||
await SpecialPowers.spawn(aBrowser, [], () => {
|
||||
content.document.location = "view-source:http://example.com";
|
||||
});
|
||||
|
||||
|
@ -527,8 +486,6 @@ async function largeAllocSuccessTests() {
|
|||
|
||||
is(pid1, pid2, "The PID should not have changed");
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
stopExpectNoProcess();
|
||||
});
|
||||
|
||||
// Try dragging tab into new window when at the max number of large allocation
|
||||
|
@ -546,7 +503,7 @@ async function largeAllocSuccessTests() {
|
|||
expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
|
@ -588,7 +545,7 @@ async function largeAllocSuccessTests() {
|
|||
expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
]);
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
|
@ -600,7 +557,7 @@ async function largeAllocSuccessTests() {
|
|||
is(true, await getInLAProc(aBrowser));
|
||||
|
||||
await Promise.all([
|
||||
ContentTask.spawn(aBrowser, null, () => {
|
||||
SpecialPowers.spawn(aBrowser, [], () => {
|
||||
content.document.querySelector("#submit").click();
|
||||
}),
|
||||
BrowserTestUtils.browserLoaded(aBrowser),
|
||||
|
@ -629,10 +586,7 @@ async function largeAllocFailTests() {
|
|||
let pid1 = await getPID(aBrowser);
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
// Fail the test if we create a process
|
||||
let stopExpectNoProcess = expectNoProcess();
|
||||
|
||||
await ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
|
@ -642,7 +596,5 @@ async function largeAllocFailTests() {
|
|||
|
||||
is(pid1, pid2, "The PID should not have changed");
|
||||
is(false, await getInLAProc(aBrowser));
|
||||
|
||||
stopExpectNoProcess();
|
||||
});
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче