Bug 1578241 - Get rid of dom.promise_rejection_events.enabled; r=mccr8
authorEdgar Chen <echen@mozilla.com>
Mon, 04 Nov 2019 18:08:54 +0000
changeset 500571 e7c9a7ee428bc7c9e171e12e5b118e27200232e6
parent 500570 4ad4fe8c0b482404e853f4206e46e42303d5830f
child 500572 7612b140db29774d27160e786236df6bc7560fcf
push id114166
push userapavel@mozilla.com
push dateThu, 07 Nov 2019 10:04:01 +0000
treeherdermozilla-inbound@d271c572a9bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1578241, 1525554
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1578241 - Get rid of dom.promise_rejection_events.enabled; r=mccr8 promise rejection event was enabled by default on 69 (bug 1525554). We could get rid of this preference. Differential Revision: https://phabricator.services.mozilla.com/D51491
dom/webidl/EventHandler.webidl
dom/webidl/PromiseRejectionEvent.webidl
dom/webidl/WorkerGlobalScope.webidl
modules/libpref/init/StaticPrefList.yaml
testing/web-platform/meta/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/__dir__.ini
xpcom/base/CycleCollectedJSContext.cpp
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -150,20 +150,18 @@ interface mixin WindowEventHandlers {
            attribute EventHandler onlanguagechange;
            attribute EventHandler onmessage;
            attribute EventHandler onmessageerror;
            attribute EventHandler onoffline;
            attribute EventHandler ononline;
            attribute EventHandler onpagehide;
            attribute EventHandler onpageshow;
            attribute EventHandler onpopstate;
-           [Pref="dom.promise_rejection_events.enabled"]
            attribute EventHandler onrejectionhandled;
            attribute EventHandler onstorage;
-           [Pref="dom.promise_rejection_events.enabled"]
            attribute EventHandler onunhandledrejection;
            attribute EventHandler onunload;
 };
 
 interface mixin DocumentAndElementEventHandlers {
   attribute EventHandler oncopy;
   attribute EventHandler oncut;
   attribute EventHandler onpaste;
--- a/dom/webidl/PromiseRejectionEvent.webidl
+++ b/dom/webidl/PromiseRejectionEvent.webidl
@@ -1,16 +1,15 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-[Exposed=(Window,Worker),
- Pref="dom.promise_rejection_events.enabled"]
+[Exposed=(Window,Worker)]
 interface PromiseRejectionEvent : Event
 {
   constructor(DOMString type, PromiseRejectionEventInit eventInitDict);
 
   [BinaryName="rejectedPromise"]
   readonly attribute Promise<any> promise;
   readonly attribute any reason;
 };
--- a/dom/webidl/WorkerGlobalScope.webidl
+++ b/dom/webidl/WorkerGlobalScope.webidl
@@ -21,19 +21,17 @@ interface WorkerGlobalScope : EventTarge
 
   [Throws]
   void importScripts(DOMString... urls);
 
   attribute OnErrorEventHandler onerror;
 
   attribute EventHandler onoffline;
   attribute EventHandler ononline;
-  [Pref="dom.promise_rejection_events.enabled"]
   attribute EventHandler onrejectionhandled;
-  [Pref="dom.promise_rejection_events.enabled"]
   attribute EventHandler onunhandledrejection;
   // also has additional members in a partial interface
 };
 
 WorkerGlobalScope includes GlobalCrypto;
 WorkerGlobalScope includes WindowOrWorkerGlobalScope;
 
 // Not implemented yet: bug 1072107.
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1958,23 +1958,16 @@
 #endif
   mirror: always
 
 - name: dom.presentation.testing.simulate-receiver
   type: bool
   value: false
   mirror: always
 
-# WHATWG promise rejection events. See
-# https://html.spec.whatwg.org/multipage/webappapis.html#promiserejectionevent
-- name: dom.promise_rejection_events.enabled
-  type: RelaxedAtomicBool
-  value: true
-  mirror: always
-
 # This currently only affects XHTML. For XUL the cache is always allowed.
 - name: dom.prototype_document_cache.enabled
   type: bool
   value: true
   mirror: always
 
 # Push
 - name: dom.push.enabled
deleted file mode 100644
--- a/testing/web-platform/meta/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/__dir__.ini
+++ /dev/null
@@ -1,1 +0,0 @@
-prefs: [dom.promise_rejection_events.enabled:true]
--- a/xpcom/base/CycleCollectedJSContext.cpp
+++ b/xpcom/base/CycleCollectedJSContext.cpp
@@ -8,17 +8,16 @@
 #include <algorithm>
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/CycleCollectedJSRuntime.h"
 #include "mozilla/Move.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Sprintf.h"
-#include "mozilla/StaticPrefs_dom.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimelineConsumers.h"
 #include "mozilla/TimelineMarker.h"
 #include "mozilla/Unused.h"
 #include "mozilla/DebuggerOnGCRunnable.h"
 #include "mozilla/dom/DOMJSClass.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/ProfileTimelineMarkerBinding.h"
@@ -317,55 +316,52 @@ void CycleCollectedJSContext::PromiseRej
   // cross-origin scripts
 
   PromiseArray& aboutToBeNotified = self->mAboutToBeNotifiedRejectedPromises;
   PromiseHashtable& unhandled = self->mPendingUnhandledRejections;
   uint64_t promiseID = JS::GetPromiseID(aPromise);
 
   if (state == JS::PromiseRejectionHandlingState::Unhandled) {
     PromiseDebugging::AddUncaughtRejection(aPromise);
-    if (mozilla::StaticPrefs::dom_promise_rejection_events_enabled() &&
-        !aMutedErrors) {
+    if (!aMutedErrors) {
       RefPtr<Promise> promise =
           Promise::CreateFromExisting(xpc::NativeGlobal(aPromise), aPromise);
       aboutToBeNotified.AppendElement(promise);
       unhandled.Put(promiseID, promise);
     }
   } else {
     PromiseDebugging::AddConsumedRejection(aPromise);
-    if (mozilla::StaticPrefs::dom_promise_rejection_events_enabled()) {
-      for (size_t i = 0; i < aboutToBeNotified.Length(); i++) {
-        if (aboutToBeNotified[i] &&
-            aboutToBeNotified[i]->PromiseObj() == aPromise) {
-          // To avoid large amounts of memmoves, we don't shrink the vector
-          // here. Instead, we filter out nullptrs when iterating over the
-          // vector later.
-          aboutToBeNotified[i] = nullptr;
-          DebugOnly<bool> isFound = unhandled.Remove(promiseID);
-          MOZ_ASSERT(isFound);
-          return;
-        }
+    for (size_t i = 0; i < aboutToBeNotified.Length(); i++) {
+      if (aboutToBeNotified[i] &&
+          aboutToBeNotified[i]->PromiseObj() == aPromise) {
+        // To avoid large amounts of memmoves, we don't shrink the vector
+        // here. Instead, we filter out nullptrs when iterating over the
+        // vector later.
+        aboutToBeNotified[i] = nullptr;
+        DebugOnly<bool> isFound = unhandled.Remove(promiseID);
+        MOZ_ASSERT(isFound);
+        return;
       }
-      RefPtr<Promise> promise;
-      unhandled.Remove(promiseID, getter_AddRefs(promise));
-      if (!promise && !aMutedErrors) {
-        nsIGlobalObject* global = xpc::NativeGlobal(aPromise);
-        if (nsCOMPtr<EventTarget> owner = do_QueryInterface(global)) {
-          RootedDictionary<PromiseRejectionEventInit> init(aCx);
-          init.mPromise = Promise::CreateFromExisting(global, aPromise);
-          init.mReason = JS::GetPromiseResult(aPromise);
+    }
+    RefPtr<Promise> promise;
+    unhandled.Remove(promiseID, getter_AddRefs(promise));
+    if (!promise && !aMutedErrors) {
+      nsIGlobalObject* global = xpc::NativeGlobal(aPromise);
+      if (nsCOMPtr<EventTarget> owner = do_QueryInterface(global)) {
+        RootedDictionary<PromiseRejectionEventInit> init(aCx);
+        init.mPromise = Promise::CreateFromExisting(global, aPromise);
+        init.mReason = JS::GetPromiseResult(aPromise);
 
-          RefPtr<PromiseRejectionEvent> event =
-              PromiseRejectionEvent::Constructor(
-                  owner, NS_LITERAL_STRING("rejectionhandled"), init);
+        RefPtr<PromiseRejectionEvent> event =
+            PromiseRejectionEvent::Constructor(
+                owner, NS_LITERAL_STRING("rejectionhandled"), init);
 
-          RefPtr<AsyncEventDispatcher> asyncDispatcher =
-              new AsyncEventDispatcher(owner, event);
-          asyncDispatcher->PostDOMEvent();
-        }
+        RefPtr<AsyncEventDispatcher> asyncDispatcher =
+            new AsyncEventDispatcher(owner, event);
+        asyncDispatcher->PostDOMEvent();
       }
     }
   }
 }
 
 already_AddRefed<Exception> CycleCollectedJSContext::GetPendingException()
     const {
   MOZ_ASSERT(mJSContext);
@@ -668,18 +664,16 @@ void CycleCollectedJSContext::PerformDeb
     }
     runnable->Run(aso);
   }
 
   AfterProcessMicrotasks();
 }
 
 NS_IMETHODIMP CycleCollectedJSContext::NotifyUnhandledRejections::Run() {
-  MOZ_ASSERT(mozilla::StaticPrefs::dom_promise_rejection_events_enabled());
-
   for (size_t i = 0; i < mUnhandledRejections.Length(); ++i) {
     RefPtr<Promise>& promise = mUnhandledRejections[i];
     if (!promise) {
       continue;
     }
 
     JS::RootingContext* cx = mCx->RootingCx();
     JS::RootedObject promiseObj(cx, promise->PromiseObj());
@@ -714,18 +708,16 @@ NS_IMETHODIMP CycleCollectedJSContext::N
     // handler, it should be removed from the table in
     // PromiseRejectionTrackerCallback.
     MOZ_ASSERT(!mCx->mPendingUnhandledRejections.Lookup(promiseID));
   }
   return NS_OK;
 }
 
 nsresult CycleCollectedJSContext::NotifyUnhandledRejections::Cancel() {
-  MOZ_ASSERT(mozilla::StaticPrefs::dom_promise_rejection_events_enabled());
-
   for (size_t i = 0; i < mUnhandledRejections.Length(); ++i) {
     RefPtr<Promise>& promise = mUnhandledRejections[i];
     if (!promise) {
       continue;
     }
 
     JS::RootedObject promiseObj(mCx->RootingCx(), promise->PromiseObj());
     mCx->mPendingUnhandledRejections.Remove(JS::GetPromiseID(promiseObj));