Bug 965898 - All properties on cross-origin DOM objects should be |own|. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Wed, 30 Jul 2014 12:23:01 -0700
changeset 196840 9e85835de239e1599b0bfce56d3c9952e5a69db2
parent 196839 88a562ab485badbe23f00e94edbc6aad07403f94
child 196841 f440504714b99855df41e1f4988fec9e2843bf46
push id46984
push userbobbyholley@gmail.com
push dateWed, 30 Jul 2014 19:24:00 +0000
treeherdermozilla-inbound@22e1b7b69877 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs965898
milestone34.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 965898 - All properties on cross-origin DOM objects should be |own|. r=gabor
js/xpconnect/wrappers/FilteringWrapper.cpp
js/xpconnect/wrappers/FilteringWrapper.h
--- a/js/xpconnect/wrappers/FilteringWrapper.cpp
+++ b/js/xpconnect/wrappers/FilteringWrapper.cpp
@@ -173,16 +173,41 @@ FilteringWrapper<Base, Policy>::enter(JS
 CrossOriginXrayWrapper::CrossOriginXrayWrapper(unsigned flags) : SecurityXrayDOM(flags)
 {
 }
 
 CrossOriginXrayWrapper::~CrossOriginXrayWrapper()
 {
 }
 
+bool
+CrossOriginXrayWrapper::getPropertyDescriptor(JSContext *cx,
+                                              JS::Handle<JSObject*> wrapper,
+                                              JS::Handle<jsid> id,
+                                              JS::MutableHandle<JSPropertyDescriptor> desc) const
+{
+    if (!SecurityXrayDOM::getPropertyDescriptor(cx, wrapper, id, desc))
+        return false;
+    if (desc.object()) {
+        // All properties on cross-origin DOM objects are |own|.
+        desc.object().set(wrapper);
+    }
+    return true;
+}
+
+bool
+CrossOriginXrayWrapper::getOwnPropertyDescriptor(JSContext *cx,
+                                                 JS::Handle<JSObject*> wrapper,
+                                                 JS::Handle<jsid> id,
+                                                 JS::MutableHandle<JSPropertyDescriptor> desc) const
+{
+    // All properties on cross-origin DOM objects are |own|.
+    return getPropertyDescriptor(cx, wrapper, id, desc);
+}
+
 #define XOW FilteringWrapper<CrossOriginXrayWrapper, CrossOriginAccessiblePropertiesOnly>
 #define NNXOW FilteringWrapper<CrossCompartmentSecurityWrapper, Opaque>
 #define NNXOWC FilteringWrapper<CrossCompartmentSecurityWrapper, OpaqueWithCall>
 
 template<> const XOW XOW::singleton(0);
 template<> const NNXOW NNXOW::singleton(0);
 template<> const NNXOWC NNXOWC::singleton(0);
 
--- a/js/xpconnect/wrappers/FilteringWrapper.h
+++ b/js/xpconnect/wrappers/FilteringWrapper.h
@@ -56,13 +56,20 @@ class FilteringWrapper : public Base {
  * The HTML5 spec mandates very particular object behavior for cross-origin DOM
  * objects (Window and Location), some of which runs contrary to the way that
  * other XrayWrappers behave. We use this class to implement those semantics.
  */
 class CrossOriginXrayWrapper : public SecurityXrayDOM {
   public:
     CrossOriginXrayWrapper(unsigned flags);
     virtual ~CrossOriginXrayWrapper();
+
+    virtual bool getPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
+                                       JS::Handle<jsid> id,
+                                       JS::MutableHandle<JSPropertyDescriptor> desc) const MOZ_OVERRIDE;
+    virtual bool getOwnPropertyDescriptor(JSContext *cx, JS::Handle<JSObject*> wrapper,
+                                          JS::Handle<jsid> id,
+                                          JS::MutableHandle<JSPropertyDescriptor> desc) const MOZ_OVERRIDE;
 };
 
 }
 
 #endif /* __FilteringWrapper_h__ */