diff --git a/dom/base/DOMPreferences.cpp b/dom/base/DOMPreferences.cpp index 4e77bdb687b5..9f54832e4d5c 100644 --- a/dom/base/DOMPreferences.cpp +++ b/dom/base/DOMPreferences.cpp @@ -44,6 +44,7 @@ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.en PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled") PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled") PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled") +PREF(OpenWindowEnabled, "dom.serviceWorkers.openWindow.enabled") #undef PREF @@ -59,6 +60,7 @@ PREF_WEBIDL(DOMCachesEnabled) PREF_WEBIDL(NotificationEnabledInServiceWorkers) PREF_WEBIDL(NotificationRIEnabled) PREF_WEBIDL(ServiceWorkersEnabled) +PREF_WEBIDL(OpenWindowEnabled) #undef PREF_WEBIDL diff --git a/dom/base/DOMPreferences.h b/dom/base/DOMPreferences.h index da1b916a116e..b57af715f657 100644 --- a/dom/base/DOMPreferences.h +++ b/dom/base/DOMPreferences.h @@ -51,6 +51,10 @@ public: // Returns true if the dom.serviceWorkers.testing.enabled pref is set. static bool ServiceWorkersTestingEnabled(); + + // Returns true if the dom.serviceWorkers.openWindow.enabled pref is set. + static bool OpenWindowEnabled(); + static bool OpenWindowEnabled(JSContext* aCx, JSObject* aObj); }; } // dom namespace diff --git a/dom/webidl/Clients.webidl b/dom/webidl/Clients.webidl index cac144ba97fa..a2028449cf01 100644 --- a/dom/webidl/Clients.webidl +++ b/dom/webidl/Clients.webidl @@ -16,7 +16,7 @@ interface Clients { [NewObject] Promise> matchAll(optional ClientQueryOptions options); [NewObject, - Func="mozilla::dom::ServiceWorkerGlobalScope::OpenWindowEnabled"] + Func="mozilla::dom::DOMPreferences::OpenWindowEnabled"] Promise openWindow(USVString url); [NewObject] Promise claim(); diff --git a/dom/workers/ServiceWorkerClient.h b/dom/workers/ServiceWorkerClient.h index e54d96c5fd35..38b1ad806c91 100644 --- a/dom/workers/ServiceWorkerClient.h +++ b/dom/workers/ServiceWorkerClient.h @@ -13,6 +13,7 @@ #include "mozilla/ErrorResult.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/ClientBinding.h" +#include "mozilla/dom/DOMPreferences.h" class nsIDocument; diff --git a/dom/workers/ServiceWorkerClients.h b/dom/workers/ServiceWorkerClients.h index 3c507516f1b3..772c1edae8cb 100644 --- a/dom/workers/ServiceWorkerClients.h +++ b/dom/workers/ServiceWorkerClients.h @@ -12,6 +12,7 @@ #include "mozilla/dom/WorkerScope.h" #include "mozilla/dom/BindingDeclarations.h" +#include "mozilla/dom/DOMPreferences.h" #include "mozilla/dom/ClientsBinding.h" #include "mozilla/ErrorResult.h" diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h index e4b626b229ae..cfd8be7c1e2a 100644 --- a/dom/workers/WorkerPrefs.h +++ b/dom/workers/WorkerPrefs.h @@ -21,7 +21,6 @@ // * First argument is the name of the pref. // * The name of the function that updates the new value of a pref. -WORKER_SIMPLE_PREF("dom.serviceWorkers.openWindow.enabled", OpenWindowEnabled, OPEN_WINDOW_ENABLED) WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED) WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED) WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED) diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index 698817ee1fca..ec24e454a30a 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -10,6 +10,7 @@ #include "mozilla/EventListenerManager.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/Console.h" +#include "mozilla/dom/DOMPreferences.h" #include "mozilla/dom/DedicatedWorkerGlobalScopeBinding.h" #include "mozilla/dom/DOMPreferences.h" #include "mozilla/dom/Fetch.h" @@ -849,15 +850,6 @@ ServiceWorkerGlobalScope::SkipWaiting(ErrorResult& aRv) return promise.forget(); } -bool -ServiceWorkerGlobalScope::OpenWindowEnabled(JSContext* aCx, JSObject* aObj) -{ - WorkerPrivate* worker = GetCurrentThreadWorkerPrivate(); - MOZ_ASSERT(worker); - worker->AssertIsOnWorkerThread(); - return worker->OpenWindowEnabled(); -} - WorkerDebuggerGlobalScope::WorkerDebuggerGlobalScope( WorkerPrivate* aWorkerPrivate) : mWorkerPrivate(aWorkerPrivate) diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h index a00b3c2f5e6a..686689d831e2 100644 --- a/dom/workers/WorkerScope.h +++ b/dom/workers/WorkerScope.h @@ -300,9 +300,6 @@ public: WrapGlobalObject(JSContext* aCx, JS::MutableHandle aReflector) override; - static bool - OpenWindowEnabled(JSContext* aCx, JSObject* aObj); - void GetScope(nsString& aScope) const {