Backed out 2 changesets (bug 1458043) for dom/presentation/tests/mochitest/test_presentation_1ua_connection_wentaway_inproc.html failures a=backout
authorCiure Andrei <aciure@mozilla.com>
Thu, 17 May 2018 00:54:04 +0300
changeset 796087 1800b8895c08bc0c60302775dc0a4b5ea4deb310
parent 796038 d5b463283f3983c0e7c9d78cb8559f89b52e1cd3
child 796088 96b5ec9789490cf1a7b821ca29918d34a1c3f61b
child 796089 08147da13d660653de69b112507c600e65126bd8
child 796148 1191b8cd031df7f0df80999331c0abab23d7d3c6
child 796178 c02a500392a9b77e650193ab2addf2424e691279
child 796197 2d25c8a0d0177aa4d62cb0df4bef9fa4c08a9564
child 796198 a7b99f5282b6ece494173f817effc52ae2079def
child 796211 88852452b13c8cfa655d0f54fb08f7cbcff50e2d
child 796215 3a91e814b3f0555557c2d93d949ab150c41ba021
child 796236 ec1e0a2f6cb01667565b11f249f1c84c65e09995
child 796237 b90be48dcc97066e106fa1777c3d3acc1e46cd1d
child 796239 e446ef34fc4a68dfa8cc4e5c9278e9d189018da2
child 796240 a31450f6c234f756f093d8ddb30ac3862a54c699
child 796243 dcf36042de2858306901e4dae4bbf5cbb635eda8
child 796244 72fd65b38a8eb67ab8e07eb9dde4ff10f3396f66
child 796246 588445e90b169a28acb38ad57f12d38eb09a2a16
child 796250 76512d757a4ed379771c567731fbca9a5c7767c7
child 796274 c8a02ad4a830e1d4935d9af80712b007bec37e2c
child 796311 c619f826d5aa9f510e72cf0c6386f5505d22d94a
child 796329 8f54c7f9ec9365f89604e4219fc63359367de1a5
child 796332 53aa091fd7c9e6f53558987b4234de8d70b4c1a5
child 796334 c5663479f8ef7464fb78f567c500fab4ea673a75
child 796339 26c7d85ac5bcd9c268af9c53b481ae53b1e48479
child 796340 d67bd6f39ef10d724a7b43f944ca3b82c47ad171
child 796342 1e1e058672d89802d052643769e820984cf6b8d2
child 796612 ad23b749339f690215ab19dfe6d070c2f383870d
child 796670 4f78af9097183a53a4c4587620c3faac1c5ccf2b
child 796718 5642c6b58a1c836317b70592fbfcf1686b550ed3
child 796877 e562d97b8ebe5f4db87b2de888eb5cc3a5ec5ff5
child 797426 289a8f973e60cc12b8b6a9e7a23d46ed071709c1
child 797634 94f21505ff13cd089f7129cd24927cf8b31a0f43
push id110160
push userbmo:mantaroh@gmail.com
push dateThu, 17 May 2018 00:51:24 +0000
reviewersbackout
bugs1458043
milestone62.0a1
backs out0b5c103fcb70edad6ad01a94385134d047641272
51cdd0595094a91cc59c652fe1a61f13abb668ac
Backed out 2 changesets (bug 1458043) for dom/presentation/tests/mochitest/test_presentation_1ua_connection_wentaway_inproc.html failures a=backout Backed out changeset 0b5c103fcb70 (bug 1458043) Backed out changeset 51cdd0595094 (bug 1458043)
dom/promise/Promise.cpp
dom/promise/Promise.h
js/xpconnect/src/XPCConvert.cpp
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -58,18 +58,23 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Promise)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Promise)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mPromiseObj);
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(Promise, AddRef);
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(Promise, Release);
+NS_IMPL_CYCLE_COLLECTING_ADDREF(Promise)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(Promise)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Promise)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+  NS_INTERFACE_MAP_ENTRY(Promise)
+NS_INTERFACE_MAP_END
 
 Promise::Promise(nsIGlobalObject* aGlobal)
   : mGlobal(aGlobal)
   , mPromiseObj(nullptr)
 {
   MOZ_ASSERT(mGlobal);
 
   mozilla::HoldJSObjects(this);
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -27,25 +27,31 @@ namespace mozilla {
 namespace dom {
 
 class AnyCallback;
 class MediaStreamError;
 class PromiseInit;
 class PromiseNativeHandler;
 class PromiseDebugging;
 
-class Promise : public SupportsWeakPtr<Promise>
+#define NS_PROMISE_IID \
+  { 0x1b8d6215, 0x3e67, 0x43ba, \
+    { 0x8a, 0xf9, 0x31, 0x5e, 0x8f, 0xce, 0x75, 0x65 } }
+
+class Promise : public nsISupports,
+                public SupportsWeakPtr<Promise>
 {
   friend class PromiseTask;
   friend class PromiseWorkerProxy;
   friend class PromiseWorkerProxyRunnable;
 
 public:
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(Promise)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(Promise)
+  NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROMISE_IID)
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Promise)
   MOZ_DECLARE_WEAKREFERENCE_TYPENAME(Promise)
 
   // Promise creation tries to create a JS reflector for the Promise, so is
   // fallible.  Furthermore, we don't want to do JS-wrapping on a 0-refcount
   // object, so we addref before doing that and return the addrefed pointer
   // here.
   static already_AddRefed<Promise>
   Create(nsIGlobalObject* aGlobal, ErrorResult& aRv);
@@ -193,12 +199,14 @@ private:
 
   void HandleException(JSContext* aCx);
 
   RefPtr<nsIGlobalObject> mGlobal;
 
   JS::Heap<JSObject*> mPromiseObj;
 };
 
+NS_DEFINE_STATIC_IID_ACCESSOR(Promise, NS_PROMISE_IID)
+
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_Promise_h
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -886,16 +886,31 @@ XPCConvert::NativeInterface2JSObject(Mut
     }
     if (flat) {
         if (allowNativeWrapper && !JS_WrapObject(cx, &flat))
             return false;
         d.setObjectOrNull(flat);
         return true;
     }
 
+    // NOTE(nika): Remove if Promise becomes non-nsISupports
+    if (iid->Equals(NS_GET_IID(nsISupports))) {
+        // Check for a Promise being returned via nsISupports.  In that
+        // situation, we want to dig out its underlying JS object and return
+        // that.
+        RefPtr<Promise> promise = do_QueryObject(aHelper.Object());
+        if (promise) {
+            flat = promise->PromiseObj();
+            if (!JS_WrapObject(cx, &flat))
+                return false;
+            d.setObjectOrNull(flat);
+            return true;
+        }
+    }
+
     // Don't double wrap CPOWs. This is a temporary measure for compatibility
     // with objects that don't provide necessary QIs (such as objects under
     // the new DOM bindings). We expect the other side of the CPOW to have
     // the appropriate wrappers in place.
     RootedObject cpow(cx, UnwrapNativeCPOW(aHelper.Object()));
     if (cpow) {
         if (!JS_WrapObject(cx, &cpow))
             return false;
@@ -1012,16 +1027,28 @@ XPCConvert::JSObject2NativeInterface(voi
                 if (nsCOMPtr<mozIDOMWindow> inner = do_QueryInterface(iface)) {
                     iface = nsPIDOMWindowInner::From(inner)->GetOuterWindow();
                     return NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
                 }
             }
 
             return false;
         }
+
+        // NOTE(nika): Remove if Promise becomes non-nsISupports
+        // Deal with Promises being passed as nsISupports.  In that situation we
+        // want to create a dom::Promise and use that.
+        if (iid->Equals(NS_GET_IID(nsISupports))) {
+            RootedObject innerObj(cx, inner);
+            if (IsPromiseObject(innerObj)) {
+                nsIGlobalObject* glob = NativeGlobal(innerObj);
+                RefPtr<Promise> p = Promise::CreateFromExisting(glob, innerObj);
+                return p && NS_SUCCEEDED(p->QueryInterface(*iid, dest));
+            }
+        }
     }
 
     RefPtr<nsXPCWrappedJS> wrapper;
     nsresult rv = nsXPCWrappedJS::GetNewOrUsed(src, *iid, getter_AddRefs(wrapper));
     if (pErr)
         *pErr = rv;
 
     if (NS_FAILED(rv) || !wrapper)