mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1329331 - Add tests for not leaving the Large-Allocation process when there are other toplevel windows, r=smaug
MozReview-Commit-ID: JVM8SxleFe8 --HG-- rename : dom/tests/browser/test_largeAllocation.html => dom/tests/browser/test_largeAllocation2.html
This commit is contained in:
parent
3a272149c6
commit
32925494c4
@ -10,6 +10,8 @@ support-files =
|
||||
dummy.html
|
||||
test_largeAllocation.html
|
||||
test_largeAllocation.html^headers^
|
||||
test_largeAllocation2.html
|
||||
test_largeAllocation2.html^headers^
|
||||
!/dom/tests/mochitest/geolocation/network_geolocation.sjs
|
||||
|
||||
[browser_allocateGigabyte.js]
|
||||
|
@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const TEST_URI = "http://example.com/browser/dom/tests/browser/test_largeAllocation.html";
|
||||
const TEST_URI_2 = "http://example.com/browser/dom/tests/browser/test_largeAllocation2.html";
|
||||
|
||||
function expectProcessCreated() {
|
||||
let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
@ -44,12 +45,15 @@ add_task(function*() {
|
||||
yield SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.largeAllocationHeader.enabled", true],
|
||||
// Increase processCount.webLargeAllocation to avoid any races where
|
||||
// processes aren't being cleaned up quickly enough.
|
||||
["dom.ipc.processCount.webLargeAllocation", 20]
|
||||
]
|
||||
});
|
||||
|
||||
// A toplevel tab should be able to navigate cross process!
|
||||
yield BrowserTestUtils.withNewTab("about:blank", function*(aBrowser) {
|
||||
ok(true, "Starting test 0");
|
||||
info("Starting test 0");
|
||||
let pid1 = yield getPID(aBrowser);
|
||||
|
||||
let epc = expectProcessCreated();
|
||||
@ -68,7 +72,7 @@ add_task(function*() {
|
||||
// When a Large-Allocation document is loaded in an iframe, the header should
|
||||
// be ignored, and the tab should stay in the current process.
|
||||
yield BrowserTestUtils.withNewTab("about:blank", function*(aBrowser) {
|
||||
ok(true, "Starting test 1");
|
||||
info("Starting test 1");
|
||||
let pid1 = yield getPID(aBrowser);
|
||||
|
||||
// Fail the test if we create a process
|
||||
@ -94,7 +98,7 @@ add_task(function*() {
|
||||
|
||||
// If you have an opener cross process navigation shouldn't work
|
||||
yield BrowserTestUtils.withNewTab("http://example.com", function*(aBrowser) {
|
||||
ok(true, "Starting test 2");
|
||||
info("Starting test 2");
|
||||
let pid1 = yield getPID(aBrowser);
|
||||
|
||||
// Fail the test if we create a process
|
||||
@ -128,7 +132,7 @@ add_task(function*() {
|
||||
|
||||
// Load Large-Allocation twice with about:blank load in between
|
||||
yield BrowserTestUtils.withNewTab("about:blank", function*(aBrowser) {
|
||||
ok(true, "Starting test 3");
|
||||
info("Starting test 3");
|
||||
let pid1 = yield getPID(aBrowser);
|
||||
|
||||
let epc = expectProcessCreated();
|
||||
@ -171,7 +175,7 @@ add_task(function*() {
|
||||
|
||||
// Load Large-Allocation then about:blank load, then back button press should load from bfcache.
|
||||
yield BrowserTestUtils.withNewTab("about:blank", function*(aBrowser) {
|
||||
ok(true, "Starting test 4");
|
||||
info("Starting test 4");
|
||||
let pid1 = yield getPID(aBrowser);
|
||||
|
||||
let epc = expectProcessCreated();
|
||||
@ -221,4 +225,76 @@ add_task(function*() {
|
||||
isnot(pid2, pid4, "PID 4 shouldn't match PID 2");
|
||||
|
||||
});
|
||||
|
||||
// Two consecutive large-allocation loads should create two processes.
|
||||
yield BrowserTestUtils.withNewTab("about:blank", function*(aBrowser) {
|
||||
info("Starting test 5");
|
||||
let pid1 = yield getPID(aBrowser);
|
||||
|
||||
let ready = Promise.all([expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser)]);
|
||||
|
||||
yield ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
yield ready;
|
||||
|
||||
let pid2 = yield getPID(aBrowser);
|
||||
|
||||
isnot(pid1, pid2, "PIDs 1 and 2 should not match");
|
||||
|
||||
let epc = expectProcessCreated();
|
||||
|
||||
yield ContentTask.spawn(aBrowser, TEST_URI_2, TEST_URI_2 => {
|
||||
content.document.location = TEST_URI_2;
|
||||
});
|
||||
|
||||
yield epc;
|
||||
|
||||
let pid3 = yield getPID(aBrowser);
|
||||
|
||||
isnot(pid1, pid3, "PIDs 1 and 3 should not match");
|
||||
isnot(pid2, pid3, "PIDs 1 and 3 should not match");
|
||||
});
|
||||
|
||||
// Opening a window from the large-allocation window should prevent the process switch.
|
||||
yield BrowserTestUtils.withNewTab("about:blank", function*(aBrowser) {
|
||||
info("Starting test 6");
|
||||
let pid1 = yield getPID(aBrowser);
|
||||
|
||||
let ready = Promise.all([expectProcessCreated(),
|
||||
BrowserTestUtils.browserLoaded(aBrowser)]);
|
||||
|
||||
yield ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
|
||||
content.document.location = TEST_URI;
|
||||
});
|
||||
|
||||
yield ready;
|
||||
|
||||
let pid2 = yield getPID(aBrowser);
|
||||
|
||||
isnot(pid1, pid2, "PIDs 1 and 2 should not match");
|
||||
|
||||
yield BrowserTestUtils.synthesizeMouse("a", 0, 0, {}, aBrowser);
|
||||
|
||||
let stopExpectNoProcess = expectNoProcess();
|
||||
|
||||
yield ContentTask.spawn(aBrowser, null, () => {
|
||||
content.document.location = "about:blank";
|
||||
});
|
||||
|
||||
yield BrowserTestUtils.browserLoaded(aBrowser);
|
||||
|
||||
let pid3 = yield getPID(aBrowser);
|
||||
|
||||
is(pid3, pid2, "PIDs 2 and 3 should match");
|
||||
|
||||
stopExpectNoProcess();
|
||||
|
||||
is(gBrowser.tabs.length, 3, "There should be 3 tabs");
|
||||
|
||||
// Get rid of that other tab. It should always be the last one.
|
||||
gBrowser.removeTab(gBrowser.tabs[2]);
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,9 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>Loaded in a new process!</body>
|
||||
<script>
|
||||
function onClick() {
|
||||
window.open("about:blank");
|
||||
}
|
||||
</script>
|
||||
<body><a onclick="onClick()">clicky</a>Loaded in a new process!</body>
|
||||
</html>
|
||||
|
4
dom/tests/browser/test_largeAllocation2.html
Normal file
4
dom/tests/browser/test_largeAllocation2.html
Normal file
@ -0,0 +1,4 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>Loaded in a new process!</body>
|
||||
</html>
|
1
dom/tests/browser/test_largeAllocation2.html^headers^
Normal file
1
dom/tests/browser/test_largeAllocation2.html^headers^
Normal file
@ -0,0 +1 @@
|
||||
Large-Allocation: 0
|
Loading…
Reference in New Issue
Block a user