diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index f40fceaaa299..3a093927b22f 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -2400,6 +2400,11 @@ void nsGlobalWindowInner::UpdateTopInnerWindow() { bool nsGlobalWindowInner::CanShareMemory(const nsID& aAgentClusterId) { MOZ_ASSERT(NS_IsMainThread()); + if (StaticPrefs:: + dom_postMessage_sharedArrayBuffer_bypassCOOP_COEP_insecure_enabled()) { + return true; + } + if (!StaticPrefs::dom_postMessage_sharedArrayBuffer_withCOOP_COEP()) { return false; } diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 7867d4672a43..65887a252ce7 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -4970,6 +4970,11 @@ const nsAString& WorkerPrivate::Id() { bool WorkerPrivate::CanShareMemory(const nsID& aAgentClusterId) { AssertIsOnWorkerThread(); + if (StaticPrefs:: + dom_postMessage_sharedArrayBuffer_bypassCOOP_COEP_insecure_enabled()) { + return true; + } + if (!StaticPrefs::dom_postMessage_sharedArrayBuffer_withCOOP_COEP()) { return false; } diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 9eb848f3f35a..fe244886b764 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -1903,6 +1903,12 @@ value: false mirror: always +# Overridden in all.js on RELEASE_OR_BETA in order to add the locked attribute. +- name: dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled + type: RelaxedAtomicBool + value: false + mirror: always + # Presentation API - name: dom.presentation.enabled type: bool diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 213e612281d4..d1b12006ad82 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4935,3 +4935,11 @@ pref("devtools.devices.url", "https://code.cdn.mozilla.net/devices/devices.json" // Enable Inactive CSS detection; used both by the client and the server. pref("devtools.inspector.inactive.css.enabled", true); + +#if defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION) +// Define in StaticPrefList.yaml and override here since StaticPrefList.yaml +// doesn't provide a way to lock the pref +pref("dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled", false); +#else +pref("dom.postMessage.sharedArrayBuffer.bypassCOOP_COEP.insecure.enabled", false, locked); +#endif