Bug 787070 - Expandos on the xray of DOM prototypes should have effect on xrays of DOM nodes, add resolve and enumerate native property hooks for the Window named properties object. r=bholley.
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 15 Sep 2014 16:51:38 +0200
changeset 207616 194b0d93d32a
parent 207615 ee4fe6bc73be
child 207617 73f22a0e55cb
push id49735
push userpvanderbeken@mozilla.com
push dateMon, 29 Sep 2014 07:58:28 +0000
treeherdermozilla-inbound@090b62fdfd21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs787070
milestone35.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 787070 - Expandos on the xray of DOM prototypes should have effect on xrays of DOM nodes, add resolve and enumerate native property hooks for the Window named properties object. r=bholley.
dom/base/WindowNamedPropertiesHandler.cpp
--- a/dom/base/WindowNamedPropertiesHandler.cpp
+++ b/dom/base/WindowNamedPropertiesHandler.cpp
@@ -202,19 +202,50 @@ bool
 WindowNamedPropertiesHandler::delete_(JSContext* aCx,
                                       JS::Handle<JSObject*> aProxy,
                                       JS::Handle<jsid> aId, bool* aBp) const
 {
   *aBp = false;
   return true;
 }
 
+static bool
+ResolveWindowNamedProperty(JSContext* aCx, JS::Handle<JSObject*> aWrapper,
+                           JS::Handle<JSObject*> aObj, JS::Handle<jsid> aId,
+                           JS::MutableHandle<JSPropertyDescriptor> aDesc)
+{
+  {
+    JSAutoCompartment ac(aCx, aObj);
+    if (!js::GetProxyHandler(aObj)->getOwnPropertyDescriptor(aCx, aObj, aId,
+                                                             aDesc)) {
+      return false;
+    }
+  }
+
+  if (aDesc.object()) {
+    aDesc.object().set(aWrapper);
+
+    return JS_WrapPropertyDescriptor(aCx, aDesc);
+  }
+
+  return true;
+}
+
+static bool
+EnumerateWindowNamedProperties(JSContext* aCx, JS::Handle<JSObject*> aWrapper,
+                               JS::Handle<JSObject*> aObj,
+                               JS::AutoIdVector& aProps)
+{
+  JSAutoCompartment ac(aCx, aObj);
+  return js::GetProxyHandler(aObj)->getOwnPropertyNames(aCx, aObj, aProps);
+}
+
 const NativePropertyHooks sWindowNamedPropertiesNativePropertyHooks[] = { {
-  nullptr,
-  nullptr,
+  ResolveWindowNamedProperty,
+  EnumerateWindowNamedProperties,
   { nullptr, nullptr },
   prototypes::id::_ID_Count,
   constructors::id::_ID_Count,
   nullptr
 } };
 
 static const DOMIfaceAndProtoJSClass WindowNamedPropertiesClass = {
   PROXY_CLASS_DEF("WindowProperties",