Bug 658909 - Remove GWNOJO for helper stubs. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Thu, 21 Mar 2013 08:20:43 -0700
changeset 125810 b2716f274a9484004e681cb8e68d8312c95749ec
parent 125809 a5d11e2a9602cf238be5fd4df98a8d60cb3b812a
child 125811 7bccfe486f988984f85d4a162b15c6d35b74e73b
push id25109
push userryanvm@gmail.com
push dateThu, 21 Mar 2013 19:52:05 +0000
treeherdermozilla-inbound@a83cbe4e0576 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs658909
milestone22.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 658909 - Remove GWNOJO for helper stubs. r=mrbkap
js/xpconnect/src/XPCWrappedNativeJSOps.cpp
--- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
@@ -843,23 +843,31 @@ XPC_WN_MaybeResolvingStrictPropertyStub(
         XPCWrappedNative::GetAndMorphWrappedNativeOfJSObject(cx, obj);        \
     THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);                             \
     bool retval = true;                                                       \
     nsresult rv = wrapper->GetScriptableCallback()->
 
 #define PRE_HELPER_STUB                                                       \
     XPCWrappedNative* wrapper;                                                \
     nsIXPCScriptable* si;                                                     \
-    if (IS_SLIM_WRAPPER(obj)) {                                               \
-        wrapper = nullptr;                                                     \
-        si = GetSlimWrapperProto(obj)->GetScriptableInfo()->GetCallback();    \
+    JSObject *unwrapped = js::UnwrapObjectChecked(obj, false);                \
+    if (!unwrapped) {                                                         \
+        JS_ReportError(cx, "Permission denied to operate on object.");        \
+        return false;                                                         \
+    }                                                                         \
+    if (!IS_WRAPPER_CLASS(js::GetObjectClass(unwrapped))) {                   \
+        return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);                    \
     }                                                                         \
-    else                                                                      \
-    {                                                                         \
-        wrapper = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);      \
+    if (IS_SLIM_WRAPPER_OBJECT(unwrapped)) {                                  \
+        wrapper = nullptr;                                                    \
+        si = GetSlimWrapperProto(unwrapped)->GetScriptableInfo()              \
+                                           ->GetCallback();                   \
+    } else {                                                                  \
+        MOZ_ASSERT(IS_WN_WRAPPER_OBJECT(unwrapped));                          \
+        wrapper = XPCWrappedNative::Get(unwrapped);                           \
         THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);                         \
         si = wrapper->GetScriptableCallback();                                \
     }                                                                         \
     bool retval = true;                                                       \
     nsresult rv = si->
 
 #define POST_HELPER_STUB                                                      \
     if (NS_FAILED(rv))                                                        \
@@ -1344,21 +1352,16 @@ XPCNativeScriptableShared::PopulateJSCla
         mJSClass.base.finalize = XPC_WN_Helper_Finalize;
     else
         mJSClass.base.finalize = XPC_WN_NoHelper_Finalize;
 
     // We let the rest default to nullptr unless the helper wants them...
     if (mFlags.WantCheckAccess())
         mJSClass.base.checkAccess = XPC_WN_Helper_CheckAccess;
 
-    // Note that we *must* set the ObjectOps (even for the cases were it does
-    // not do much) because with these dynamically generated JSClasses, the
-    // code in XPCWrappedNative::GetWrappedNativeOfJSObject() needs to look
-    // for that these callback pointers in order to identify that a given
-    // JSObject represents a wrapper.
     js::ObjectOps *ops = &mJSClass.base.ops;
     ops->enumerate = XPC_WN_JSOp_Enumerate;
     ops->thisObject = XPC_WN_JSOp_ThisObject;
 
 
     if (mFlags.WantCall())
         mJSClass.base.call = XPC_WN_Helper_Call;
     if (mFlags.WantConstruct())