forked from mirrors/gecko-dev
Bug 1747261: enable ServiceWorker process-isolation for all domains r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D134505
This commit is contained in:
parent
e27a6d1ff0
commit
acfbcd62fe
5 changed files with 11 additions and 44 deletions
|
|
@ -121,9 +121,14 @@ add_task(async function() {
|
||||||
await removeTab(gBrowser.selectedTab);
|
await removeTab(gBrowser.selectedTab);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Test setting breakpoints while the service worker is starting up.
|
// Test setting breakpoints while the service worker is starting up.
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
info("Subtest #4");
|
info("Subtest #4");
|
||||||
|
if (Services.appinfo.fissionAutostart) {
|
||||||
|
// Disabled when serviceworker isolation is used due to bug 1749341
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const toolbox = await openNewTabAndToolbox(
|
const toolbox = await openNewTabAndToolbox(
|
||||||
EXAMPLE_URL + "doc-service-workers.html",
|
EXAMPLE_URL + "doc-service-workers.html",
|
||||||
|
|
|
||||||
|
|
@ -322,28 +322,9 @@ add_task(async function test() {
|
||||||
|
|
||||||
// ## Fission Isolation
|
// ## Fission Isolation
|
||||||
if (Services.appinfo.fissionAutostart) {
|
if (Services.appinfo.fissionAutostart) {
|
||||||
const fissionUrl = "example.com";
|
// ## ServiceWorker isolation
|
||||||
const fissionRemoteType = `webIsolated=https://example.com`;
|
|
||||||
|
|
||||||
await do_test_sw(fissionUrl, fissionRemoteType, "synthetic", null);
|
|
||||||
await do_test_sw(fissionUrl, fissionRemoteType, "synthetic", fileBlob);
|
|
||||||
|
|
||||||
// ## ServiceWorker isolation via allow-list
|
|
||||||
const isolateUrl = "example.com";
|
const isolateUrl = "example.com";
|
||||||
const isolateRemoteType = `webServiceWorker=https://` + isolateUrl;
|
const isolateRemoteType = `webServiceWorker=https://` + isolateUrl;
|
||||||
await SpecialPowers.pushPrefEnv({
|
|
||||||
set: [
|
|
||||||
[
|
|
||||||
"browser.tabs.remote.serviceWorkerIsolationList",
|
|
||||||
"https://" + isolateUrl,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"browser.tabs.remote.separatePrivilegedMozillaWebContentProcess",
|
|
||||||
false,
|
|
||||||
],
|
|
||||||
["browser.tabs.remote.separatedMozillaDomains", ""],
|
|
||||||
],
|
|
||||||
});
|
|
||||||
await do_test_sw(isolateUrl, isolateRemoteType, "synthetic", null);
|
await do_test_sw(isolateUrl, isolateRemoteType, "synthetic", null);
|
||||||
await do_test_sw(isolateUrl, isolateRemoteType, "synthetic", fileBlob);
|
await do_test_sw(isolateUrl, isolateRemoteType, "synthetic", fileBlob);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1432,14 +1432,6 @@
|
||||||
value: true
|
value: true
|
||||||
mirror: always
|
mirror: always
|
||||||
|
|
||||||
# Temporary pref which makes certain ServiceWorkers be isolated in special
|
|
||||||
# processes instead of within a the normal web/webIsolated process based on
|
|
||||||
# the URI. Entries are separated by commas
|
|
||||||
- name: browser.tabs.remote.serviceWorkerIsolationList
|
|
||||||
type: String
|
|
||||||
value: ""
|
|
||||||
mirror: never
|
|
||||||
|
|
||||||
# When this pref is enabled, opaque response is only allowed to enter the
|
# When this pref is enabled, opaque response is only allowed to enter the
|
||||||
# content process if it's a response for media (audio, image, video), CSS, or
|
# content process if it's a response for media (audio, image, video), CSS, or
|
||||||
# JavaScript.
|
# JavaScript.
|
||||||
|
|
|
||||||
|
|
@ -44,16 +44,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
"browser.tabs.remote.useCrossOriginOpenerPolicy",
|
"browser.tabs.remote.useCrossOriginOpenerPolicy",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
// Preference containing the list (comma separated) of origins that will
|
|
||||||
// have ServiceWorkers isolated in special processes
|
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(
|
|
||||||
this,
|
|
||||||
"serviceWorkerIsolationList",
|
|
||||||
"browser.tabs.remote.serviceWorkerIsolationList",
|
|
||||||
"",
|
|
||||||
false,
|
|
||||||
val => val.split(",")
|
|
||||||
);
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(
|
XPCOMUtils.defineLazyServiceGetter(
|
||||||
this,
|
this,
|
||||||
"serializationHelper",
|
"serializationHelper",
|
||||||
|
|
@ -250,10 +240,7 @@ function validatedWebRemoteType(
|
||||||
|
|
||||||
if (
|
if (
|
||||||
aIsWorker &&
|
aIsWorker &&
|
||||||
aWorkerType === Ci.nsIE10SUtils.REMOTE_WORKER_TYPE_SERVICE &&
|
aWorkerType === Ci.nsIE10SUtils.REMOTE_WORKER_TYPE_SERVICE
|
||||||
serviceWorkerIsolationList.some(function(val) {
|
|
||||||
return targetPrincipal.siteOriginNoSuffix == val;
|
|
||||||
})
|
|
||||||
) {
|
) {
|
||||||
return `${SERVICEWORKER_REMOTE_TYPE}=${targetPrincipal.siteOrigin}`;
|
return `${SERVICEWORKER_REMOTE_TYPE}=${targetPrincipal.siteOrigin}`;
|
||||||
}
|
}
|
||||||
|
|
@ -289,6 +276,7 @@ var E10SUtils = {
|
||||||
PRIVILEGEDMOZILLA_REMOTE_TYPE,
|
PRIVILEGEDMOZILLA_REMOTE_TYPE,
|
||||||
LARGE_ALLOCATION_REMOTE_TYPE,
|
LARGE_ALLOCATION_REMOTE_TYPE,
|
||||||
FISSION_WEB_REMOTE_TYPE,
|
FISSION_WEB_REMOTE_TYPE,
|
||||||
|
SERVICEWORKER_REMOTE_TYPE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param aURI The URI of the about page
|
* @param aURI The URI of the about page
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ const {
|
||||||
NOT_REMOTE,
|
NOT_REMOTE,
|
||||||
PRIVILEGEDABOUT_REMOTE_TYPE,
|
PRIVILEGEDABOUT_REMOTE_TYPE,
|
||||||
PRIVILEGEDMOZILLA_REMOTE_TYPE,
|
PRIVILEGEDMOZILLA_REMOTE_TYPE,
|
||||||
|
SERVICEWORKER_REMOTE_TYPE,
|
||||||
WEB_REMOTE_COOP_COEP_TYPE_PREFIX,
|
WEB_REMOTE_COOP_COEP_TYPE_PREFIX,
|
||||||
WEB_REMOTE_TYPE,
|
WEB_REMOTE_TYPE,
|
||||||
} = E10SUtils;
|
} = E10SUtils;
|
||||||
|
|
@ -77,7 +78,7 @@ add_task(function test_get_remote_type_for_service_worker() {
|
||||||
// - content principal + any preferred remote type => web remote type
|
// - content principal + any preferred remote type => web remote type
|
||||||
// - fission enabled:
|
// - fission enabled:
|
||||||
// - extension principal + any preferred remote type => extension remote type
|
// - extension principal + any preferred remote type => extension remote type
|
||||||
// - content principal + any preferred remote type => webIsolated=siteOrigin remote type
|
// - content principal + any preferred remote type => webServiceWorker=siteOrigin remote type
|
||||||
function* getTestCase(fission = false) {
|
function* getTestCase(fission = false) {
|
||||||
const TEST_PRINCIPALS = [
|
const TEST_PRINCIPALS = [
|
||||||
principalSecureCom,
|
principalSecureCom,
|
||||||
|
|
@ -129,7 +130,7 @@ add_task(function test_get_remote_type_for_service_worker() {
|
||||||
// Test cases for e10s mode + fission enabled.
|
// Test cases for e10s mode + fission enabled.
|
||||||
for (const testCase of getTestCase(true)) {
|
for (const testCase of getTestCase(true)) {
|
||||||
const [msg, principal, ...args] = testCase;
|
const [msg, principal, ...args] = testCase;
|
||||||
let expected = `${FISSION_WEB_REMOTE_TYPE}=${principal.siteOrigin}`;
|
let expected = `${SERVICEWORKER_REMOTE_TYPE}=${principal.siteOrigin}`;
|
||||||
|
|
||||||
if (principal == principalExtension) {
|
if (principal == principalExtension) {
|
||||||
expected = WebExtensionPolicy.useRemoteWebExtensions
|
expected = WebExtensionPolicy.useRemoteWebExtensions
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue