Bug 1188256 part 6 - Expose PromiseDebugging to plain mochitest via SpecialPowers. r=bzbarsky
authorXidorn Quan <me@upsuper.org>
Fri, 14 Sep 2018 22:43:54 +0000
changeset 492140 4f7527b669df5e649cf58d58d940731b6e76a98f
parent 492139 9e246dedccbfe9058d9e042de19bf5853c91d339
child 492141 0665a323aec7354788b6be532a21ac79da3a3ff8
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1188256
milestone64.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 1188256 part 6 - Expose PromiseDebugging to plain mochitest via SpecialPowers. r=bzbarsky Depends on D5852 Differential Revision: https://phabricator.services.mozilla.com/D5858
js/xpconnect/src/Sandbox.cpp
js/xpconnect/src/xpcprivate.h
testing/specialpowers/content/specialpowersAPI.js
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -43,16 +43,17 @@
 #include "mozilla/dom/Fetch.h"
 #include "mozilla/dom/FileBinding.h"
 #include "mozilla/dom/InspectorUtilsBinding.h"
 #include "mozilla/dom/MessageChannelBinding.h"
 #include "mozilla/dom/MessagePortBinding.h"
 #include "mozilla/dom/NodeBinding.h"
 #include "mozilla/dom/NodeFilterBinding.h"
 #include "mozilla/dom/PromiseBinding.h"
+#include "mozilla/dom/PromiseDebuggingBinding.h"
 #include "mozilla/dom/RequestBinding.h"
 #include "mozilla/dom/ResponseBinding.h"
 #ifdef MOZ_WEBRTC
 #include "mozilla/dom/RTCIdentityProviderRegistrar.h"
 #endif
 #include "mozilla/dom/FileReaderBinding.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/TextDecoderBinding.h"
@@ -901,16 +902,18 @@ xpc::GlobalProperties::Parse(JSContext* 
         } else if (JS_FlatStringEqualsAscii(nameStr, "InspectorUtils")) {
             InspectorUtils = true;
         } else if (JS_FlatStringEqualsAscii(nameStr, "MessageChannel")) {
             MessageChannel = true;
         } else if (JS_FlatStringEqualsAscii(nameStr, "Node")) {
             Node = true;
         } else if (JS_FlatStringEqualsAscii(nameStr, "NodeFilter")) {
             NodeFilter = true;
+        } else if (JS_FlatStringEqualsAscii(nameStr, "PromiseDebugging")) {
+            PromiseDebugging = true;
         } else if (JS_FlatStringEqualsAscii(nameStr, "TextDecoder")) {
             TextDecoder = true;
         } else if (JS_FlatStringEqualsAscii(nameStr, "TextEncoder")) {
             TextEncoder = true;
         } else if (JS_FlatStringEqualsAscii(nameStr, "URL")) {
             URL = true;
         } else if (JS_FlatStringEqualsAscii(nameStr, "URLSearchParams")) {
             URLSearchParams = true;
@@ -1013,16 +1016,21 @@ xpc::GlobalProperties::Define(JSContext*
     if (Node && !dom::Node_Binding::GetConstructorObject(cx)) {
         return false;
     }
 
     if (NodeFilter && !dom::NodeFilter_Binding::GetConstructorObject(cx)) {
         return false;
     }
 
+    if (PromiseDebugging &&
+        !dom::PromiseDebugging_Binding::GetConstructorObject(cx)) {
+        return false;
+    }
+
     if (TextDecoder &&
         !dom::TextDecoder_Binding::GetConstructorObject(cx))
         return false;
 
     if (TextEncoder &&
         !dom::TextEncoder_Binding::GetConstructorObject(cx))
         return false;
 
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -2625,16 +2625,17 @@ struct GlobalProperties {
     bool Event : 1;
     bool File : 1;
     bool FileReader: 1;
     bool FormData : 1;
     bool InspectorUtils : 1;
     bool MessageChannel: 1;
     bool Node : 1;
     bool NodeFilter : 1;
+    bool PromiseDebugging : 1;
     bool TextDecoder : 1;
     bool TextEncoder : 1;
     bool URL : 1;
     bool URLSearchParams : 1;
     bool XMLHttpRequest : 1;
     bool XMLSerializer : 1;
 
     // Ad-hoc property names we implement.
--- a/testing/specialpowers/content/specialpowersAPI.js
+++ b/testing/specialpowers/content/specialpowersAPI.js
@@ -33,20 +33,21 @@ ChromeUtils.defineModuleGetter(this, "Ap
                                "resource://gre/modules/AppConstants.jsm");
 ChromeUtils.defineModuleGetter(this, "ServiceWorkerCleanUp",
                                "resource://gre/modules/ServiceWorkerCleanUp.jsm");
 
 ChromeUtils.defineModuleGetter(this, "PerTestCoverageUtils",
   "resource://testing-common/PerTestCoverageUtils.jsm");
 
 try {
-    Cu.importGlobalProperties(["DOMParser", "File", "InspectorUtils", "NodeFilter"]);
+    Cu.importGlobalProperties(["DOMParser", "File", "InspectorUtils",
+                               "NodeFilter", "PromiseDebugging"]);
 } catch (e) {
- // We are in window scope hence DOMParser, File, InspectorUtils and NodeFilter
- // are already defined, So do nothing.
+  // We are in window scope hence DOMParser, File, InspectorUtils, NodeFilter,
+  // and PromiseDebugging are already defined, So do nothing.
 }
 
 // Allow stuff from this scope to be accessed from non-privileged scopes. This
 // would crash if used outside of automation.
 Cu.forcePermissiveCOWs();
 
 function SpecialPowersAPI() {
   this._consoleListeners = [];
@@ -687,16 +688,18 @@ SpecialPowersAPI.prototype = {
   getNoXULDOMParser() {
     // If we create it with a system subject principal (so it gets a
     // nullprincipal), it won't be able to parse XUL by default.
     return wrapPrivileged(new DOMParser());
   },
 
   get InspectorUtils() { return wrapPrivileged(InspectorUtils); },
 
+  get PromiseDebugging() { return wrapPrivileged(PromiseDebugging); },
+
   waitForCrashes(aExpectingProcessCrash) {
     return new Promise((resolve, reject) => {
       if (!aExpectingProcessCrash) {
         resolve();
       }
 
       var crashIds = this._encounteredCrashDumpFiles.filter((filename) => {
         return ((filename.length === 40) && filename.endsWith(".dmp"));