Bug 1125015 - Prototype non-hasPrototype XrayWrappers with non-Xrayable prototypes to the wrapper's Object.prototype. r=bz, a=abillings
authorBobby Holley <bobbyholley@gmail.com>
Mon, 26 Jan 2015 16:06:59 -0500
changeset 200530 50cad2d9985b287d9217b8cad5d715a43b848721
parent 200529 fbe02a90af22c3ccf7f0d6838163779976dde6c6
child 200531 6d7c5ebb94da2ed2e04b183e500e27cf73a34a0a
push id177
push userryanvm@gmail.com
push dateMon, 26 Jan 2015 21:07:03 +0000
treeherdermozilla-esr31@5ee3807b4bb2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, abillings
bugs1125015
milestone31.4.0
Bug 1125015 - Prototype non-hasPrototype XrayWrappers with non-Xrayable prototypes to the wrapper's Object.prototype. r=bz, a=abillings
js/xpconnect/wrappers/XrayWrapper.h
--- a/js/xpconnect/wrappers/XrayWrapper.h
+++ b/js/xpconnect/wrappers/XrayWrapper.h
@@ -4,18 +4,21 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef XrayWrapper_h
 #define XrayWrapper_h
 
 #include "mozilla/Attributes.h"
 
+#include "jsapi.h"
 #include "jswrapper.h"
 
+#include "WrapperFactory.h"
+
 // Xray wrappers re-resolve the original native properties on the native
 // object and always directly access to those properties.
 // Because they work so differently from the rest of the wrapper hierarchy,
 // we pull them out of the Wrapper inheritance hierarchy and create a
 // little world around them.
 
 namespace xpc {
 
@@ -121,17 +124,23 @@ class XrayWrapper : public Base {
     {
         return Traits::singleton.getPrototypeOf(cx, wrapper, target, protop);
     }
     template <bool HasPrototype>
     typename mozilla::EnableIf<!HasPrototype, bool>::Type
         getPrototypeOfHelper(JSContext *cx, JS::HandleObject wrapper,
                              JS::HandleObject target, JS::MutableHandleObject protop)
     {
-        return Base::getPrototypeOf(cx, wrapper, protop);
+        if (!Base::getPrototypeOf(cx, wrapper, protop))
+            return false;
+        if (WrapperFactory::IsXrayWrapper(protop))
+            return true;
+
+        protop.set(JS_GetObjectPrototype(cx, wrapper));
+        return !!protop.get();
     }
     bool getPrototypeOfHelper(JSContext *cx, JS::HandleObject wrapper,
                               JS::HandleObject target, JS::MutableHandleObject protop)
     {
         return getPrototypeOfHelper<Traits::HasPrototype>(cx, wrapper, target,
                                                           protop);
     }