Bug 761695 - Reorder checks for expandos and nodePrincipal. r=peterv
authorBobby Holley <bobbyholley@gmail.com>
Fri, 05 Oct 2012 18:59:23 +0200
changeset 109402 d8c15d5aeaa238904349eb285887653f1a191aae
parent 109401 bc5648cb99722667dc9ea4dca572214504b1c16d
child 109403 b2bb146b3fa7bfed6c68d4b6491a0801b415c177
push id16008
push userbobbyholley@gmail.com
push dateFri, 05 Oct 2012 16:59:43 +0000
treeherdermozilla-inbound@3b4562fd4f20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs761695
milestone18.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 761695 - Reorder checks for expandos and nodePrincipal. r=peterv Peter and I decided this was ok. We can't hoist expando stuff otherwise.
js/xpconnect/wrappers/XrayWrapper.cpp
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -972,16 +972,35 @@ nodePrincipal_getter(JSContext *cx, JSHa
     return true;
 }
 
 bool
 XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper,
                                                JSObject *wrapper, JSObject *holder, jsid id,
                                                bool set, PropertyDescriptor *desc)
 {
+    desc->obj = NULL;
+    JSObject *target = getTargetObject(wrapper);
+    JSObject *expando = singleton.getExpandoObject(cx, target, wrapper);
+
+    // Check for expando properties first. Note that the expando object lives
+    // in the target compartment.
+    if (expando) {
+        JSAutoCompartment ac(cx, expando);
+        if (!JS_GetPropertyDescriptorById(cx, expando, id, 0, desc))
+            return false;
+    }
+    if (desc->obj) {
+        if (!JS_WrapPropertyDescriptor(cx, desc))
+            return false;
+        // Pretend the property lives on the wrapper.
+        desc->obj = wrapper;
+        return true;
+    }
+
     // Xray wrappers don't use the regular wrapper hierarchy, so we should be
     // in the wrapper's compartment here, not the wrappee.
     MOZ_ASSERT(js::IsObjectInContextCompartment(wrapper, cx));
     XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
     if (AccessCheck::isChrome(wrapper) &&
         (((id == rt->GetStringID(XPCJSRuntime::IDX_BASEURIOBJECT) ||
            id == rt->GetStringID(XPCJSRuntime::IDX_NODEPRINCIPAL)) &&
           Is<nsINode>(wrapper)) ||
@@ -1002,37 +1021,17 @@ XPCWrappedNativeXrayTraits::resolveOwnPr
         else
             desc->getter = nodePrincipal_getter;
         desc->setter = NULL;
         desc->shortid = 0;
         desc->value = JSVAL_VOID;
         return true;
     }
 
-    desc->obj = NULL;
-
     unsigned flags = (set ? JSRESOLVE_ASSIGNING : 0) | JSRESOLVE_QUALIFIED;
-    JSObject *target = getTargetObject(wrapper);
-    JSObject *expando = singleton.getExpandoObject(cx, target, wrapper);
-
-    // Check for expando properties first. Note that the expando object lives
-    // in the target compartment.
-    if (expando) {
-        JSAutoCompartment ac(cx, expando);
-        if (!JS_GetPropertyDescriptorById(cx, expando, id, flags, desc))
-            return false;
-    }
-    if (desc->obj) {
-        if (!JS_WrapPropertyDescriptor(cx, desc))
-            return false;
-        // Pretend the property lives on the wrapper.
-        desc->obj = wrapper;
-        return true;
-    }
-
     JSBool hasProp;
     if (!JS_HasPropertyById(cx, holder, id, &hasProp)) {
         return false;
     }
     if (!hasProp) {
         XPCWrappedNative *wn = getWN(wrapper);
 
         // Run the resolve hook of the wrapped native.