bool DedicatedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector) { mWorkerPrivate->AssertIsOnWorkerThread(); MOZ_ASSERT(!mWorkerPrivate->IsSharedWorker()); JS::CompartmentOptions options; mWorkerPrivate->CopyJSCompartmentOptions(options); const bool usesSystemPrincipal = mWorkerPrivate->UsesSystemPrincipal(); // Note that xpc::ShouldDiscardSystemSource() and // xpc::ExtraWarningsForSystemJS() read prefs that are cached on the main // thread. This is benignly racey. const bool discardSource = usesSystemPrincipal && xpc::ShouldDiscardSystemSource(); const bool extraWarnings = usesSystemPrincipal && xpc::ExtraWarningsForSystemJS(); JS::CompartmentBehaviors& behaviors = options.behaviors(); behaviors.setDiscardSource(discardSource) .extraWarningsOverride().set(extraWarnings); const bool sharedMemoryEnabled = xpc::SharedMemoryEnabled(); JS::CompartmentCreationOptions& creationOptions = options.creationOptions(); creationOptions.setSharedMemoryAndAtomicsEnabled(sharedMemoryEnabled); return DedicatedWorkerGlobalScopeBinding::Wrap(aCx, this, this, options, GetWorkerPrincipal(), true, aReflector); }
bool WorkerDebuggerGlobalScope::WrapGlobalObject( JSContext* aCx, JS::MutableHandle<JSObject*> aReflector) { mWorkerPrivate->AssertIsOnWorkerThread(); JS::RealmOptions options; mWorkerPrivate->CopyJSRealmOptions(options); return WorkerDebuggerGlobalScope_Binding::Wrap( aCx, this, this, options, GetWorkerPrincipal(), true, aReflector); }
bool ServiceWorkerGlobalScope::WrapGlobalObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector) { mWorkerPrivate->AssertIsOnWorkerThread(); MOZ_ASSERT(mWorkerPrivate->IsServiceWorker()); JS::CompartmentOptions options; mWorkerPrivate->CopyJSCompartmentOptions(options); return ServiceWorkerGlobalScopeBinding::Wrap(aCx, this, this, options, GetWorkerPrincipal(), true, aReflector); }