Bug 1596462 - Make browser_aboutnewtab_process_selection.js Fission-compatible, r=kmag

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kashav Madan 2019-11-21 00:17:00 +00:00
parent 1d657c8499
commit 649ac773f7
2 changed files with 57 additions and 41 deletions

View File

@ -49,9 +49,7 @@ tags = mcb
skip-if = !e10s || verify # this only makes sense with e10s-multi
[browser_messagemanager_loadprocessscript.js]
[browser_aboutnewtab_process_selection.js]
fail-if = fission
skip-if = !e10s # this only makes sense with e10s-multi
uses-unsafe-cpows = true
[browser_messagemanager_targetframeloader.js]
[browser_messagemanager_unload.js]
skip-if = fission # Fails with Fission, and we're unlikely to spend time to fix it. (bug 1587490)

View File

@ -1,4 +1,5 @@
const TEST_URL = "http://www.example.com/browser/dom/base/test/dummy.html";
const TEST_URL_2 = "http://example.org/browser/dom/base/test/dummy.html";
const PRELOADED_STATE = "preloaded";
const CONSUMED_STATE = "consumed";
@ -26,59 +27,76 @@ add_task(async function() {
// Wait for the preloaded browser to load.
await BrowserTestUtils.maybeCreatePreloadedBrowser(gBrowser);
// Store the number of processes (note: +1 for the parent process).
const { childCount: originalChildCount } = ppmm;
// Store the number of processes.
let expectedChildCount = ppmm.childCount;
// Use the preloaded browser and create another one.
BrowserOpenTab();
let tab1 = gBrowser.selectedTab;
await BrowserTestUtils.maybeCreatePreloadedBrowser(gBrowser);
// Open 3 tabs using the preloaded browser.
let tabs = [];
for (let i = 0; i < 3; i++) {
BrowserOpenTab();
tabs.unshift(gBrowser.selectedTab);
await BrowserTestUtils.maybeCreatePreloadedBrowser(gBrowser);
// Check that the process count did not change.
is(
ppmm.childCount,
originalChildCount,
"Preloaded browser should not create a new content process."
);
// Let's do another round.
BrowserOpenTab();
let tab2 = gBrowser.selectedTab;
await BrowserTestUtils.maybeCreatePreloadedBrowser(gBrowser);
// Check that the process count did not change.
is(
ppmm.childCount,
originalChildCount,
"Preloaded browser should (still) not create a new content process."
);
// Check that the process count did not change.
is(
ppmm.childCount,
expectedChildCount,
"Preloaded browser should not create a new content process."
);
}
// Navigate to a content page from the parent side.
BrowserTestUtils.loadURI(tab2.linkedBrowser, TEST_URL);
await BrowserTestUtils.browserLoaded(tab2.linkedBrowser, false, TEST_URL);
//
// We should create a new content process.
expectedChildCount += 1;
BrowserTestUtils.loadURI(tabs[0].linkedBrowser, TEST_URL);
await BrowserTestUtils.browserLoaded(tabs[0].linkedBrowser, false, TEST_URL);
is(
ppmm.childCount,
originalChildCount + 1,
expectedChildCount,
"Navigating away from the preloaded browser (parent side) should create a new content process."
);
// Navigate to a content page from the child side.
await BrowserTestUtils.switchTab(gBrowser, tab1);
/* eslint-disable no-shadow */
await ContentTask.spawn(tab1.linkedBrowser, null, async function() {
const TEST_URL = "http://www.example.com/browser/dom/base/test/dummy.html";
content.location.href = TEST_URL;
// Navigate to the same content page from the child side.
//
// We already have a content process for TEST_URL, so we don't create a new
// one when Fission is enabled.
expectedChildCount += gFissionBrowser ? 0 : 1;
await BrowserTestUtils.switchTab(gBrowser, tabs[1]);
await ContentTask.spawn(tabs[1].linkedBrowser, TEST_URL, url => {
content.location.href = url;
});
/* eslint-enable no-shadow */
await BrowserTestUtils.browserLoaded(tab1.linkedBrowser, false, TEST_URL);
await BrowserTestUtils.browserLoaded(tabs[1].linkedBrowser, false, TEST_URL);
is(
ppmm.childCount,
originalChildCount + 2,
"Navigating away from the preloaded browser (child side) should create a new content process."
expectedChildCount,
`Navigating away from the preloaded browser (child side, same-origin) should${
gFissionBrowser ? " not " : " "
}create a new content process.`
);
BrowserTestUtils.removeTab(tab1);
BrowserTestUtils.removeTab(tab2);
// Navigate to a new content page from the child side.
//
// We should create a new content process, with or without Fission.
expectedChildCount += 1;
await BrowserTestUtils.switchTab(gBrowser, tabs[2]);
await ContentTask.spawn(tabs[2].linkedBrowser, TEST_URL_2, url => {
content.location.href = url;
});
await BrowserTestUtils.browserLoaded(
tabs[2].linkedBrowser,
false,
TEST_URL_2
);
is(
ppmm.childCount,
expectedChildCount,
"Navigating away from the preloaded browser (child side, cross-origin) should create a new content process."
);
for (let tab of tabs) {
BrowserTestUtils.removeTab(tab);
}
// Make sure the preload browser does not keep any of the new processes alive.
NewTabPagePreloading.removePreloadedBrowser(window);