Web Inspector: Expose Proxy target and handler internal properties to Inspector
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2016 04:59:18 +0000 (04:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Feb 2016 04:59:18 +0000 (04:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154663

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-02-24
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

* inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::getInternalProperties):
Expose the ProxyObject's target and handler.

Source/WebInspectorUI:

* UserInterface/Models/NativeFunctionParameters.js:
* UserInterface/Views/ObjectTreePropertyTreeElement.js:
(WebInspector.ObjectTreePropertyTreeElement.prototype._functionParameterString):
Improve the native parameter list for the global Reflect object methods.
Include "enumerate" even though it is deprecated, because we implement it.

LayoutTests:

* inspector/model/remote-object.html:
* platform/mac/inspector/model/remote-object-expected.txt:
Test that a Proxy object includes the internal properties.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197061 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/model/remote-object-expected.txt
LayoutTests/inspector/model/remote-object.html
LayoutTests/platform/mac/inspector/model/remote-object-expected.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js
Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js

index e17a71e..0c3b61b 100644 (file)
@@ -1,3 +1,14 @@
+2016-02-24  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Expose Proxy target and handler internal properties to Inspector
+        https://bugs.webkit.org/show_bug.cgi?id=154663
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/model/remote-object.html:
+        * platform/mac/inspector/model/remote-object-expected.txt:
+        Test that a Proxy object includes the internal properties.
+
 2016-02-24  Ryan Haddad  <ryanhaddad@apple.com>
 
         Marking storage/indexeddb/odd-strings.html as flaky on mac-wk1
index bd62fed..da629a9 100644 (file)
@@ -4656,6 +4656,74 @@ EXPRESSION: Promise.resolve({result:1})
 }
 
 -----------------------------------------------------
+EXPRESSION: new Proxy({x:1, y:1}, {handler: true})
+{
+  "_type": "object",
+  "_objectId": "<filtered>",
+  "_description": "ProxyObject",
+  "_preview": {
+    "_listeners": null,
+    "_type": "object",
+    "_description": "ProxyObject",
+    "_lossless": true,
+    "_overflow": false,
+    "_properties": [
+      {
+        "_listeners": null,
+        "_name": "target",
+        "_type": "object",
+        "_valuePreview": {
+          "_listeners": null,
+          "_type": "object",
+          "_description": "Object",
+          "_lossless": true,
+          "_overflow": false,
+          "_properties": [
+            {
+              "_listeners": null,
+              "_name": "x",
+              "_type": "number",
+              "_value": "1"
+            },
+            {
+              "_listeners": null,
+              "_name": "y",
+              "_type": "number",
+              "_value": "1"
+            }
+          ],
+          "_entries": null
+        },
+        "_internal": true
+      },
+      {
+        "_listeners": null,
+        "_name": "handler",
+        "_type": "object",
+        "_valuePreview": {
+          "_listeners": null,
+          "_type": "object",
+          "_description": "Object",
+          "_lossless": true,
+          "_overflow": false,
+          "_properties": [
+            {
+              "_listeners": null,
+              "_name": "handler",
+              "_type": "boolean",
+              "_value": "true"
+            }
+          ],
+          "_entries": null
+        },
+        "_internal": true
+      }
+    ],
+    "_entries": null
+  }
+}
+
+-----------------------------------------------------
 EXPRESSION: Person = class Person { constructor(name){} get fullName(){} methodName(p1, p2){} }; Person
 {
   "_type": "function",
index 2bd50d7..abcd93a 100644 (file)
@@ -168,6 +168,9 @@ function test()
         {expression: "Promise.resolve()"},
         {expression: "Promise.resolve({result:1})"},
 
+        // Proxy
+        {expression: "new Proxy({x:1, y:1}, {handler: true})"},
+
     // Classes
 
         {expression: "Person = class Person { constructor(name){} get fullName(){} methodName(p1, p2){} }; Person"}, // Constructor => class type
index 0cc6113..40bbce5 100644 (file)
@@ -4657,6 +4657,74 @@ EXPRESSION: Promise.resolve({result:1})
 }
 
 -----------------------------------------------------
+EXPRESSION: new Proxy({x:1, y:1}, {handler: true})
+{
+  "_type": "object",
+  "_objectId": "<filtered>",
+  "_description": "ProxyObject",
+  "_preview": {
+    "_listeners": null,
+    "_type": "object",
+    "_description": "ProxyObject",
+    "_lossless": true,
+    "_overflow": false,
+    "_properties": [
+      {
+        "_listeners": null,
+        "_name": "target",
+        "_type": "object",
+        "_valuePreview": {
+          "_listeners": null,
+          "_type": "object",
+          "_description": "Object",
+          "_lossless": true,
+          "_overflow": false,
+          "_properties": [
+            {
+              "_listeners": null,
+              "_name": "x",
+              "_type": "number",
+              "_value": "1"
+            },
+            {
+              "_listeners": null,
+              "_name": "y",
+              "_type": "number",
+              "_value": "1"
+            }
+          ],
+          "_entries": null
+        },
+        "_internal": true
+      },
+      {
+        "_listeners": null,
+        "_name": "handler",
+        "_type": "object",
+        "_valuePreview": {
+          "_listeners": null,
+          "_type": "object",
+          "_description": "Object",
+          "_lossless": true,
+          "_overflow": false,
+          "_properties": [
+            {
+              "_listeners": null,
+              "_name": "handler",
+              "_type": "boolean",
+              "_value": "true"
+            }
+          ],
+          "_entries": null
+        },
+        "_internal": true
+      }
+    ],
+    "_entries": null
+  }
+}
+
+-----------------------------------------------------
 EXPRESSION: Person = class Person { constructor(name){} get fullName(){} methodName(p1, p2){} }; Person
 {
   "_type": "function",
index bc5467a..199f7e1 100644 (file)
@@ -1,3 +1,14 @@
+2016-02-24  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Expose Proxy target and handler internal properties to Inspector
+        https://bugs.webkit.org/show_bug.cgi?id=154663
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/JSInjectedScriptHost.cpp:
+        (Inspector::JSInjectedScriptHost::getInternalProperties):
+        Expose the ProxyObject's target and handler.
+
 2016-02-24  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
 
         [web-animations] Add AnimationTimeline, DocumentTimeline and add extensions to Document interface
index 3ad8bfa..65e2eb8 100644 (file)
@@ -48,6 +48,7 @@
 #include "JSWeakMap.h"
 #include "JSWeakSet.h"
 #include "ObjectConstructor.h"
+#include "ProxyObject.h"
 #include "RegExpObject.h"
 #include "ScopedArguments.h"
 #include "SourceCode.h"
@@ -260,6 +261,14 @@ JSValue JSInjectedScriptHost::getInternalProperties(ExecState* exec)
         return array;
     }
 
+    if (ProxyObject* proxy = jsDynamicCast<ProxyObject*>(value)) {
+        unsigned index = 0;
+        JSArray* array = constructEmptyArray(exec, nullptr, 2);
+        array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("target"), proxy->target()));
+        array->putDirectIndex(exec, index++, constructInternalProperty(exec, ASCIILiteral("handler"), proxy->handler()));
+        return array;
+    }
+
     if (JSArrayIterator* arrayIterator = jsDynamicCast<JSArrayIterator*>(value)) {
         String kind;
         switch (arrayIterator->kind(exec)) {
index dbf1796..b7e3c06 100644 (file)
@@ -1,3 +1,16 @@
+2016-02-24  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Expose Proxy target and handler internal properties to Inspector
+        https://bugs.webkit.org/show_bug.cgi?id=154663
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/NativeFunctionParameters.js:
+        * UserInterface/Views/ObjectTreePropertyTreeElement.js:
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._functionParameterString):
+        Improve the native parameter list for the global Reflect object methods.
+        Include "enumerate" even though it is deprecated, because we implement it.
+
 2016-02-24  Devin Rousso  <dcrousso+webkit@gmail.com>
 
         Web Inspector: Visual Styles sidebar should support multiple animations
index 417cc3b..aaaf30b 100644 (file)
@@ -129,6 +129,24 @@ WebInspector.NativeConstructorFunctionParameters = {
         __proto__: null,
     },
 
+    Reflect: {
+        apply: "target, thisArgument, argumentsList",
+        construct: "target, argumentsList, [newTarget=target]",
+        defineProperty: "target, propertyKey, attributes",
+        deleteProperty: "target, propertyKey",
+        enumerate: "target",
+        get: "target, propertyKey, [receiver]",
+        getOwnPropertyDescriptor: "target, propertyKey",
+        getPrototypeOf: "target",
+        has: "target, propertyKey",
+        isExtensible: "target",
+        ownKeys: "target",
+        preventExtensions: "target",
+        set: "target, propertyKey, value, [receiver]",
+        setPrototypeOf: "target, prototype",
+        __proto__: null,
+    },
+
     String: {
         fromCharCode: "...codeUnits",
         fromCodePoint: "...codePoints",
index fb77f81..a0e3c43 100644 (file)
@@ -272,7 +272,7 @@ WebInspector.ObjectTreePropertyTreeElement = class ObjectTreePropertyTreeElement
             }
 
             // Native DOM constructor or on native objects that are not functions.
-            if (parentDescription.endsWith("Constructor") || parentDescription === "Math" || parentDescription === "JSON") {
+            if (parentDescription.endsWith("Constructor") || parentDescription === "Math" || parentDescription === "JSON" || parentDescription === "Reflect") {
                 var name = parentDescription;
                 if (WebInspector.NativeConstructorFunctionParameters[name]) {
                     var params = WebInspector.NativeConstructorFunctionParameters[name][this._property.name];