From 8351f7cc2d58c9181656cb69b9abc2547732870b Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Mon, 12 Dec 2022 22:08:36 +0000 Subject: [PATCH] Bug 1804093 - Part 5: Eliminate WorkerPrincipal and WorkletPrincipals, r=asuth Differential Revision: https://phabricator.services.mozilla.com/D163856 --- caps/nsJSPrincipals.cpp | 43 ++----------------- caps/nsJSPrincipals.h | 11 ----- dom/base/SerializedStackHolder.cpp | 10 +---- dom/base/StructuredCloneTags.h | 5 --- .../webaudio/AudioWorkletGlobalScope.cpp | 6 +-- dom/workers/Principal.cpp | 36 ---------------- dom/workers/Principal.h | 34 --------------- dom/workers/RuntimeService.cpp | 3 +- dom/workers/ScriptLoader.cpp | 1 - dom/workers/WorkerScope.cpp | 17 ++------ dom/workers/moz.build | 1 - dom/worklet/WorkletPrincipals.cpp | 39 ----------------- dom/worklet/WorkletPrincipals.h | 40 ----------------- dom/worklet/WorkletThread.cpp | 4 +- dom/worklet/moz.build | 2 - layout/style/PaintWorkletGlobalScope.cpp | 5 +-- .../webidl-api/ExtensionEventListener.cpp | 14 +----- 17 files changed, 18 insertions(+), 253 deletions(-) delete mode 100644 dom/workers/Principal.cpp delete mode 100644 dom/workers/Principal.h delete mode 100644 dom/worklet/WorkletPrincipals.cpp delete mode 100644 dom/worklet/WorkletPrincipals.h diff --git a/caps/nsJSPrincipals.cpp b/caps/nsJSPrincipals.cpp index e3bce2536f2a..cdaa0ce6bf4a 100644 --- a/caps/nsJSPrincipals.cpp +++ b/caps/nsJSPrincipals.cpp @@ -13,10 +13,6 @@ #include "mozilla/BasePrincipal.h" #include "mozilla/StaticPtr.h" #include "mozilla/dom/StructuredCloneTags.h" -// for mozilla::dom::workerinternals::kJSPrincipalsDebugToken -#include "mozilla/dom/workerinternals/JSSettings.h" -// for mozilla::dom::worklet::kJSPrincipalsDebugToken -#include "mozilla/dom/WorkletPrincipals.h" #include "mozilla/ipc/BackgroundUtils.h" #include "mozilla/ipc/PBackgroundSharedTypes.h" @@ -85,10 +81,6 @@ JS_PUBLIC_API void JSPrincipals::dump() { nsresult rv = static_cast(this)->GetScriptLocation(str); fprintf(stderr, "nsIPrincipal (%p) = %s\n", static_cast(this), NS_SUCCEEDED(rv) ? str.get() : "(unknown)"); - } else if (debugToken == dom::workerinternals::kJSPrincipalsDebugToken) { - fprintf(stderr, "Web Worker principal singleton (%p)\n", this); - } else if (debugToken == dom::WorkletPrincipals::kJSPrincipalsDebugToken) { - fprintf(stderr, "Web Worklet principal (%p)\n", this); } else { fprintf(stderr, "!!! JSPrincipals (%p) is not nsJSPrincipals instance - bad token: " @@ -109,10 +101,9 @@ bool nsJSPrincipals::ReadPrincipals(JSContext* aCx, return false; } - if (!(tag == SCTAG_DOM_NULL_PRINCIPAL || tag == SCTAG_DOM_SYSTEM_PRINCIPAL || - tag == SCTAG_DOM_CONTENT_PRINCIPAL || - tag == SCTAG_DOM_EXPANDED_PRINCIPAL || - tag == SCTAG_DOM_WORKER_PRINCIPAL)) { + if (tag != SCTAG_DOM_NULL_PRINCIPAL && tag != SCTAG_DOM_SYSTEM_PRINCIPAL && + tag != SCTAG_DOM_CONTENT_PRINCIPAL && + tag != SCTAG_DOM_EXPANDED_PRINCIPAL) { xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR); return false; } @@ -276,19 +267,6 @@ bool nsJSPrincipals::ReadPrincipalInfo(JSStructuredCloneReader* aReader, return ::ReadPrincipalInfo(aReader, tag, aInfo); } -static StaticRefPtr sActiveWorkerPrincipal; - -nsJSPrincipals::AutoSetActiveWorkerPrincipal::AutoSetActiveWorkerPrincipal( - nsIPrincipal* aPrincipal) { - MOZ_ASSERT(NS_IsMainThread()); - MOZ_RELEASE_ASSERT(!sActiveWorkerPrincipal); - sActiveWorkerPrincipal = aPrincipal; -} - -nsJSPrincipals::AutoSetActiveWorkerPrincipal::~AutoSetActiveWorkerPrincipal() { - sActiveWorkerPrincipal = nullptr; -} - /* static */ bool nsJSPrincipals::ReadKnownPrincipalType(JSContext* aCx, JSStructuredCloneReader* aReader, @@ -297,20 +275,7 @@ bool nsJSPrincipals::ReadKnownPrincipalType(JSContext* aCx, MOZ_ASSERT(aTag == SCTAG_DOM_NULL_PRINCIPAL || aTag == SCTAG_DOM_SYSTEM_PRINCIPAL || aTag == SCTAG_DOM_CONTENT_PRINCIPAL || - aTag == SCTAG_DOM_EXPANDED_PRINCIPAL || - aTag == SCTAG_DOM_WORKER_PRINCIPAL); - - if (aTag == SCTAG_DOM_WORKER_PRINCIPAL) { - // When reading principals which were written on a worker thread, we need to - // know the principal of the worker which did the write. - if (!sActiveWorkerPrincipal) { - xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR); - return false; - } - RefPtr retval = get(sActiveWorkerPrincipal); - retval.forget(aOutPrincipals); - return true; - } + aTag == SCTAG_DOM_EXPANDED_PRINCIPAL); PrincipalInfo info; if (!::ReadPrincipalInfo(aReader, aTag, info)) { diff --git a/caps/nsJSPrincipals.h b/caps/nsJSPrincipals.h index a928c0de200a..54cf5f44c03d 100644 --- a/caps/nsJSPrincipals.h +++ b/caps/nsJSPrincipals.h @@ -42,17 +42,6 @@ class nsJSPrincipals : public nsIPrincipal, public JSPrincipals { static bool WritePrincipalInfo(JSStructuredCloneWriter* aWriter, const mozilla::ipc::PrincipalInfo& aInfo); - // This class is used on the main thread to specify which principal to use - // when reading principals data that was set on a DOM worker thread. - // DOM workers do not use principals from Gecko's point of view, and any - // JSPrincipals used internally will be a shared singleton object. When that - // singleton is written out and later read on the main thread, we substitute - // the principal specified with this class. - struct MOZ_RAII AutoSetActiveWorkerPrincipal { - explicit AutoSetActiveWorkerPrincipal(nsIPrincipal* aPrincipal); - ~AutoSetActiveWorkerPrincipal(); - }; - bool write(JSContext* aCx, JSStructuredCloneWriter* aWriter) final; bool isSystemOrAddonPrincipal() final; diff --git a/dom/base/SerializedStackHolder.cpp b/dom/base/SerializedStackHolder.cpp index 43f2ee767a9c..133031967a62 100644 --- a/dom/base/SerializedStackHolder.cpp +++ b/dom/base/SerializedStackHolder.cpp @@ -78,15 +78,7 @@ JSObject* SerializedStackHolder::ReadStack(JSContext* aCx) { JS::Rooted stackValue(aCx); - { - Maybe set; - if (mWorkerRef) { - set.emplace(mWorkerRef->Private()->GetPrincipal()); - } - - mHolder.Read(xpc::CurrentNativeGlobal(aCx), aCx, &stackValue, - IgnoreErrors()); - } + mHolder.Read(xpc::CurrentNativeGlobal(aCx), aCx, &stackValue, IgnoreErrors()); return stackValue.isObject() ? &stackValue.toObject() : nullptr; } diff --git a/dom/base/StructuredCloneTags.h b/dom/base/StructuredCloneTags.h index 42f2e4e1d139..19007c294366 100644 --- a/dom/base/StructuredCloneTags.h +++ b/dom/base/StructuredCloneTags.h @@ -130,11 +130,6 @@ enum StructuredCloneTags : uint32_t { // StructuredCloneHolder::{Read,Write}FullySerializableObjects. In theory they // can be 'less' stable. - // Principal written out by worker threads when serializing objects. When - // reading on the main thread this principal will be converted to a normal - // principal object using nsJSPrincipals::AutoSetActiveWorkerPrincipal. - SCTAG_DOM_WORKER_PRINCIPAL, - SCTAG_DOM_IMAGEBITMAP, SCTAG_DOM_MAP_MESSAGEPORT, SCTAG_DOM_FORMDATA, diff --git a/dom/media/webaudio/AudioWorkletGlobalScope.cpp b/dom/media/webaudio/AudioWorkletGlobalScope.cpp index 44e2e9e677b5..5d20ee9cd30c 100644 --- a/dom/media/webaudio/AudioWorkletGlobalScope.cpp +++ b/dom/media/webaudio/AudioWorkletGlobalScope.cpp @@ -12,12 +12,12 @@ #include "jsapi.h" #include "js/ForOfIterator.h" #include "js/PropertyAndElement.h" // JS_GetProperty +#include "mozilla/BasePrincipal.h" #include "mozilla/dom/AudioWorkletGlobalScopeBinding.h" #include "mozilla/dom/AudioWorkletProcessor.h" #include "mozilla/dom/BindingCallContext.h" #include "mozilla/dom/MessagePort.h" #include "mozilla/dom/StructuredCloneHolder.h" -#include "mozilla/dom/WorkletPrincipals.h" #include "mozilla/dom/AudioParamDescriptorBinding.h" #include "nsPrintfCString.h" #include "nsTHashSet.h" @@ -59,9 +59,9 @@ bool AudioWorkletGlobalScope::WrapGlobalObject( options.creationOptions().setDefineSharedArrayBufferConstructor( IsSharedMemoryAllowed()); - JS::AutoHoldPrincipals principals(aCx, new WorkletPrincipals(mImpl)); return AudioWorkletGlobalScope_Binding::Wrap( - aCx, this, this, options, principals.get(), true, aReflector); + aCx, this, this, options, BasePrincipal::Cast(mImpl->Principal()), true, + aReflector); } void AudioWorkletGlobalScope::RegisterProcessor( diff --git a/dom/workers/Principal.cpp b/dom/workers/Principal.cpp deleted file mode 100644 index c1166e355904..000000000000 --- a/dom/workers/Principal.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "Principal.h" - -#include "JSSettings.h" -#include "jsapi.h" -#include "mozilla/Assertions.h" -#include "mozilla/dom/StructuredCloneTags.h" -#include "mozilla/dom/workerinternals/JSSettings.h" - -namespace mozilla::dom { - -WorkerPrincipal::WorkerPrincipal(bool aIsSystemOrAddonPrincipal) - : JSPrincipals(), mIsSystemOrAddonPrincipal(aIsSystemOrAddonPrincipal) { - setDebugToken(workerinternals::kJSPrincipalsDebugToken); -} - -WorkerPrincipal::~WorkerPrincipal() = default; - -bool WorkerPrincipal::write(JSContext* aCx, JSStructuredCloneWriter* aWriter) { - return JS_WriteUint32Pair(aWriter, SCTAG_DOM_WORKER_PRINCIPAL, 0); -} - -bool WorkerPrincipal::isSystemOrAddonPrincipal() { - return mIsSystemOrAddonPrincipal; -} - -void WorkerPrincipal::Destroy(JSPrincipals* aPrincipals) { - delete static_cast(aPrincipals); -} - -} // namespace mozilla::dom diff --git a/dom/workers/Principal.h b/dom/workers/Principal.h deleted file mode 100644 index 9e9ffa429b60..000000000000 --- a/dom/workers/Principal.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_workers_principal_h__ -#define mozilla_dom_workers_principal_h__ - -#include "js/Principals.h" - -namespace mozilla::dom { - -struct MOZ_HEAP_CLASS WorkerPrincipal final : public JSPrincipals { - explicit WorkerPrincipal(bool aIsSystemOrAddonPrincipal); - - bool write(JSContext* aCx, JSStructuredCloneWriter* aWriter) override; - - // We don't distinguish between System or Addon because the only use - // case for this right now doesn't need to. When you need to distinguish - // add a second bool. - bool isSystemOrAddonPrincipal() override; - - // Callback for JS_InitDestroyPrincipalsCallback() - static void Destroy(JSPrincipals* aPrincipals); - - private: - ~WorkerPrincipal(); - bool mIsSystemOrAddonPrincipal; -}; - -} // namespace mozilla::dom - -#endif /* mozilla_dom_workers_principal_h__ */ diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 60dbd47ed22c..44e00dd420a5 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -71,7 +71,6 @@ # include "nsMacUtilsImpl.h" #endif -#include "Principal.h" #include "WorkerDebuggerManager.h" #include "WorkerError.h" #include "WorkerLoadInfo.h" @@ -876,7 +875,7 @@ class WorkerJSContext final : public mozilla::CycleCollectedJSContext { JSContext* cx = Context(); js::SetPreserveWrapperCallbacks(cx, PreserveWrapper, HasReleasedWrapper); - JS_InitDestroyPrincipalsCallback(cx, WorkerPrincipal::Destroy); + JS_InitDestroyPrincipalsCallback(cx, nsJSPrincipals::Destroy); JS_SetWrapObjectCallbacks(cx, &WrapObjectCallbacks); if (mWorkerPrivate->IsDedicatedWorker()) { JS_SetFutexCanWait(cx); diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index 677e8acb4948..e25e4b4e9480 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -71,7 +71,6 @@ #include "mozilla/ResultExtensions.h" #include "mozilla/StaticPrefs_browser.h" #include "mozilla/UniquePtr.h" -#include "Principal.h" #include "WorkerRunnable.h" #include "WorkerScope.h" diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index 599767a75c0c..5b0caf86128a 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -12,7 +12,6 @@ #include "Crypto.h" #include "GeckoProfiler.h" #include "MainThreadUtils.h" -#include "Principal.h" #include "ScriptLoader.h" #include "js/CompilationAndEvaluation.h" #include "js/CompileOptions.h" @@ -916,9 +915,7 @@ bool DedicatedWorkerGlobalScope::WrapGlobalObject( return DedicatedWorkerGlobalScope_Binding::Wrap( aCx, this, this, options, - new WorkerPrincipal(usesSystemPrincipal || - mWorkerPrivate->UsesAddonOrExpandedAddonPrincipal()), - true, aReflector); + nsJSPrincipals::get(mWorkerPrivate->GetPrincipal()), true, aReflector); } void DedicatedWorkerGlobalScope::PostMessage( @@ -1080,9 +1077,7 @@ bool SharedWorkerGlobalScope::WrapGlobalObject( return SharedWorkerGlobalScope_Binding::Wrap( aCx, this, this, options, - new WorkerPrincipal(mWorkerPrivate->UsesSystemPrincipal() || - mWorkerPrivate->UsesAddonOrExpandedAddonPrincipal()), - true, aReflector); + nsJSPrincipals::get(mWorkerPrivate->GetPrincipal()), true, aReflector); } void SharedWorkerGlobalScope::Close() { @@ -1125,9 +1120,7 @@ bool ServiceWorkerGlobalScope::WrapGlobalObject( return ServiceWorkerGlobalScope_Binding::Wrap( aCx, this, this, options, - new WorkerPrincipal(mWorkerPrivate->UsesSystemPrincipal() || - mWorkerPrivate->UsesAddonOrExpandedAddonPrincipal()), - true, aReflector); + nsJSPrincipals::get(mWorkerPrivate->GetPrincipal()), true, aReflector); } already_AddRefed ServiceWorkerGlobalScope::GetClients() { @@ -1252,9 +1245,7 @@ bool WorkerDebuggerGlobalScope::WrapGlobalObject( return WorkerDebuggerGlobalScope_Binding::Wrap( aCx, this, this, options, - new WorkerPrincipal(mWorkerPrivate->UsesSystemPrincipal() || - mWorkerPrivate->UsesAddonOrExpandedAddonPrincipal()), - true, aReflector); + nsJSPrincipals::get(mWorkerPrivate->GetPrincipal()), true, aReflector); } void WorkerDebuggerGlobalScope::GetGlobal(JSContext* aCx, diff --git a/dom/workers/moz.build b/dom/workers/moz.build index bba7ca509b21..b2f9fd803ad6 100644 --- a/dom/workers/moz.build +++ b/dom/workers/moz.build @@ -50,7 +50,6 @@ UNIFIED_SOURCES += [ "ChromeWorkerScope.cpp", "JSExecutionManager.cpp", "MessageEventRunnable.cpp", - "Principal.cpp", "RegisterBindings.cpp", "RuntimeService.cpp", "ScriptLoader.cpp", diff --git a/dom/worklet/WorkletPrincipals.cpp b/dom/worklet/WorkletPrincipals.cpp deleted file mode 100644 index 36905c40af64..000000000000 --- a/dom/worklet/WorkletPrincipals.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "WorkletPrincipals.h" - -#include "mozilla/dom/WorkletImpl.h" -#include "nsJSPrincipals.h" - -namespace mozilla::dom { - -WorkletPrincipals::WorkletPrincipals(WorkletImpl* aWorkletImpl) - : JSPrincipals(), mWorkletImpl(aWorkletImpl) { - setDebugToken(kJSPrincipalsDebugToken); -} - -WorkletPrincipals::~WorkletPrincipals() = default; - -bool WorkletPrincipals::write(JSContext* aCx, - JSStructuredCloneWriter* aWriter) { - // This is a serialization of the NullPrincipal corresponding to the worklet - // environment settings object for the WorkletGlobalScope. - // https://drafts.css-houdini.org/worklets/#set-up-a-worklet-environment-settings-object - return nsJSPrincipals::WritePrincipalInfo(aWriter, - mWorkletImpl->PrincipalInfo()); -} - -bool WorkletPrincipals::isSystemOrAddonPrincipal() { - // Per Bug 1578623 rev a83797ed249c - Worklets are always NullPrincipal - return false; -} - -void WorkletPrincipals::Destroy(JSPrincipals* aPrincipals) { - delete static_cast(aPrincipals); -} - -} // namespace mozilla::dom diff --git a/dom/worklet/WorkletPrincipals.h b/dom/worklet/WorkletPrincipals.h deleted file mode 100644 index a5132c04cb32..000000000000 --- a/dom/worklet/WorkletPrincipals.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef DOM_WORKLET_WORKLETPRINCIPALS_H_ -#define DOM_WORKLET_WORKLETPRINCIPALS_H_ - -#include "js/Principals.h" -#include "mozilla/RefPtr.h" - -namespace mozilla { - -class WorkletImpl; - -namespace dom { - -struct MOZ_HEAP_CLASS WorkletPrincipals final : public JSPrincipals { - // A new WorkletPrincipals has refcount zero. - explicit WorkletPrincipals(WorkletImpl* aWorkletImpl); - - bool write(JSContext* aCx, JSStructuredCloneWriter* aWriter) override; - - bool isSystemOrAddonPrincipal() override; - - // Callback for JS_InitDestroyPrincipalsCallback() - static void Destroy(JSPrincipals* aPrincipals); - - static const uint32_t kJSPrincipalsDebugToken = 0x7e2df9f4; - - private: - ~WorkletPrincipals(); - RefPtr mWorkletImpl; -}; - -} // namespace dom -} // namespace mozilla - -#endif // DOM_WORKLET_WORKLETPRINCIPALS_H_ diff --git a/dom/worklet/WorkletThread.cpp b/dom/worklet/WorkletThread.cpp index a9268f05dfcc..749bc1a1509e 100644 --- a/dom/worklet/WorkletThread.cpp +++ b/dom/worklet/WorkletThread.cpp @@ -9,9 +9,9 @@ #include "nsContentUtils.h" #include "nsCycleCollector.h" #include "nsJSEnvironment.h" +#include "nsJSPrincipals.h" #include "mozilla/dom/AtomList.h" #include "mozilla/dom/WorkletGlobalScope.h" -#include "mozilla/dom/WorkletPrincipals.h" #include "mozilla/ipc/BackgroundChild.h" #include "mozilla/Attributes.h" #include "mozilla/CycleCollectedJSRuntime.h" @@ -136,7 +136,7 @@ class WorkletJSContext final : public CycleCollectedJSContext { JSContext* cx = Context(); js::SetPreserveWrapperCallbacks(cx, PreserveWrapper, HasReleasedWrapper); - JS_InitDestroyPrincipalsCallback(cx, WorkletPrincipals::Destroy); + JS_InitDestroyPrincipalsCallback(cx, nsJSPrincipals::Destroy); JS_SetWrapObjectCallbacks(cx, &WrapObjectCallbacks); JS_SetFutexCanWait(cx); diff --git a/dom/worklet/moz.build b/dom/worklet/moz.build index 706921ff53ee..4a351f7172f9 100644 --- a/dom/worklet/moz.build +++ b/dom/worklet/moz.build @@ -11,7 +11,6 @@ EXPORTS.mozilla.dom += [ "Worklet.h", "WorkletGlobalScope.h", "WorkletImpl.h", - "WorkletPrincipals.h", "WorkletThread.h", ] @@ -19,7 +18,6 @@ UNIFIED_SOURCES += [ "Worklet.cpp", "WorkletGlobalScope.cpp", "WorkletImpl.cpp", - "WorkletPrincipals.cpp", "WorkletThread.cpp", ] diff --git a/layout/style/PaintWorkletGlobalScope.cpp b/layout/style/PaintWorkletGlobalScope.cpp index 525a5d1d2a5f..ec4e1d264006 100644 --- a/layout/style/PaintWorkletGlobalScope.cpp +++ b/layout/style/PaintWorkletGlobalScope.cpp @@ -6,7 +6,6 @@ #include "PaintWorkletGlobalScope.h" -#include "mozilla/dom/WorkletPrincipals.h" #include "mozilla/dom/PaintWorkletGlobalScopeBinding.h" #include "mozilla/dom/FunctionBinding.h" #include "PaintWorkletImpl.h" @@ -34,9 +33,9 @@ bool PaintWorkletGlobalScope::WrapGlobalObject( options.creationOptions().setDefineSharedArrayBufferConstructor( IsSharedMemoryAllowed()); - JS::AutoHoldPrincipals principals(aCx, new WorkletPrincipals(mImpl)); return PaintWorkletGlobalScope_Binding::Wrap( - aCx, this, this, options, principals.get(), true, aReflector); + aCx, this, this, options, nsJSPrincipals::get(mImpl->Principal()), true, + aReflector); } void PaintWorkletGlobalScope::RegisterPaint(const nsAString& aType, diff --git a/toolkit/components/extensions/webidl-api/ExtensionEventListener.cpp b/toolkit/components/extensions/webidl-api/ExtensionEventListener.cpp index 998b211513e6..0fe5c893143c 100644 --- a/toolkit/components/extensions/webidl-api/ExtensionEventListener.cpp +++ b/toolkit/components/extensions/webidl-api/ExtensionEventListener.cpp @@ -7,7 +7,6 @@ #include "ExtensionPort.h" #include "mozilla/dom/FunctionBinding.h" -#include "nsJSPrincipals.h" // nsJSPrincipals::AutoSetActiveWorkerPrincipal #include "nsThreadManager.h" // NS_IsMainThread namespace mozilla { @@ -652,18 +651,7 @@ void ExtensionListenerCallPromiseResultHandler::WorkerRunCallback( JS::Rooted jsvalue(cx); IgnoredErrorResult rv; - { - // Set the active worker principal while reading the result, - // needed to be sure to be able to successfully deserialize the - // SavedFrame part of a ClonedErrorHolder (in case that was the - // result stored in the StructuredCloneHolder). - Maybe set; - if (workerRef) { - set.emplace(workerRef->Private()->GetPrincipal()); - } - - resHolder->Read(global, cx, &jsvalue, rv); - } + resHolder->Read(global, cx, &jsvalue, rv); if (NS_WARN_IF(rv.Failed())) { promiseResult->MaybeReject(rv.StealNSResult());