diff --git a/dom/base/DOMPrefs.cpp b/dom/base/DOMPrefs.cpp index f886a95fc2f5..8d0f65fca76a 100644 --- a/dom/base/DOMPrefs.cpp +++ b/dom/base/DOMPrefs.cpp @@ -44,6 +44,7 @@ PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled") PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled") PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled") PREF(StorageManagerEnabled, "dom.storageManager.enabled") +PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled") #undef PREF @@ -60,6 +61,7 @@ PREF_WEBIDL(NotificationEnabledInServiceWorkers) PREF_WEBIDL(NotificationRIEnabled) PREF_WEBIDL(ServiceWorkersEnabled) PREF_WEBIDL(StorageManagerEnabled) +PREF_WEBIDL(PromiseRejectionEventsEnabled) #undef PREF_WEBIDL diff --git a/dom/base/DOMPrefs.h b/dom/base/DOMPrefs.h index 8e5df53393e1..8eb8f4e2145f 100644 --- a/dom/base/DOMPrefs.h +++ b/dom/base/DOMPrefs.h @@ -55,6 +55,10 @@ public: // Returns true if the dom.storageManager.enabled pref is set. static bool StorageManagerEnabled(); static bool StorageManagerEnabled(JSContext* aCx, JSObject* aObj); + + // Returns true if the dom.promise_rejection_events.enabled pref is set. + static bool PromiseRejectionEventsEnabled(); + static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj); }; } // dom namespace diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index c2fb6359db1c..75af9eb4f0ef 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -8885,25 +8885,6 @@ nsContentUtils::GetReferrerPolicyFromHeader(const nsAString& aHeader) return referrerPolicy; } -// static -bool -nsContentUtils::PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj) -{ - if (NS_IsMainThread()) { - return Preferences::GetBool("dom.promise_rejection_events.enabled", false); - } - - using namespace workers; - - // Otherwise, check the pref via the WorkerPrivate - WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx); - if (!workerPrivate) { - return false; - } - - return workerPrivate->PromiseRejectionEventsEnabled(); -} - // static bool nsContentUtils::PushEnabled(JSContext* aCx, JSObject* aObj) diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 391f1474c949..cb7e7235053e 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2911,8 +2911,6 @@ public: */ static mozilla::net::ReferrerPolicy GetReferrerPolicyFromHeader(const nsAString& aHeader); - static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj); - static bool PushEnabled(JSContext* aCx, JSObject* aObj); static bool StreamsEnabled(JSContext* aCx, JSObject* aObj); diff --git a/dom/webidl/PromiseRejectionEvent.webidl b/dom/webidl/PromiseRejectionEvent.webidl index 21faf8bd09d0..a341794cf916 100644 --- a/dom/webidl/PromiseRejectionEvent.webidl +++ b/dom/webidl/PromiseRejectionEvent.webidl @@ -6,7 +6,7 @@ [Constructor(DOMString type, PromiseRejectionEventInit eventInitDict), Exposed=(Window,Worker), - Func="nsContentUtils::PromiseRejectionEventsEnabled"] + Func="mozilla::dom::DOMPrefs::PromiseRejectionEventsEnabled"] interface PromiseRejectionEvent : Event { [BinaryName="rejectedPromise"] diff --git a/dom/workers/WorkerPrefs.h b/dom/workers/WorkerPrefs.h index 99085bb39ce6..7b87e157b556 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.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED) WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED) WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED) WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)