forked from mirrors/gecko-dev
Differential Revision: https://phabricator.services.mozilla.com/D30276 --HG-- rename : browser/base/content/test/general/browser_e10s_about_page_triggeringprincipal.js => browser/base/content/test/tabs/browser_e10s_about_page_triggeringprincipal.js rename : browser/base/content/test/general/browser_e10s_about_process.js => browser/base/content/test/tabs/browser_e10s_about_process.js rename : browser/base/content/test/general/browser_e10s_chrome_process.js => browser/base/content/test/tabs/browser_e10s_chrome_process.js rename : browser/base/content/test/general/browser_e10s_javascript.js => browser/base/content/test/tabs/browser_e10s_javascript.js rename : browser/base/content/test/general/browser_e10s_switchbrowser.js => browser/base/content/test/tabs/browser_e10s_switchbrowser.js rename : browser/base/content/test/general/file_about_child.html => browser/base/content/test/tabs/file_about_child.html rename : browser/base/content/test/general/file_about_parent.html => browser/base/content/test/tabs/file_about_parent.html rename : browser/base/content/test/general/test_process_flags_chrome.html => browser/base/content/test/tabs/test_process_flags_chrome.html extra : moz-landing-system : lando
183 lines
7.7 KiB
JavaScript
183 lines
7.7 KiB
JavaScript
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
*/
|
|
|
|
/**
|
|
* Tests to ensure that Mozilla Privileged Webpages load in the privileged
|
|
* mozilla web content process. Normal http web pages should load in the web
|
|
* content process.
|
|
* Ref: Bug 1539595.
|
|
*/
|
|
|
|
// High and Low Privilege
|
|
const TEST_HIGH1 = "https://example.org/";
|
|
const TEST_HIGH2 = "https://test1.example.org/";
|
|
const TEST_LOW1 = "http://example.org/";
|
|
const TEST_LOW2 = "https://example.com/";
|
|
|
|
add_task(async function setup() {
|
|
await SpecialPowers.pushPrefEnv({
|
|
set: [
|
|
["browser.tabs.remote.separatePrivilegedMozillaWebContentProcess", true],
|
|
["browser.tabs.remote.separatedMozillaDomains", "example.org"],
|
|
["dom.ipc.processCount.privilegedmozilla", 1],
|
|
],
|
|
});
|
|
});
|
|
|
|
/*
|
|
* Test to ensure that the tabs open in privileged mozilla content process. We
|
|
* will first open a page that acts as a reference to the privileged mozilla web
|
|
* content process. With the reference, we can then open other links in a new tab
|
|
* and ensure that the new tab opens in the same privileged mozilla content process
|
|
* as our reference.
|
|
*/
|
|
add_task(async function webpages_in_privileged_content_process() {
|
|
Services.ppmm.releaseCachedProcesses();
|
|
|
|
await BrowserTestUtils.withNewTab(TEST_HIGH1, async function(browser1) {
|
|
checkBrowserRemoteType(browser1, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE);
|
|
|
|
// Note the processID for about:newtab for comparison later.
|
|
let privilegedPid = browser1.frameLoader.remoteTab.osPid;
|
|
|
|
for (let url of [
|
|
TEST_HIGH1,
|
|
`${TEST_HIGH1}#foo`,
|
|
`${TEST_HIGH1}?q=foo`,
|
|
TEST_HIGH2,
|
|
`${TEST_HIGH2}#foo`,
|
|
`${TEST_HIGH2}?q=foo`,
|
|
]) {
|
|
await BrowserTestUtils.withNewTab(url, async function(browser2) {
|
|
is(browser2.frameLoader.remoteTab.osPid, privilegedPid,
|
|
"Check that privileged pages are in the same privileged mozilla content process.");
|
|
});
|
|
}
|
|
});
|
|
|
|
Services.ppmm.releaseCachedProcesses();
|
|
});
|
|
|
|
/*
|
|
* Test to ensure that a process switch occurs when navigating between normal
|
|
* web pages and unprivileged pages in the same tab.
|
|
*/
|
|
add_task(async function process_switching_through_loading_in_the_same_tab() {
|
|
Services.ppmm.releaseCachedProcesses();
|
|
|
|
await BrowserTestUtils.withNewTab(TEST_LOW1, async function(browser) {
|
|
checkBrowserRemoteType(browser, E10SUtils.WEB_REMOTE_TYPE);
|
|
|
|
for (let [url, remoteType] of [
|
|
[TEST_HIGH1, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE],
|
|
[TEST_LOW1, E10SUtils.WEB_REMOTE_TYPE],
|
|
[TEST_HIGH1, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE],
|
|
[TEST_LOW2, E10SUtils.WEB_REMOTE_TYPE],
|
|
[TEST_HIGH1, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE],
|
|
[TEST_LOW1, E10SUtils.WEB_REMOTE_TYPE],
|
|
[TEST_LOW2, E10SUtils.WEB_REMOTE_TYPE],
|
|
[`${TEST_HIGH1}#foo`, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE],
|
|
[TEST_LOW1, E10SUtils.WEB_REMOTE_TYPE],
|
|
[`${TEST_HIGH1}#bar`, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE],
|
|
[TEST_LOW2, E10SUtils.WEB_REMOTE_TYPE],
|
|
[`${TEST_HIGH1}#baz`, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE],
|
|
[TEST_LOW1, E10SUtils.WEB_REMOTE_TYPE],
|
|
[`${TEST_HIGH1}?q=foo`, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE],
|
|
[TEST_LOW2, E10SUtils.WEB_REMOTE_TYPE],
|
|
[`${TEST_HIGH1}?q=bar`, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE],
|
|
[TEST_LOW1, E10SUtils.WEB_REMOTE_TYPE],
|
|
[`${TEST_HIGH1}?q=baz`, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE],
|
|
[TEST_LOW2, E10SUtils.WEB_REMOTE_TYPE],
|
|
]) {
|
|
BrowserTestUtils.loadURI(browser, url);
|
|
await BrowserTestUtils.browserLoaded(browser, false, url);
|
|
checkBrowserRemoteType(browser, remoteType);
|
|
}
|
|
});
|
|
|
|
Services.ppmm.releaseCachedProcesses();
|
|
});
|
|
|
|
/*
|
|
* Test to ensure that a process switch occurs when navigating between normal
|
|
* web pages and privileged pages using the browser's navigation features
|
|
* such as history and location change.
|
|
*/
|
|
add_task(async function process_switching_through_navigation_features() {
|
|
Services.ppmm.releaseCachedProcesses();
|
|
|
|
await BrowserTestUtils.withNewTab(TEST_HIGH1, async function(browser) {
|
|
checkBrowserRemoteType(browser, E10SUtils.PRIVILEGEDMOZILLA_REMOTE_TYPE);
|
|
|
|
// Note the processID for about:newtab for comparison later.
|
|
let privilegedPid = browser.frameLoader.remoteTab.osPid;
|
|
|
|
// Check that about:newtab opened from JS in about:newtab page is in the same process.
|
|
let promiseTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, TEST_HIGH1, true);
|
|
await ContentTask.spawn(browser, TEST_HIGH1, uri => {
|
|
content.open(uri, "_blank");
|
|
});
|
|
let newTab = await promiseTabOpened;
|
|
registerCleanupFunction(async function() {
|
|
BrowserTestUtils.removeTab(newTab);
|
|
});
|
|
browser = newTab.linkedBrowser;
|
|
is(browser.frameLoader.remoteTab.osPid, privilegedPid,
|
|
"Check that new tab opened from privileged page is loaded in privileged mozilla content process.");
|
|
|
|
// Check that reload does not break the privileged mozilla content process affinity.
|
|
BrowserReload();
|
|
await BrowserTestUtils.browserLoaded(browser, false, TEST_HIGH1);
|
|
is(browser.frameLoader.remoteTab.osPid, privilegedPid,
|
|
"Check that privileged page is still in privileged mozilla content process after reload.");
|
|
|
|
// Load http webpage
|
|
BrowserTestUtils.loadURI(browser, TEST_LOW1);
|
|
await BrowserTestUtils.browserLoaded(browser, false, TEST_LOW1);
|
|
checkBrowserRemoteType(browser, E10SUtils.WEB_REMOTE_TYPE);
|
|
|
|
// Check that using the history back feature switches back to privileged mozilla content process.
|
|
let promiseLocation = BrowserTestUtils.waitForLocationChange(gBrowser, TEST_HIGH1);
|
|
browser.goBack();
|
|
await promiseLocation;
|
|
// We will need to ensure that the process flip has fully completed so that
|
|
// the navigation history data will be available when we do browser.goForward();
|
|
await BrowserTestUtils.waitForEvent(newTab, "SSTabRestored");
|
|
is(browser.frameLoader.remoteTab.osPid, privilegedPid,
|
|
"Check that privileged page is still in privileged mozilla content process after history goBack.");
|
|
|
|
// Check that using the history forward feature switches back to the web content process.
|
|
promiseLocation = BrowserTestUtils.waitForLocationChange(gBrowser, TEST_LOW1);
|
|
browser.goForward();
|
|
await promiseLocation;
|
|
// We will need to ensure that the process flip has fully completed so that
|
|
// the navigation history data will be available when we do browser.gotoIndex(0);
|
|
await BrowserTestUtils.waitForEvent(newTab, "SSTabRestored");
|
|
checkBrowserRemoteType(browser, E10SUtils.WEB_REMOTE_TYPE,
|
|
"Check that tab runs in the web content process after using history goForward.");
|
|
|
|
// Check that goto history index does not break the affinity.
|
|
promiseLocation = BrowserTestUtils.waitForLocationChange(gBrowser, TEST_HIGH1);
|
|
browser.gotoIndex(0);
|
|
await promiseLocation;
|
|
is(browser.frameLoader.remoteTab.osPid, privilegedPid,
|
|
"Check that privileged page is in privileged mozilla content process after history gotoIndex.");
|
|
|
|
BrowserTestUtils.loadURI(browser, TEST_LOW2);
|
|
await BrowserTestUtils.browserLoaded(browser, false, TEST_LOW2);
|
|
checkBrowserRemoteType(browser, E10SUtils.WEB_REMOTE_TYPE);
|
|
|
|
// Check that location change causes a change in process type as well.
|
|
await ContentTask.spawn(browser, TEST_HIGH1, uri => {
|
|
content.location = uri;
|
|
});
|
|
await BrowserTestUtils.browserLoaded(browser, false, TEST_HIGH1);
|
|
is(browser.frameLoader.remoteTab.osPid, privilegedPid,
|
|
"Check that privileged page is in privileged mozilla content process after location change.");
|
|
});
|
|
|
|
Services.ppmm.releaseCachedProcesses();
|
|
});
|