Bug 877862 - Propagate exceptions from PrepareForWrapping. r=mrbkap
☠☠ backed out by 0a6f4bdb34bf ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Mon, 03 Jun 2013 11:27:41 -0700
changeset 133831 08a29f18500a1ef8e21187c68de482814bc029aa
parent 133830 0692ed4ff443fb0d8983f8b106e0357fac8525d4
child 133832 d4a39e18e5a78d5c92e188323e28c2bba79ff116
push id28918
push userbobbyholley@gmail.com
push dateMon, 03 Jun 2013 18:28:08 +0000
treeherdermozilla-inbound@803586f0a297 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs877862
milestone24.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 877862 - Propagate exceptions from PrepareForWrapping. r=mrbkap
js/xpconnect/wrappers/WrapperFactory.cpp
--- a/js/xpconnect/wrappers/WrapperFactory.cpp
+++ b/js/xpconnect/wrappers/WrapperFactory.cpp
@@ -292,36 +292,36 @@ WrapperFactory::PrepareForWrapping(JSCon
 
     // This public WrapNativeToJSVal API enters the compartment of 'wrapScope'
     // so we don't have to.
     RootedValue v(cx);
     nsresult rv =
         nsXPConnect::XPConnect()->WrapNativeToJSVal(cx, wrapScope, wn->Native(), nullptr,
                                                     &NS_GET_IID(nsISupports), false,
                                                     v.address(), getter_AddRefs(holder));
-    if (NS_SUCCEEDED(rv)) {
-        obj = JSVAL_TO_OBJECT(v);
-        NS_ASSERTION(IS_WN_WRAPPER(obj), "bad object");
+    NS_ENSURE_SUCCESS(rv, nullptr);
+
+    obj = JSVAL_TO_OBJECT(v);
+    NS_ASSERTION(IS_WN_WRAPPER(obj), "bad object");
 
-        // Because the underlying native didn't have a PreCreate hook, we had
-        // to a new (or possibly pre-existing) XPCWN in our compartment.
-        // This could be a problem for chrome code that passes XPCOM objects
-        // across compartments, because the effects of QI would disappear across
-        // compartments.
-        //
-        // So whenever we pull an XPCWN across compartments in this manner, we
-        // give the destination object the union of the two native sets. We try
-        // to do this cleverly in the common case to avoid too much overhead.
-        XPCWrappedNative *newwn = static_cast<XPCWrappedNative *>(xpc_GetJSPrivate(obj));
-        XPCNativeSet *unionSet = XPCNativeSet::GetNewOrUsed(ccx, newwn->GetSet(),
-                                                            wn->GetSet(), false);
-        if (!unionSet)
-            return nullptr;
-        newwn->SetSet(unionSet);
-    }
+    // Because the underlying native didn't have a PreCreate hook, we had
+    // to a new (or possibly pre-existing) XPCWN in our compartment.
+    // This could be a problem for chrome code that passes XPCOM objects
+    // across compartments, because the effects of QI would disappear across
+    // compartments.
+    //
+    // So whenever we pull an XPCWN across compartments in this manner, we
+    // give the destination object the union of the two native sets. We try
+    // to do this cleverly in the common case to avoid too much overhead.
+    XPCWrappedNative *newwn = static_cast<XPCWrappedNative *>(xpc_GetJSPrivate(obj));
+    XPCNativeSet *unionSet = XPCNativeSet::GetNewOrUsed(ccx, newwn->GetSet(),
+                                                        wn->GetSet(), false);
+    if (!unionSet)
+        return nullptr;
+    newwn->SetSet(unionSet);
 
     return DoubleWrap(cx, obj, flags);
 }
 
 #ifdef DEBUG
 static void
 DEBUG_CheckUnwrapSafety(HandleObject obj, js::Wrapper *handler,
                         JSCompartment *origin, JSCompartment *target)