зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1603007 - Remove allowLinkedWebInFileUriProcess r=nika
This patch removes the allowLinkedWebInFileUriProcess pref, but one code-path is kept because when DocumentChannel is disabled a HTTP POST load from a file:// page would loose the postData, so that case keeps the FILE remote type. Differential Revision: https://phabricator.services.mozilla.com/D69923
This commit is contained in:
Родитель
7edcf8ac3b
Коммит
4e341bce84
|
@ -72,8 +72,6 @@ support-files = file_new_tab_page.html
|
|||
skip-if = !e10s || (os == 'linux' && debug && bits == 64) # Pref and test only relevant for e10s, Bug 1581500.
|
||||
[browser_privilegedmozilla_process_pref.js]
|
||||
skip-if = !e10s # Pref and test only relevant for e10s.
|
||||
[browser_new_web_tab_in_file_process_pref.js]
|
||||
skip-if = !e10s # Pref and test only relevant for e10s.
|
||||
[browser_newwindow_tabstrip_overflow.js]
|
||||
[browser_open_newtab_start_observer_notification.js]
|
||||
[browser_opened_file_tab_navigated_to_web.js]
|
||||
|
|
|
@ -1,317 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
|
||||
const TEST_FILE = "dummy_page.html";
|
||||
const TEST_HTTP = "http://example.org/";
|
||||
const TEST_CROSS_ORIGIN = "http://example.com/";
|
||||
let testFile = getChromeDir(getResolvedURI(gTestPath));
|
||||
testFile.append(TEST_FILE);
|
||||
testFile.normalize();
|
||||
const testFileURI = Services.io.newFileURI(testFile).spec;
|
||||
|
||||
function getBrowserPid(browser) {
|
||||
return SpecialPowers.spawn(browser, [], () => Services.appinfo.processID);
|
||||
}
|
||||
|
||||
async function CheckBrowserInPid(browser, expectedPid, message) {
|
||||
let pid = await getBrowserPid(browser);
|
||||
is(pid, expectedPid, message);
|
||||
}
|
||||
|
||||
async function CheckBrowserNotInPid(browser, unExpectedPid, message) {
|
||||
let pid = await getBrowserPid(browser);
|
||||
isnot(pid, unExpectedPid, message);
|
||||
}
|
||||
|
||||
async function runWebNotInFileTest(prefValue) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.tabs.remote.allowLinkedWebInFileUriProcess", prefValue]],
|
||||
});
|
||||
info(`Running test with allowLinkedWebInFileUriProcess=${prefValue}`);
|
||||
|
||||
// Verify that with this pref disabled the new HTTP content loaded into a file
|
||||
// tab causes a process switch.
|
||||
|
||||
// Open file:// page.
|
||||
await BrowserTestUtils.withNewTab(testFileURI, async function(fileBrowser) {
|
||||
// Get the file:// URI pid for comparison later.
|
||||
let filePid = await getBrowserPid(fileBrowser);
|
||||
|
||||
// Check that http tab opened from JS in file:// page is in a different
|
||||
// process.
|
||||
let promiseTabOpened = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
TEST_HTTP,
|
||||
/* waitForLoad */ true
|
||||
);
|
||||
await SpecialPowers.spawn(fileBrowser, [TEST_HTTP], uri => {
|
||||
content.open(uri, "_blank");
|
||||
});
|
||||
let httpTab = await promiseTabOpened;
|
||||
let httpBrowser = httpTab.linkedBrowser;
|
||||
registerCleanupFunction(async function() {
|
||||
BrowserTestUtils.removeTab(httpTab);
|
||||
});
|
||||
await CheckBrowserNotInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that new http tab opened from file loaded in a new content process."
|
||||
);
|
||||
ok(
|
||||
E10SUtils.isWebRemoteType(httpBrowser.remoteType),
|
||||
`Check that tab now has web remote type, got ${httpBrowser.remoteType}.`
|
||||
);
|
||||
|
||||
// Check that a file:// URI load switches back to the file process.
|
||||
let httpPid = await getBrowserPid(httpBrowser);
|
||||
let promiseLoad = BrowserTestUtils.browserLoaded(
|
||||
httpBrowser,
|
||||
/* includeSubFrames */ false,
|
||||
testFileURI
|
||||
);
|
||||
BrowserTestUtils.loadURI(httpBrowser, testFileURI);
|
||||
await promiseLoad;
|
||||
await CheckBrowserNotInPid(
|
||||
httpBrowser,
|
||||
httpPid,
|
||||
"Check that tab not in http content process after file:// load."
|
||||
);
|
||||
is(
|
||||
httpBrowser.remoteType,
|
||||
E10SUtils.FILE_REMOTE_TYPE,
|
||||
"Check that tab now has file remote type."
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Test for bug 1343184.
|
||||
async function runWebInFileTest() {
|
||||
// Set prefs to ensure file content process, to allow linked web content in
|
||||
// file URI process and allow more that one file content process.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.tabs.remote.allowLinkedWebInFileUriProcess", true]],
|
||||
});
|
||||
info("Running test with allowLinkedWebInFileUriProcess=true");
|
||||
|
||||
// Open file:// page.
|
||||
await BrowserTestUtils.withNewTab(testFileURI, async function(fileBrowser) {
|
||||
// Get the file:// URI pid for comparison later.
|
||||
let filePid = await getBrowserPid(fileBrowser);
|
||||
|
||||
// Check that http tab opened from JS in file:// page is in same process.
|
||||
let promiseTabOpened = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
TEST_HTTP,
|
||||
true
|
||||
);
|
||||
await SpecialPowers.spawn(fileBrowser, [TEST_HTTP], uri => {
|
||||
content.open(uri, "_blank");
|
||||
});
|
||||
let httpTab = await promiseTabOpened;
|
||||
let httpBrowser = httpTab.linkedBrowser;
|
||||
registerCleanupFunction(async function() {
|
||||
BrowserTestUtils.removeTab(httpTab);
|
||||
});
|
||||
await CheckBrowserInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that new http tab opened from file loaded in file content process."
|
||||
);
|
||||
is(
|
||||
httpBrowser.remoteType,
|
||||
E10SUtils.FILE_REMOTE_TYPE,
|
||||
"Check that tab now has file remote type."
|
||||
);
|
||||
|
||||
// Check that reload doesn't break the file content process affinity.
|
||||
if (httpTab != gBrowser.selectedTab) {
|
||||
httpTab = await BrowserTestUtils.switchTab(gBrowser, httpTab);
|
||||
httpBrowser = httpTab.linkedBrowser;
|
||||
}
|
||||
let promiseLoad = BrowserTestUtils.browserLoaded(
|
||||
httpBrowser,
|
||||
false,
|
||||
TEST_HTTP
|
||||
);
|
||||
document.getElementById("reload-button").doCommand();
|
||||
await promiseLoad;
|
||||
await CheckBrowserInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that http tab still in file content process after reload."
|
||||
);
|
||||
|
||||
// Check that same-origin load doesn't break the affinity.
|
||||
promiseLoad = BrowserTestUtils.browserLoaded(
|
||||
httpBrowser,
|
||||
false,
|
||||
TEST_HTTP + "foo"
|
||||
);
|
||||
BrowserTestUtils.loadURI(httpBrowser, TEST_HTTP + "foo");
|
||||
await promiseLoad;
|
||||
await CheckBrowserInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that http tab still in file content process after same origin load."
|
||||
);
|
||||
|
||||
// Check that history back doesn't break the affinity.
|
||||
let promiseLocation = BrowserTestUtils.waitForLocationChange(
|
||||
gBrowser,
|
||||
TEST_HTTP
|
||||
);
|
||||
httpBrowser.goBack();
|
||||
await promiseLocation;
|
||||
await CheckBrowserInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that http tab still in file content process after history back."
|
||||
);
|
||||
|
||||
// Check that history forward doesn't break the affinity.
|
||||
promiseLocation = BrowserTestUtils.waitForLocationChange(
|
||||
gBrowser,
|
||||
TEST_HTTP + "foo"
|
||||
);
|
||||
promiseLoad = BrowserTestUtils.browserLoaded(
|
||||
httpBrowser,
|
||||
false,
|
||||
TEST_HTTP + "foo"
|
||||
);
|
||||
httpBrowser.goForward();
|
||||
await promiseLocation;
|
||||
await CheckBrowserInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that http tab still in file content process after history forward."
|
||||
);
|
||||
|
||||
// Check that goto history index doesn't break the affinity.
|
||||
promiseLocation = BrowserTestUtils.waitForLocationChange(
|
||||
gBrowser,
|
||||
TEST_HTTP
|
||||
);
|
||||
httpBrowser.gotoIndex(0);
|
||||
await promiseLocation;
|
||||
await CheckBrowserInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that http tab still in file content process after history gotoIndex."
|
||||
);
|
||||
|
||||
// Check that file:// URI load doesn't break the affinity.
|
||||
promiseLoad = BrowserTestUtils.browserLoaded(
|
||||
httpBrowser,
|
||||
false,
|
||||
testFileURI
|
||||
);
|
||||
BrowserTestUtils.loadURI(httpBrowser, testFileURI);
|
||||
await promiseLoad;
|
||||
await CheckBrowserInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that http tab still in file content process after file:// load."
|
||||
);
|
||||
|
||||
// Check that location change doesn't break the affinity.
|
||||
promiseLoad = BrowserTestUtils.browserLoaded(httpBrowser, false, TEST_HTTP);
|
||||
await SpecialPowers.spawn(httpBrowser, [TEST_HTTP], uri => {
|
||||
content.location = uri;
|
||||
});
|
||||
await promiseLoad;
|
||||
await CheckBrowserInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that http tab still in file content process after location change."
|
||||
);
|
||||
|
||||
// Check that cross-origin load does break the affinity.
|
||||
promiseLoad = BrowserTestUtils.browserLoaded(
|
||||
httpBrowser,
|
||||
false,
|
||||
TEST_CROSS_ORIGIN
|
||||
);
|
||||
BrowserTestUtils.loadURI(httpBrowser, TEST_CROSS_ORIGIN);
|
||||
await promiseLoad;
|
||||
await CheckBrowserNotInPid(
|
||||
httpBrowser,
|
||||
filePid,
|
||||
"Check that http tab not in file content process after cross origin load."
|
||||
);
|
||||
ok(
|
||||
E10SUtils.isWebRemoteType(httpBrowser.remoteType),
|
||||
"Check that tab now has web remote type."
|
||||
);
|
||||
|
||||
// Check that history back now remains in the web content process.
|
||||
let httpPid = await getBrowserPid(httpBrowser);
|
||||
promiseLocation = BrowserTestUtils.waitForLocationChange(
|
||||
gBrowser,
|
||||
TEST_HTTP
|
||||
);
|
||||
httpBrowser.goBack();
|
||||
await promiseLocation;
|
||||
await CheckBrowserInPid(
|
||||
httpBrowser,
|
||||
httpPid,
|
||||
"Check that http tab still in web content process after process switch and history back."
|
||||
);
|
||||
|
||||
// Check that history back to file:// URI switches to file content process.
|
||||
promiseLocation = BrowserTestUtils.waitForLocationChange(
|
||||
gBrowser,
|
||||
testFileURI
|
||||
);
|
||||
httpBrowser.goBack();
|
||||
await promiseLocation;
|
||||
await CheckBrowserNotInPid(
|
||||
httpBrowser,
|
||||
httpPid,
|
||||
"Check that history back to file:// URI switches to file content process."
|
||||
);
|
||||
is(
|
||||
httpBrowser.remoteType,
|
||||
E10SUtils.FILE_REMOTE_TYPE,
|
||||
"Check that tab now has file remote type."
|
||||
);
|
||||
});
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.tabs.remote.separateFileUriProcess", true],
|
||||
["dom.ipc.processCount.file", 2],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function runWebNotInFileTestFalse() {
|
||||
await runWebNotInFileTest(false);
|
||||
});
|
||||
|
||||
if (SpecialPowers.useRemoteSubframes) {
|
||||
add_task(async function runWebNotInFileTestTrue() {
|
||||
await runWebNotInFileTest(true);
|
||||
});
|
||||
} else {
|
||||
// Without document channel this pref obeyed.
|
||||
add_task(async function runWithDCOff() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.tabs.documentchannel", false]],
|
||||
});
|
||||
await runWebInFileTest();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
// With document channel this pref is ignored.
|
||||
add_task(async function runWithDCOn() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.tabs.documentchannel", true]],
|
||||
});
|
||||
await runWebNotInFileTest(true);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
}
|
|
@ -167,32 +167,10 @@ async function runTest(doNewTab) {
|
|||
});
|
||||
}
|
||||
|
||||
if (!SpecialPowers.useRemoteSubframes) {
|
||||
add_task(async function runWithAllowLinked() {
|
||||
// Set prefs to ensure file content process, to allow linked web content in
|
||||
// file URI process and allow more that one file content process.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.tabs.remote.separateFileUriProcess", true],
|
||||
["browser.tabs.remote.allowLinkedWebInFileUriProcess", true],
|
||||
["browser.tabs.documentchannel", false],
|
||||
],
|
||||
});
|
||||
|
||||
await runTest(false);
|
||||
await runTest(true);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function runWithDocumentChannel() {
|
||||
// Set prefs to use documentchannel instead.
|
||||
// Set prefs to use documentchannel.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.tabs.remote.allowLinkedWebInFileUriProcess", false],
|
||||
["browser.tabs.documentchannel", true],
|
||||
],
|
||||
set: [["browser.tabs.documentchannel", true]],
|
||||
});
|
||||
|
||||
await runTest(false);
|
||||
|
|
|
@ -703,7 +703,6 @@ pref("extensions.systemAddon.update.enabled", true);
|
|||
|
||||
// E10s stuff. We don't support 'file' or 'priveleged' process types.
|
||||
pref("browser.tabs.remote.separateFileUriProcess", false);
|
||||
pref("browser.tabs.remote.allowLinkedWebInFileUriProcess", true);
|
||||
pref("browser.tabs.remote.separatePrivilegedContentProcess", false);
|
||||
pref("browser.tabs.remote.enforceRemoteTypeRestrictions", false);
|
||||
|
||||
|
|
|
@ -2719,15 +2719,6 @@ pref("browser.tabs.remote.separateFileUriProcess", true);
|
|||
// web process when running with fission.
|
||||
pref("browser.tabs.remote.dataUriInDefaultWebProcess", false);
|
||||
|
||||
// Pref that enables top level web content pages that are opened from file://
|
||||
// URI pages to run in the file content process.
|
||||
// This has been added in case breaking any window references between these
|
||||
// sorts of pages, which we have to do when we run them in the normal web
|
||||
// content process, causes compatibility issues.
|
||||
//
|
||||
// This is going away and for now is disabled.
|
||||
pref("browser.tabs.remote.allowLinkedWebInFileUriProcess", false);
|
||||
|
||||
// This pref will cause assertions when a remoteType triggers a process switch
|
||||
// to a new remoteType it should not be able to trigger.
|
||||
pref("browser.tabs.remote.enforceRemoteTypeRestrictions", false);
|
||||
|
|
|
@ -11,24 +11,10 @@ const DATA_URL = "data:text/html,Hello%2C World!";
|
|||
const DATA_STRING = "Hello, World!";
|
||||
|
||||
const DOCUMENT_CHANNEL_PREF = "browser.tabs.documentchannel";
|
||||
const LINKED_WEB_IN_FILE_PREF =
|
||||
"browser.tabs.remote.allowLinkedWebInFileUriProcess";
|
||||
|
||||
async function setPref() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[DOCUMENT_CHANNEL_PREF, true],
|
||||
[LINKED_WEB_IN_FILE_PREF, false],
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
async function unsetPref() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[DOCUMENT_CHANNEL_PREF, false],
|
||||
[LINKED_WEB_IN_FILE_PREF, true],
|
||||
],
|
||||
set: [[DOCUMENT_CHANNEL_PREF, true]],
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -235,63 +221,6 @@ async function testLoadAndRedirect(
|
|||
);
|
||||
}
|
||||
|
||||
add_task(async function test_disabled() {
|
||||
if (gFissionBrowser) {
|
||||
info(
|
||||
`Skipping test. Cannot disable ${DOCUMENT_CHANNEL_PREF} with Fission.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await unsetPref();
|
||||
|
||||
// With the pref disabled, file URIs should successfully POST, but remain in
|
||||
// the 'file' process.
|
||||
info("DISABLED -- FILE -- raw URI load");
|
||||
let resp = await postFrom(FILE_DUMMY, PRINT_POSTDATA);
|
||||
is(resp.remoteType, E10SUtils.FILE_REMOTE_TYPE, "no process switch");
|
||||
is(resp.location, PRINT_POSTDATA, "correct location");
|
||||
is(resp.body, "initialRemoteType=file", "correct POST body");
|
||||
|
||||
info("DISABLED -- FILE -- 307-redirect URI load");
|
||||
let resp307 = await postFrom(FILE_DUMMY, add307(PRINT_POSTDATA));
|
||||
is(resp307.remoteType, E10SUtils.FILE_REMOTE_TYPE, "no process switch");
|
||||
is(resp307.location, PRINT_POSTDATA, "correct location");
|
||||
is(resp307.body, "initialRemoteType=file", "correct POST body");
|
||||
|
||||
// With the pref disabled, extension URIs should fail to POST, but correctly
|
||||
// switch processes.
|
||||
await withExtensionDummy(async extOrigin => {
|
||||
info("DISABLED -- EXTENSION -- raw URI load");
|
||||
let respExt = await postFrom(extOrigin + "dummy.html", PRINT_POSTDATA);
|
||||
ok(E10SUtils.isWebRemoteType(respExt.remoteType), "process switch");
|
||||
is(respExt.location, PRINT_POSTDATA, "correct location");
|
||||
is(respExt.body, "", "no POST body");
|
||||
|
||||
info("DISABLED -- EXTENSION -- extension-redirect URI load");
|
||||
let respExtRedirect = await postFrom(
|
||||
extOrigin + "redirect.html",
|
||||
PRINT_POSTDATA
|
||||
);
|
||||
ok(E10SUtils.isWebRemoteType(respExtRedirect.remoteType), "process switch");
|
||||
is(
|
||||
respExtRedirect.location,
|
||||
PRINT_POSTDATA + "?redirected",
|
||||
"correct location"
|
||||
);
|
||||
is(respExtRedirect.body, "redirected", "no POST body");
|
||||
|
||||
info("DISABLED -- EXTENSION -- 307-redirect URI load");
|
||||
let respExt307 = await postFrom(
|
||||
extOrigin + "dummy.html",
|
||||
add307(PRINT_POSTDATA)
|
||||
);
|
||||
ok(E10SUtils.isWebRemoteType(respExt307.remoteType), "process switch");
|
||||
is(respExt307.location, PRINT_POSTDATA, "correct location");
|
||||
is(respExt307.body, "", "no POST body");
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_enabled() {
|
||||
await setPref();
|
||||
|
||||
|
|
|
@ -29,12 +29,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
"browser.tabs.remote.dataUriInDefaultWebProcess",
|
||||
false
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"allowLinkedWebInFileUriProcess",
|
||||
"browser.tabs.remote.allowLinkedWebInFileUriProcess",
|
||||
false
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"useSeparatePrivilegedAboutContentProcess",
|
||||
|
@ -264,38 +258,6 @@ function validatedWebRemoteType(
|
|||
return aPreferredRemoteType;
|
||||
}
|
||||
|
||||
if (
|
||||
allowLinkedWebInFileUriProcess &&
|
||||
// This is not supported with documentchannel and will go away in
|
||||
// Bug 1603007
|
||||
!documentChannel &&
|
||||
aPreferredRemoteType == FILE_REMOTE_TYPE
|
||||
) {
|
||||
E10SUtils.log().debug("checking allowLinkedWebInFileUriProcess");
|
||||
// If aCurrentUri is passed then we should only allow FILE_REMOTE_TYPE
|
||||
// when it is same origin as target or the current URI is already a
|
||||
// file:// URI.
|
||||
if (aCurrentUri) {
|
||||
if (aCurrentUri.scheme == "file" || aCurrentUri.spec == "about:blank") {
|
||||
return FILE_REMOTE_TYPE;
|
||||
}
|
||||
try {
|
||||
// checkSameOriginURI throws when not same origin.
|
||||
// todo: if you intend to update CheckSameOriginURI to log the error to the
|
||||
// console you also need to update the 'aFromPrivateWindow' argument.
|
||||
sm.checkSameOriginURI(aCurrentUri, aTargetUri, false, false);
|
||||
E10SUtils.log().debug("Next URL is same origin");
|
||||
return FILE_REMOTE_TYPE;
|
||||
} catch (e) {
|
||||
E10SUtils.log().debug("Leaving same origin");
|
||||
return WEB_REMOTE_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
E10SUtils.log().debug("No aCurrentUri");
|
||||
return FILE_REMOTE_TYPE;
|
||||
}
|
||||
|
||||
return WEB_REMOTE_TYPE;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче