diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index cef34bace8ba..f9ff69875742 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1427,6 +1427,14 @@ value: true 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 # content process if it's a response for media (audio, image, video), CSS, or # JavaScript. diff --git a/toolkit/modules/E10SUtils.jsm b/toolkit/modules/E10SUtils.jsm index 1bb712a46622..cf044118fa90 100644 --- a/toolkit/modules/E10SUtils.jsm +++ b/toolkit/modules/E10SUtils.jsm @@ -44,6 +44,16 @@ XPCOMUtils.defineLazyPreferenceGetter( "browser.tabs.remote.useCrossOriginOpenerPolicy", 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( this, "serializationHelper", @@ -237,7 +247,10 @@ function validatedWebRemoteType( if ( 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}`; }