Bug 1759163 - Add origin trial support for worklets. r=asuth

Move the trial getter to nsIGlobalObject, make every implementation
provide a reasonable value, and add a test.

Differential Revision: https://phabricator.services.mozilla.com/D140848
This commit is contained in:
Emilio Cobos Álvarez 2022-03-15 17:50:03 +00:00
Родитель 9c4f187966
Коммит 7961a431ef
25 изменённых файлов: 159 добавлений и 98 удалений

Просмотреть файл

@ -1625,6 +1625,10 @@ 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();

Просмотреть файл

@ -251,6 +251,7 @@ 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 {

Просмотреть файл

@ -1698,6 +1698,11 @@ 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;

Просмотреть файл

@ -231,6 +231,7 @@ 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(); }

Просмотреть файл

@ -12,6 +12,7 @@
#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"
@ -196,6 +197,9 @@ 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();

Просмотреть файл

@ -20,8 +20,7 @@
#include "nsISupportsImpl.h"
#include "nsCycleCollectionParticipant.h"
namespace mozilla {
namespace dom {
namespace mozilla::dom {
class SimpleGlobalObject : public nsIGlobalObject, public nsWrapperCache {
public:
@ -67,8 +66,10 @@ class SimpleGlobalObject : public nsIGlobalObject, public nsWrapperCache {
return GetWrapperPreserveColor();
}
virtual JSObject* WrapObject(JSContext* cx,
JS::Handle<JSObject*> aGivenProto) override {
OriginTrials Trials() const override { return {}; }
JSObject* WrapObject(JSContext* cx,
JS::Handle<JSObject*> aGivenProto) override {
MOZ_CRASH("SimpleGlobalObject doesn't use DOM bindings!");
}
@ -82,7 +83,6 @@ class SimpleGlobalObject : public nsIGlobalObject, public nsWrapperCache {
const GlobalType mType;
};
} // namespace dom
} // namespace mozilla
} // namespace mozilla::dom
#endif /* mozilla_dom_SimpleGlobalObject_h__ */

Просмотреть файл

@ -35,15 +35,17 @@ NS_IMPL_ADDREF_INHERITED(AudioWorkletGlobalScope, WorkletGlobalScope)
NS_IMPL_RELEASE_INHERITED(AudioWorkletGlobalScope, WorkletGlobalScope)
AudioWorkletGlobalScope::AudioWorkletGlobalScope(AudioWorkletImpl* aImpl)
: WorkletGlobalScope(aImpl->GetAgentClusterId(),
aImpl->IsSharedMemoryAllowed()),
mImpl(aImpl) {}
: WorkletGlobalScope(aImpl) {}
AudioWorkletImpl* AudioWorkletGlobalScope::Impl() const {
return static_cast<AudioWorkletImpl*>(mImpl.get());
}
bool AudioWorkletGlobalScope::WrapGlobalObject(
JSContext* aCx, JS::MutableHandle<JSObject*> 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.
mImpl->DestinationTrack()->Graph()->NotifyJSContext(aCx);
Impl()->DestinationTrack()->Graph()->NotifyJSContext(aCx);
JS::RealmOptions options;
@ -189,7 +191,8 @@ void AudioWorkletGlobalScope::RegisterProcessor(
*/
NS_DispatchToMainThread(NS_NewRunnableFunction(
"AudioWorkletGlobalScope: parameter descriptors",
[impl = mImpl, name = nsString(aName), map = std::move(map)]() mutable {
[impl = RefPtr{Impl()}, name = nsString(aName),
map = std::move(map)]() mutable {
AudioNode* destinationNode =
impl->DestinationTrack()->Engine()->NodeMainThread();
if (!destinationNode) {
@ -199,10 +202,8 @@ void AudioWorkletGlobalScope::RegisterProcessor(
}));
}
WorkletImpl* AudioWorkletGlobalScope::Impl() const { return mImpl; }
uint64_t AudioWorkletGlobalScope::CurrentFrame() const {
AudioNodeTrack* destinationTrack = mImpl->DestinationTrack();
AudioNodeTrack* destinationTrack = Impl()->DestinationTrack();
GraphTime processedTime = destinationTrack->Graph()->ProcessedTime();
return destinationTrack->GraphTimeToTrackTime(processedTime);
}
@ -212,7 +213,7 @@ double AudioWorkletGlobalScope::CurrentTime() const {
}
float AudioWorkletGlobalScope::SampleRate() const {
return static_cast<float>(mImpl->DestinationTrack()->mSampleRate);
return static_cast<float>(Impl()->DestinationTrack()->mSampleRate);
}
AudioParamDescriptorMap AudioWorkletGlobalScope::DescriptorsFromJS(

Просмотреть файл

@ -39,7 +39,7 @@ class AudioWorkletGlobalScope final : public WorkletGlobalScope {
AudioWorkletProcessorConstructor& aProcessorCtor,
ErrorResult& aRv);
WorkletImpl* Impl() const override;
AudioWorkletImpl* Impl() const;
uint64_t CurrentFrame() const;
@ -69,8 +69,6 @@ class AudioWorkletGlobalScope final : public WorkletGlobalScope {
JS::ForOfIterator* aIter,
ErrorResult& aRv);
const RefPtr<AudioWorkletImpl> mImpl;
typedef nsRefPtrHashtable<nsStringHashKey, AudioWorkletProcessorConstructor>
NodeNameToProcessorDefinitionMap;
NodeNameToProcessorDefinitionMap mNameToProcessorMap;

Просмотреть файл

@ -159,18 +159,9 @@ bool OriginTrials::IsEnabled(JSContext* aCx, JSObject* aObject,
return true;
}
LOG("OriginTrials::IsEnabled(%d)\n", int(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);
nsIGlobalObject* global = xpc::CurrentNativeGlobal(aCx);
MOZ_ASSERT(global);
return global && global->Trials().IsEnabled(aTrial);
}
#undef LOG

Просмотреть файл

@ -1,23 +1,48 @@
/* 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: !!self.TestTrialInterface });
port.postMessage({
testTrialInterfaceExposed: !!globalThis.TestTrialInterface,
});
}
if (
self.SharedWorkerGlobalScope &&
self instanceof self.SharedWorkerGlobalScope
globalThis.SharedWorkerGlobalScope &&
globalThis instanceof globalThis.SharedWorkerGlobalScope
) {
self.addEventListener("connect", function(e) {
globalThis.addEventListener("connect", function(e) {
const port = e.ports[0];
workerReply(port);
});
} else if (self.WorkerGlobalScope && self instanceof self.WorkerGlobalScope) {
self.addEventListener("message", workerReply(self));
} 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);
}
function assertTestTrialActive(shouldBeActive) {
add_task(async function() {
info("Main thread test: " + document.URL);
is(
!!navigator.testTrialGatedAttribute,
shouldBeActive,
@ -35,48 +60,54 @@ function assertTestTrialActive(shouldBeActive) {
);
}
{
const worker = new Worker("common.js");
await new Promise(resolve => {
worker.addEventListener(
function promiseWorkerWorkletMessage(target, context) {
info(`promiseWorkerWorkletMessage(${context})`);
return new Promise(resolve => {
target.addEventListener(
"message",
function(e) {
is(
e.data.testTrialInterfaceExposed,
shouldBeActive,
"Should work as expected in workers"
"Should work as expected in " + context
);
info(`got ${context} message`);
resolve();
},
{ once: true }
);
worker.postMessage("ping");
});
}
{
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 = new Promise(resolve => {
worker.port.addEventListener(
"message",
function(e) {
is(
e.data.testTrialInterfaceExposed,
shouldBeActive,
"Should work as expected in shared workers"
);
resolve();
},
{ once: true }
);
});
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).
});

Просмотреть файл

@ -7,8 +7,11 @@ 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]

Просмотреть файл

@ -1,6 +1,6 @@
<!doctype html>
<!-- Created with: mktoken --origin 'http://mochi.test:8888' --feature TestTrial --expiry 'Wed, 01 Jan 2000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 -->
<meta http-equiv="origin-trial" content="A4GPgfKWSUlgUucdY2ESQAuu8pNiChJxAf+cf5KEe5O3OZNrHW4DuGdjzZShUhEwWZ3m30BaoBYnVSPCXNrQRSMAAABMeyJvcmlnaW4iOiJodHRwOi8vbW9jaGkudGVzdDo4ODg4IiwiZmVhdHVyZSI6IlRlc3RUcmlhbCIsImV4cGlyeSI6OTQ2Njg0ODAwfQ==">
<!-- Created with: mktoken --origin 'https://example.com' --feature TestTrial --expiry '01 Jan 2000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 -->
<meta http-equiv="origin-trial" content="A41+wSMhPQeR9B+AofdiFzheyZVF+gP4ubTNzrt6v8Qcjv68j1eINNFCxVe5/vdy4cO9dGDkwd9eizsib70RgAQAAABJeyJvcmlnaW4iOiJodHRwczovL2V4YW1wbGUuY29tIiwiZmVhdHVyZSI6IlRlc3RUcmlhbCIsImV4cGlyeSI6OTQ2Njg0ODAwfQ==">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="common.js"></script>
<script>

Просмотреть файл

@ -1 +1 @@
Origin-Trial: Ax+NsjHu0gB7huPad279C/p0ENAZR3R5lXAtKx0YTLbNsFFoYFFgDqxjCP10AHezcyyPrNS+uHHO72QdJM3eqMYAAABOeyJvcmlnaW4iOiJodHRwOi8vbW9jaGkudGVzdDo4ODg4IiwiZmVhdHVyZSI6IlRlc3RUcmlhbCIsImV4cGlyeSI6MzI1MDM2ODAwMDB9
Origin-Trial: AyGdETIKWLLqe+chG57f74gZcjYSfbdYAapEq7DA49E6CmaYaPmaoXh/4tAe5XJJJdwwpFVal7hz/irC+Wvp1HgAAABLeyJvcmlnaW4iOiJodHRwczovL2V4YW1wbGUuY29tIiwiZmVhdHVyZSI6IlRlc3RUcmlhbCIsImV4cGlyeSI6MzI1MDM2ODAwMDB9

Просмотреть файл

@ -1,6 +1,6 @@
<!doctype html>
<!-- Created with: mktoken --origin 'http://mochi.test:8888' --feature TestTrial --expiry 'Wed, 01 Jan 3000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 -->
<meta http-equiv="origin-trial" content="Ax+NsjHu0gB7huPad279C/p0ENAZR3R5lXAtKx0YTLbNsFFoYFFgDqxjCP10AHezcyyPrNS+uHHO72QdJM3eqMYAAABOeyJvcmlnaW4iOiJodHRwOi8vbW9jaGkudGVzdDo4ODg4IiwiZmVhdHVyZSI6IlRlc3RUcmlhbCIsImV4cGlyeSI6MzI1MDM2ODAwMDB9">
<!-- Created with: mktoken --origin 'https://example.com' --feature TestTrial --expiry 'Wed, 01 Jan 3000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 -->
<meta http-equiv="origin-trial" content="AyGdETIKWLLqe+chG57f74gZcjYSfbdYAapEq7DA49E6CmaYaPmaoXh/4tAe5XJJJdwwpFVal7hz/irC+Wvp1HgAAABLeyJvcmlnaW4iOiJodHRwczovL2V4YW1wbGUuY29tIiwiZmVhdHVyZSI6IlRlc3RUcmlhbCIsImV4cGlyeSI6MzI1MDM2ODAwMDB9">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="common.js"></script>
<script>

Просмотреть файл

@ -0,0 +1,8 @@
<!doctype html>
<!-- Created with: mktoken --origin 'https://not-example.com' --feature TestTrial --expiry '01 Jan 3000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 -->
<meta http-equiv="origin-trial" content="A1nUsa3CwtYj28syX2jYUogdrg+ZsjjNfAvmdg3SGybXxaJFbNq7i8AmY6Fo3OUe6Xvza3R0YYfaGTqM0TOU2OAAAABPeyJvcmlnaW4iOiJodHRwczovL25vdC1leGFtcGxlLmNvbSIsImZlYXR1cmUiOiJUZXN0VHJpYWwiLCJleHBpcnkiOjMyNTAzNjgwMDAwfQ==">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="common.js"></script>
<script>
assertTestTrialActive(false);
</script>

Просмотреть файл

@ -275,6 +275,11 @@ 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();

Просмотреть файл

@ -116,6 +116,8 @@ class WorkerGlobalScopeBase : public DOMEventTargetHelper,
uint32_t GetPrincipalHashValue() const final;
OriginTrials Trials() const final;
StorageAccess GetStorageAccess() final;
Maybe<ClientInfo> GetClientInfo() const final;

Просмотреть файл

@ -38,11 +38,8 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WorkletGlobalScope)
NS_INTERFACE_MAP_ENTRY(WorkletGlobalScope)
NS_INTERFACE_MAP_END
WorkletGlobalScope::WorkletGlobalScope(const Maybe<nsID>& aAgentClusterId,
bool aSharedMemoryAllowed)
: mCreationTimeStamp(TimeStamp::Now()),
mAgentClusterId(aAgentClusterId),
mSharedMemoryAllowed(aSharedMemoryAllowed) {}
WorkletGlobalScope::WorkletGlobalScope(WorkletImpl* aImpl)
: mImpl(aImpl), mCreationTimeStamp(TimeStamp::Now()) {}
WorkletGlobalScope::~WorkletGlobalScope() = default;
@ -68,6 +65,16 @@ already_AddRefed<Console> WorkletGlobalScope::GetConsole(JSContext* aCx,
return console.forget();
}
OriginTrials WorkletGlobalScope::Trials() const { return mImpl->Trials(); }
Maybe<nsID> WorkletGlobalScope::GetAgentClusterId() const {
return mImpl->GetAgentClusterId();
}
bool WorkletGlobalScope::IsSharedMemoryAllowed() const {
return mImpl->IsSharedMemoryAllowed();
}
void WorkletGlobalScope::Dump(const Optional<nsAString>& aString) const {
WorkletThread::AssertIsOnWorkletThread();

Просмотреть файл

@ -38,8 +38,7 @@ class WorkletGlobalScope : public nsIGlobalObject, public nsWrapperCache {
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WorkletGlobalScope)
WorkletGlobalScope(const Maybe<nsID>& aAgentClusterId,
bool aSharedMemoryAllowed);
WorkletGlobalScope(WorkletImpl*);
nsIGlobalObject* GetParentObject() const { return nullptr; }
@ -56,7 +55,7 @@ class WorkletGlobalScope : public nsIGlobalObject, public nsWrapperCache {
already_AddRefed<Console> GetConsole(JSContext* aCx, ErrorResult& aRv);
virtual WorkletImpl* Impl() const = 0;
WorkletImpl* Impl() const { return mImpl.get(); }
void Dump(const Optional<nsAString>& aString) const;
@ -66,19 +65,17 @@ class WorkletGlobalScope : public nsIGlobalObject, public nsWrapperCache {
return duration.ToMilliseconds();
}
Maybe<nsID> GetAgentClusterId() const override { return mAgentClusterId; }
bool IsSharedMemoryAllowed() const override { return mSharedMemoryAllowed; }
OriginTrials Trials() const override;
Maybe<nsID> GetAgentClusterId() const override;
bool IsSharedMemoryAllowed() const override;
protected:
~WorkletGlobalScope();
;
const RefPtr<WorkletImpl> mImpl;
private:
TimeStamp mCreationTimeStamp;
Maybe<nsID> mAgentClusterId;
RefPtr<Console> mConsole;
bool mSharedMemoryAllowed;
};
NS_DEFINE_STATIC_IID_ACCESSOR(WorkletGlobalScope, WORKLET_IID)

Просмотреть файл

@ -41,7 +41,8 @@ WorkletImpl::WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal)
: mPrincipal(NullPrincipal::CreateWithInheritedAttributes(aPrincipal)),
mWorkletLoadInfo(aWindow),
mTerminated(false),
mFinishedOnExecutionThread(false) {
mFinishedOnExecutionThread(false),
mTrials(OriginTrials::FromWindow(nsGlobalWindowInner::Cast(aWindow))) {
Unused << NS_WARN_IF(
NS_FAILED(ipc::PrincipalToPrincipalInfo(mPrincipal, &mPrincipalInfo)));

Просмотреть файл

@ -10,6 +10,7 @@
#include "MainThreadUtils.h"
#include "mozilla/Maybe.h"
#include "mozilla/OriginAttributes.h"
#include "mozilla/OriginTrials.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
class nsPIDOMWindowInner;
@ -71,6 +72,7 @@ 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();
@ -115,6 +117,8 @@ class WorkletImpl {
Maybe<nsID> mAgentClusterId;
bool mSharedMemoryAllowed;
const OriginTrials mTrials;
};
} // namespace mozilla

Просмотреть файл

@ -18,11 +18,11 @@
class XPCWrappedNative;
class BackstagePass : public nsIGlobalObject,
public nsIScriptObjectPrincipal,
public nsIXPCScriptable,
public nsIClassInfo,
public nsSupportsWeakReference {
class BackstagePass final : public nsIGlobalObject,
public nsIScriptObjectPrincipal,
public nsIXPCScriptable,
public nsIClassInfo,
public nsSupportsWeakReference {
public:
BackstagePass();
@ -30,13 +30,13 @@ class BackstagePass : public nsIGlobalObject,
NS_DECL_NSIXPCSCRIPTABLE
NS_DECL_NSICLASSINFO
virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
nsIPrincipal* GetPrincipal() override { return mPrincipal; }
virtual nsIPrincipal* GetEffectiveStoragePrincipal() override {
return mPrincipal;
}
nsIPrincipal* GetEffectiveStoragePrincipal() override { return mPrincipal; }
virtual nsIPrincipal* PartitionedPrincipal() override { return mPrincipal; }
nsIPrincipal* PartitionedPrincipal() override { return mPrincipal; }
mozilla::OriginTrials Trials() const override { return {}; }
JSObject* GetGlobalJSObject() override;
JSObject* GetGlobalJSObjectPreserveColor() const override;

Просмотреть файл

@ -49,6 +49,8 @@ class SandboxPrivate : public nsIGlobalObject,
return static_cast<SandboxPrivate*>(sop);
}
mozilla::OriginTrials Trials() const final { return {}; }
nsIPrincipal* GetPrincipal() override { return mPrincipal; }
nsIPrincipal* GetEffectiveStoragePrincipal() override { return mPrincipal; }

Просмотреть файл

@ -11,13 +11,14 @@
#include "mozilla/dom/FunctionBinding.h"
#include "PaintWorkletImpl.h"
namespace mozilla {
namespace dom {
namespace mozilla::dom {
PaintWorkletGlobalScope::PaintWorkletGlobalScope(PaintWorkletImpl* aImpl)
: WorkletGlobalScope(aImpl->GetAgentClusterId(),
aImpl->IsSharedMemoryAllowed()),
mImpl(aImpl) {}
: WorkletGlobalScope(aImpl) {}
PaintWorkletImpl* PaintWorkletGlobalScope::Impl() const {
return static_cast<PaintWorkletImpl*>(mImpl.get());
}
bool PaintWorkletGlobalScope::WrapGlobalObject(
JSContext* aCx, JS::MutableHandle<JSObject*> aReflector) {
@ -40,7 +41,4 @@ void PaintWorkletGlobalScope::RegisterPaint(const nsAString& aType,
// Nothing to do here, yet.
}
WorkletImpl* PaintWorkletGlobalScope::Impl() const { return mImpl; }
} // namespace dom
} // namespace mozilla
} // namespace mozilla::dom

Просмотреть файл

@ -26,12 +26,10 @@ class PaintWorkletGlobalScope final : public WorkletGlobalScope {
void RegisterPaint(const nsAString& aType, VoidFunction& aProcessorCtor);
WorkletImpl* Impl() const override;
PaintWorkletImpl* Impl() const;
private:
~PaintWorkletGlobalScope() = default;
const RefPtr<PaintWorkletImpl> mImpl;
};
} // namespace dom