diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index cf1e639a0f01..48974006615c 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -1625,10 +1625,6 @@ bool nsGlobalWindowInner::ShouldResistFingerprinting() const { return nsIScriptGlobalObject::ShouldResistFingerprinting(); } -OriginTrials nsGlobalWindowInner::Trials() const { - return OriginTrials::FromWindow(this); -} - uint32_t nsGlobalWindowInner::GetPrincipalHashValue() const { if (mDoc) { return mDoc->NodePrincipal()->GetHashValue(); diff --git a/dom/base/nsGlobalWindowInner.h b/dom/base/nsGlobalWindowInner.h index 4b13e05f255d..e916a553d016 100644 --- a/dom/base/nsGlobalWindowInner.h +++ b/dom/base/nsGlobalWindowInner.h @@ -251,7 +251,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, // nsIGlobalObject bool ShouldResistFingerprinting() const final; uint32_t GetPrincipalHashValue() const final; - mozilla::OriginTrials Trials() const final; JSObject* GetGlobalJSObject() final { return GetWrapper(); } JSObject* GetGlobalJSObjectPreserveColor() const final { diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index d7a01da2c5cd..25253594da31 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -1698,11 +1698,6 @@ uint32_t nsGlobalWindowOuter::GetPrincipalHashValue() const { return 0; } -OriginTrials nsGlobalWindowOuter::Trials() const { - return mInnerWindow ? nsGlobalWindowInner::Cast(mInnerWindow)->Trials() - : OriginTrials(); -} - nsresult nsGlobalWindowOuter::EnsureScriptEnvironment() { if (GetWrapperPreserveColor()) { return NS_OK; diff --git a/dom/base/nsGlobalWindowOuter.h b/dom/base/nsGlobalWindowOuter.h index ab3a63025e19..b1789133f4ac 100644 --- a/dom/base/nsGlobalWindowOuter.h +++ b/dom/base/nsGlobalWindowOuter.h @@ -231,7 +231,6 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget, // nsIGlobalObject bool ShouldResistFingerprinting() const final; uint32_t GetPrincipalHashValue() const final; - mozilla::OriginTrials Trials() const final; // nsIGlobalJSObjectHolder JSObject* GetGlobalJSObject() final { return GetWrapper(); } diff --git a/dom/base/nsIGlobalObject.h b/dom/base/nsIGlobalObject.h index ec739aa4cd4b..fa486deb5fc5 100644 --- a/dom/base/nsIGlobalObject.h +++ b/dom/base/nsIGlobalObject.h @@ -12,7 +12,6 @@ #include "mozilla/dom/ClientInfo.h" #include "mozilla/dom/DispatcherTrait.h" #include "mozilla/dom/ServiceWorkerDescriptor.h" -#include "mozilla/OriginTrials.h" #include "nsHashKeys.h" #include "nsISupports.h" #include "nsStringFwd.h" @@ -197,9 +196,6 @@ class nsIGlobalObject : public nsISupports, */ virtual mozilla::StorageAccess GetStorageAccess(); - // Returns the set of active origin trials for this global. - virtual mozilla::OriginTrials Trials() const = 0; - // Returns a pointer to this object as an inner window if this is one or // nullptr otherwise. nsPIDOMWindowInner* AsInnerWindow(); diff --git a/dom/bindings/SimpleGlobalObject.h b/dom/bindings/SimpleGlobalObject.h index 6f58747e9ae4..55931fcad3de 100644 --- a/dom/bindings/SimpleGlobalObject.h +++ b/dom/bindings/SimpleGlobalObject.h @@ -20,7 +20,8 @@ #include "nsISupportsImpl.h" #include "nsCycleCollectionParticipant.h" -namespace mozilla::dom { +namespace mozilla { +namespace dom { class SimpleGlobalObject : public nsIGlobalObject, public nsWrapperCache { public: @@ -66,10 +67,8 @@ class SimpleGlobalObject : public nsIGlobalObject, public nsWrapperCache { return GetWrapperPreserveColor(); } - OriginTrials Trials() const override { return {}; } - - JSObject* WrapObject(JSContext* cx, - JS::Handle aGivenProto) override { + virtual JSObject* WrapObject(JSContext* cx, + JS::Handle aGivenProto) override { MOZ_CRASH("SimpleGlobalObject doesn't use DOM bindings!"); } @@ -83,6 +82,7 @@ class SimpleGlobalObject : public nsIGlobalObject, public nsWrapperCache { const GlobalType mType; }; -} // namespace mozilla::dom +} // namespace dom +} // namespace mozilla #endif /* mozilla_dom_SimpleGlobalObject_h__ */ diff --git a/dom/media/webaudio/AudioWorkletGlobalScope.cpp b/dom/media/webaudio/AudioWorkletGlobalScope.cpp index 7d7429f0dd53..0af72f945882 100644 --- a/dom/media/webaudio/AudioWorkletGlobalScope.cpp +++ b/dom/media/webaudio/AudioWorkletGlobalScope.cpp @@ -35,17 +35,15 @@ NS_IMPL_ADDREF_INHERITED(AudioWorkletGlobalScope, WorkletGlobalScope) NS_IMPL_RELEASE_INHERITED(AudioWorkletGlobalScope, WorkletGlobalScope) AudioWorkletGlobalScope::AudioWorkletGlobalScope(AudioWorkletImpl* aImpl) - : WorkletGlobalScope(aImpl) {} - -AudioWorkletImpl* AudioWorkletGlobalScope::Impl() const { - return static_cast(mImpl.get()); -} + : WorkletGlobalScope(aImpl->GetAgentClusterId(), + aImpl->IsSharedMemoryAllowed()), + mImpl(aImpl) {} bool AudioWorkletGlobalScope::WrapGlobalObject( JSContext* aCx, JS::MutableHandle aReflector) { // |this| is being exposed to JS and content script will soon be running. // The graph needs a handle on the JSContext so it can interrupt JS. - Impl()->DestinationTrack()->Graph()->NotifyJSContext(aCx); + mImpl->DestinationTrack()->Graph()->NotifyJSContext(aCx); JS::RealmOptions options; @@ -191,8 +189,7 @@ void AudioWorkletGlobalScope::RegisterProcessor( */ NS_DispatchToMainThread(NS_NewRunnableFunction( "AudioWorkletGlobalScope: parameter descriptors", - [impl = RefPtr{Impl()}, name = nsString(aName), - map = std::move(map)]() mutable { + [impl = mImpl, name = nsString(aName), map = std::move(map)]() mutable { AudioNode* destinationNode = impl->DestinationTrack()->Engine()->NodeMainThread(); if (!destinationNode) { @@ -202,8 +199,10 @@ void AudioWorkletGlobalScope::RegisterProcessor( })); } +WorkletImpl* AudioWorkletGlobalScope::Impl() const { return mImpl; } + uint64_t AudioWorkletGlobalScope::CurrentFrame() const { - AudioNodeTrack* destinationTrack = Impl()->DestinationTrack(); + AudioNodeTrack* destinationTrack = mImpl->DestinationTrack(); GraphTime processedTime = destinationTrack->Graph()->ProcessedTime(); return destinationTrack->GraphTimeToTrackTime(processedTime); } @@ -213,7 +212,7 @@ double AudioWorkletGlobalScope::CurrentTime() const { } float AudioWorkletGlobalScope::SampleRate() const { - return static_cast(Impl()->DestinationTrack()->mSampleRate); + return static_cast(mImpl->DestinationTrack()->mSampleRate); } AudioParamDescriptorMap AudioWorkletGlobalScope::DescriptorsFromJS( diff --git a/dom/media/webaudio/AudioWorkletGlobalScope.h b/dom/media/webaudio/AudioWorkletGlobalScope.h index faaa731fa6bd..8de6b9332c45 100644 --- a/dom/media/webaudio/AudioWorkletGlobalScope.h +++ b/dom/media/webaudio/AudioWorkletGlobalScope.h @@ -39,7 +39,7 @@ class AudioWorkletGlobalScope final : public WorkletGlobalScope { AudioWorkletProcessorConstructor& aProcessorCtor, ErrorResult& aRv); - AudioWorkletImpl* Impl() const; + WorkletImpl* Impl() const override; uint64_t CurrentFrame() const; @@ -69,6 +69,8 @@ class AudioWorkletGlobalScope final : public WorkletGlobalScope { JS::ForOfIterator* aIter, ErrorResult& aRv); + const RefPtr mImpl; + typedef nsRefPtrHashtable NodeNameToProcessorDefinitionMap; NodeNameToProcessorDefinitionMap mNameToProcessorMap; diff --git a/dom/origin-trials/OriginTrials.cpp b/dom/origin-trials/OriginTrials.cpp index c9ccf8dbbefd..299b33c28c6d 100644 --- a/dom/origin-trials/OriginTrials.cpp +++ b/dom/origin-trials/OriginTrials.cpp @@ -159,9 +159,18 @@ bool OriginTrials::IsEnabled(JSContext* aCx, JSObject* aObject, return true; } LOG("OriginTrials::IsEnabled(%d)\n", int(aTrial)); - nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx); - MOZ_ASSERT(global); - return global && global->Trials().IsEnabled(aTrial); + + if (dom::WorkletThread::IsOnWorkletThread()) { + // TODO: Worklet support, clean up the assumption below than not main thread + // means worker. + return false; + } + + const OriginTrials trials = + NS_IsMainThread() + ? FromWindow(xpc::WindowGlobalOrNull(js::UncheckedUnwrap(aObject))) + : dom::GetWorkerPrivateFromContext(aCx)->Trials(); + return trials.IsEnabled(aTrial); } #undef LOG diff --git a/dom/origin-trials/tests/common.js b/dom/origin-trials/tests/common.js index 116a116e36ee..c0aa5c9c0340 100644 --- a/dom/origin-trials/tests/common.js +++ b/dom/origin-trials/tests/common.js @@ -1,48 +1,23 @@ /* import-globals-from ../../../testing/mochitest/tests/SimpleTest/SimpleTest.js */ -// This would be a bit nicer with `self`, but Worklet doesn't have that, so -// `globalThis` it is, see https://github.com/whatwg/html/issues/7696 function workerReply(port) { - port.postMessage({ - testTrialInterfaceExposed: !!globalThis.TestTrialInterface, - }); + port.postMessage({ testTrialInterfaceExposed: !!self.TestTrialInterface }); } if ( - globalThis.SharedWorkerGlobalScope && - globalThis instanceof globalThis.SharedWorkerGlobalScope + self.SharedWorkerGlobalScope && + self instanceof self.SharedWorkerGlobalScope ) { - globalThis.addEventListener("connect", function(e) { + self.addEventListener("connect", function(e) { const port = e.ports[0]; workerReply(port); }); -} else if ( - globalThis.WorkerGlobalScope && - globalThis instanceof globalThis.WorkerGlobalScope -) { - workerReply(globalThis); -} else if ( - globalThis.WorkletGlobalScope && - globalThis instanceof globalThis.WorkletGlobalScope -) { - class Processor extends AudioWorkletProcessor { - constructor() { - super(); - this.port.start(); - workerReply(this.port); - } - - process(inputs, outputs, parameters) { - // Do nothing, output silence - return true; - } - } - registerProcessor("test-processor", Processor); +} else if (self.WorkerGlobalScope && self instanceof self.WorkerGlobalScope) { + self.addEventListener("message", workerReply(self)); } function assertTestTrialActive(shouldBeActive) { add_task(async function() { - info("Main thread test: " + document.URL); is( !!navigator.testTrialGatedAttribute, shouldBeActive, @@ -60,54 +35,48 @@ function assertTestTrialActive(shouldBeActive) { ); } - function promiseWorkerWorkletMessage(target, context) { - info(`promiseWorkerWorkletMessage(${context})`); - return new Promise(resolve => { - target.addEventListener( + { + const worker = new Worker("common.js"); + await new Promise(resolve => { + worker.addEventListener( "message", function(e) { is( e.data.testTrialInterfaceExposed, shouldBeActive, - "Should work as expected in " + context + "Should work as expected in workers" + ); + resolve(); + }, + { once: true } + ); + worker.postMessage("ping"); + }); + worker.terminate(); + } + + { + // We want a unique worker per page since the trial state depends on the + // creator document. + const worker = new SharedWorker("common.js", document.URL); + const promise = new Promise(resolve => { + worker.port.addEventListener( + "message", + function(e) { + is( + e.data.testTrialInterfaceExposed, + shouldBeActive, + "Should work as expected in shared workers" ); - info(`got ${context} message`); resolve(); }, { once: true } ); }); - } - - { - info("Worker test"); - const worker = new Worker("common.js"); - await promiseWorkerWorkletMessage(worker, "worker"); - worker.terminate(); - } - - { - info("SharedWorker test"); - // We want a unique worker per page since the trial state depends on the - // creator document. - const worker = new SharedWorker("common.js", document.URL); - const promise = promiseWorkerWorkletMessage(worker.port, "shared worker"); worker.port.start(); await promise; } - { - info("AudioWorklet test"); - const audioContext = new AudioContext(); - await audioContext.audioWorklet.addModule("common.js"); - audioContext.resume(); - const workletNode = new AudioWorkletNode(audioContext, "test-processor"); - const promise = promiseWorkerWorkletMessage(workletNode.port, "worklet"); - workletNode.port.start(); - await promise; - await audioContext.close(); - } - // FIXME(emilio): Add more tests. // * Stuff hanging off Window or Document (bug 1757935). }); diff --git a/dom/origin-trials/tests/mochitest.ini b/dom/origin-trials/tests/mochitest.ini index ded0d6504440..ff5a5de0ffb9 100644 --- a/dom/origin-trials/tests/mochitest.ini +++ b/dom/origin-trials/tests/mochitest.ini @@ -7,11 +7,8 @@ support-files = common.js # Test interfaces only exposed on DEBUG builds. skip-if = !debug -# AudioWorklet requires secure context -scheme = https [test_meta_simple.html] [test_header_simple.html] [test_trial_hidden.html] [test_expired_token.html] -[test_wrong_origin.html] diff --git a/dom/origin-trials/tests/test_expired_token.html b/dom/origin-trials/tests/test_expired_token.html index 48bd4d1215c4..44780f6d8f77 100644 --- a/dom/origin-trials/tests/test_expired_token.html +++ b/dom/origin-trials/tests/test_expired_token.html @@ -1,6 +1,6 @@ - - + + - - diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index ce1267defe49..cae2f6efffc5 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -275,11 +275,6 @@ uint32_t WorkerGlobalScopeBase::GetPrincipalHashValue() const { return mWorkerPrivate->GetPrincipalHashValue(); } -OriginTrials WorkerGlobalScopeBase::Trials() const { - mWorkerPrivate->AssertIsOnWorkerThread(); - return mWorkerPrivate->Trials(); -} - StorageAccess WorkerGlobalScopeBase::GetStorageAccess() { mWorkerPrivate->AssertIsOnWorkerThread(); return mWorkerPrivate->StorageAccess(); diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h index 939d03cc15dc..2f6403eee7d1 100644 --- a/dom/workers/WorkerScope.h +++ b/dom/workers/WorkerScope.h @@ -116,8 +116,6 @@ class WorkerGlobalScopeBase : public DOMEventTargetHelper, uint32_t GetPrincipalHashValue() const final; - OriginTrials Trials() const final; - StorageAccess GetStorageAccess() final; Maybe GetClientInfo() const final; diff --git a/dom/worklet/WorkletGlobalScope.cpp b/dom/worklet/WorkletGlobalScope.cpp index fc1e90f8e13c..b6874f878778 100644 --- a/dom/worklet/WorkletGlobalScope.cpp +++ b/dom/worklet/WorkletGlobalScope.cpp @@ -38,8 +38,11 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WorkletGlobalScope) NS_INTERFACE_MAP_ENTRY(WorkletGlobalScope) NS_INTERFACE_MAP_END -WorkletGlobalScope::WorkletGlobalScope(WorkletImpl* aImpl) - : mImpl(aImpl), mCreationTimeStamp(TimeStamp::Now()) {} +WorkletGlobalScope::WorkletGlobalScope(const Maybe& aAgentClusterId, + bool aSharedMemoryAllowed) + : mCreationTimeStamp(TimeStamp::Now()), + mAgentClusterId(aAgentClusterId), + mSharedMemoryAllowed(aSharedMemoryAllowed) {} WorkletGlobalScope::~WorkletGlobalScope() = default; @@ -65,16 +68,6 @@ already_AddRefed WorkletGlobalScope::GetConsole(JSContext* aCx, return console.forget(); } -OriginTrials WorkletGlobalScope::Trials() const { return mImpl->Trials(); } - -Maybe WorkletGlobalScope::GetAgentClusterId() const { - return mImpl->GetAgentClusterId(); -} - -bool WorkletGlobalScope::IsSharedMemoryAllowed() const { - return mImpl->IsSharedMemoryAllowed(); -} - void WorkletGlobalScope::Dump(const Optional& aString) const { WorkletThread::AssertIsOnWorkletThread(); diff --git a/dom/worklet/WorkletGlobalScope.h b/dom/worklet/WorkletGlobalScope.h index 1e63f2c6707e..3f24415d424b 100644 --- a/dom/worklet/WorkletGlobalScope.h +++ b/dom/worklet/WorkletGlobalScope.h @@ -38,7 +38,8 @@ class WorkletGlobalScope : public nsIGlobalObject, public nsWrapperCache { NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WorkletGlobalScope) - WorkletGlobalScope(WorkletImpl*); + WorkletGlobalScope(const Maybe& aAgentClusterId, + bool aSharedMemoryAllowed); nsIGlobalObject* GetParentObject() const { return nullptr; } @@ -55,7 +56,7 @@ class WorkletGlobalScope : public nsIGlobalObject, public nsWrapperCache { already_AddRefed GetConsole(JSContext* aCx, ErrorResult& aRv); - WorkletImpl* Impl() const { return mImpl.get(); } + virtual WorkletImpl* Impl() const = 0; void Dump(const Optional& aString) const; @@ -65,17 +66,19 @@ class WorkletGlobalScope : public nsIGlobalObject, public nsWrapperCache { return duration.ToMilliseconds(); } - OriginTrials Trials() const override; - Maybe GetAgentClusterId() const override; - bool IsSharedMemoryAllowed() const override; + Maybe GetAgentClusterId() const override { return mAgentClusterId; } + + bool IsSharedMemoryAllowed() const override { return mSharedMemoryAllowed; } protected: ~WorkletGlobalScope(); + ; - const RefPtr mImpl; private: TimeStamp mCreationTimeStamp; + Maybe mAgentClusterId; RefPtr mConsole; + bool mSharedMemoryAllowed; }; NS_DEFINE_STATIC_IID_ACCESSOR(WorkletGlobalScope, WORKLET_IID) diff --git a/dom/worklet/WorkletImpl.cpp b/dom/worklet/WorkletImpl.cpp index cccc1d04aee7..8e6a70289d18 100644 --- a/dom/worklet/WorkletImpl.cpp +++ b/dom/worklet/WorkletImpl.cpp @@ -41,8 +41,7 @@ WorkletImpl::WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal) : mPrincipal(NullPrincipal::CreateWithInheritedAttributes(aPrincipal)), mWorkletLoadInfo(aWindow), mTerminated(false), - mFinishedOnExecutionThread(false), - mTrials(OriginTrials::FromWindow(nsGlobalWindowInner::Cast(aWindow))) { + mFinishedOnExecutionThread(false) { Unused << NS_WARN_IF( NS_FAILED(ipc::PrincipalToPrincipalInfo(mPrincipal, &mPrincipalInfo))); diff --git a/dom/worklet/WorkletImpl.h b/dom/worklet/WorkletImpl.h index 39bc9c46f4c3..2e7b790d6632 100644 --- a/dom/worklet/WorkletImpl.h +++ b/dom/worklet/WorkletImpl.h @@ -10,7 +10,6 @@ #include "MainThreadUtils.h" #include "mozilla/Maybe.h" #include "mozilla/OriginAttributes.h" -#include "mozilla/OriginTrials.h" #include "mozilla/ipc/PBackgroundSharedTypes.h" class nsPIDOMWindowInner; @@ -72,7 +71,6 @@ class WorkletImpl { // Any thread. - const OriginTrials& Trials() const { return mTrials; } const WorkletLoadInfo& LoadInfo() const { return mWorkletLoadInfo; } const OriginAttributes& OriginAttributesRef() const { return mPrincipalInfo.get_NullPrincipalInfo().attrs(); @@ -117,8 +115,6 @@ class WorkletImpl { Maybe mAgentClusterId; bool mSharedMemoryAllowed; - - const OriginTrials mTrials; }; } // namespace mozilla diff --git a/js/xpconnect/src/BackstagePass.h b/js/xpconnect/src/BackstagePass.h index b9f407800393..068ad08757e8 100644 --- a/js/xpconnect/src/BackstagePass.h +++ b/js/xpconnect/src/BackstagePass.h @@ -18,11 +18,11 @@ class XPCWrappedNative; -class BackstagePass final : public nsIGlobalObject, - public nsIScriptObjectPrincipal, - public nsIXPCScriptable, - public nsIClassInfo, - public nsSupportsWeakReference { +class BackstagePass : public nsIGlobalObject, + public nsIScriptObjectPrincipal, + public nsIXPCScriptable, + public nsIClassInfo, + public nsSupportsWeakReference { public: BackstagePass(); @@ -30,13 +30,13 @@ class BackstagePass final : public nsIGlobalObject, NS_DECL_NSIXPCSCRIPTABLE NS_DECL_NSICLASSINFO - nsIPrincipal* GetPrincipal() override { return mPrincipal; } + virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; } - nsIPrincipal* GetEffectiveStoragePrincipal() override { return mPrincipal; } + virtual nsIPrincipal* GetEffectiveStoragePrincipal() override { + return mPrincipal; + } - nsIPrincipal* PartitionedPrincipal() override { return mPrincipal; } - - mozilla::OriginTrials Trials() const override { return {}; } + virtual nsIPrincipal* PartitionedPrincipal() override { return mPrincipal; } JSObject* GetGlobalJSObject() override; JSObject* GetGlobalJSObjectPreserveColor() const override; diff --git a/js/xpconnect/src/SandboxPrivate.h b/js/xpconnect/src/SandboxPrivate.h index 245260558f0c..cf36c6ef2e93 100644 --- a/js/xpconnect/src/SandboxPrivate.h +++ b/js/xpconnect/src/SandboxPrivate.h @@ -49,8 +49,6 @@ class SandboxPrivate : public nsIGlobalObject, return static_cast(sop); } - mozilla::OriginTrials Trials() const final { return {}; } - nsIPrincipal* GetPrincipal() override { return mPrincipal; } nsIPrincipal* GetEffectiveStoragePrincipal() override { return mPrincipal; } diff --git a/layout/style/PaintWorkletGlobalScope.cpp b/layout/style/PaintWorkletGlobalScope.cpp index 22e251bd7da0..d59f20ce3aa7 100644 --- a/layout/style/PaintWorkletGlobalScope.cpp +++ b/layout/style/PaintWorkletGlobalScope.cpp @@ -11,14 +11,13 @@ #include "mozilla/dom/FunctionBinding.h" #include "PaintWorkletImpl.h" -namespace mozilla::dom { +namespace mozilla { +namespace dom { PaintWorkletGlobalScope::PaintWorkletGlobalScope(PaintWorkletImpl* aImpl) - : WorkletGlobalScope(aImpl) {} - -PaintWorkletImpl* PaintWorkletGlobalScope::Impl() const { - return static_cast(mImpl.get()); -} + : WorkletGlobalScope(aImpl->GetAgentClusterId(), + aImpl->IsSharedMemoryAllowed()), + mImpl(aImpl) {} bool PaintWorkletGlobalScope::WrapGlobalObject( JSContext* aCx, JS::MutableHandle aReflector) { @@ -41,4 +40,7 @@ void PaintWorkletGlobalScope::RegisterPaint(const nsAString& aType, // Nothing to do here, yet. } -} // namespace mozilla::dom +WorkletImpl* PaintWorkletGlobalScope::Impl() const { return mImpl; } + +} // namespace dom +} // namespace mozilla diff --git a/layout/style/PaintWorkletGlobalScope.h b/layout/style/PaintWorkletGlobalScope.h index 21858ba16ba6..7b7604eb3ba3 100644 --- a/layout/style/PaintWorkletGlobalScope.h +++ b/layout/style/PaintWorkletGlobalScope.h @@ -26,10 +26,12 @@ class PaintWorkletGlobalScope final : public WorkletGlobalScope { void RegisterPaint(const nsAString& aType, VoidFunction& aProcessorCtor); - PaintWorkletImpl* Impl() const; + WorkletImpl* Impl() const override; private: ~PaintWorkletGlobalScope() = default; + + const RefPtr mImpl; }; } // namespace dom