Title: [207229] trunk
Revision
207229
Author
joep...@webkit.org
Date
2016-10-12 11:47:53 -0700 (Wed, 12 Oct 2016)

Log Message

Web Inspector: Improve support for logging Proxy objects in console
https://bugs.webkit.org/show_bug.cgi?id=163323
<rdar://problem/28432553>

Reviewed by Timothy Hatcher.

Source/_javascript_Core:

This is based off of similiar patches in Blink for Proxy handling.

* bindings/ScriptValue.cpp:
(Deprecated::ScriptValue::isEqual):
Use strict equality. This is the intent, and it prevents the possibility of triggering
primitive conversion on objects in previous ConsoleMessage argument lists.

* inspector/InjectedScriptSource.js:
(InjectedScript.prototype._propertyDescriptors):
Bail if the object is a Proxy.

(InjectedScript.prototype._describe):
Provide a friendlier name, "Proxy" instead of "ProxyObject".

(InjectedScript.RemoteObject):
When generating a preview for a Proxy object, generate it from the final target
and mark it as lossy so that the object can always be expanded to get the internal
target/handler properties.

* inspector/JSInjectedScriptHost.h:
* inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::subtype):
New subtype for Proxy objects.

(Inspector::JSInjectedScriptHost::proxyTargetValue):
Resolve the final target value for a Proxy.

* inspector/JSInjectedScriptHostPrototype.cpp:
(Inspector::JSInjectedScriptHostPrototype::finishCreation):
(Inspector::jsInjectedScriptHostPrototypeFunctionProxyTargetValue):
Add the new method.

* inspector/ScriptArguments.cpp:
(Inspector::ScriptArguments::getFirstArgumentAsString):
Avoid triggering Proxy traps on a Proxy object when getting a quick
string description for ConsoleMessages.

* inspector/protocol/Runtime.json:
Add new "proxy" subtype.

Source/WebInspectorUI:

* UserInterface/Views/ConsoleMessageView.js:
(WebInspector.ConsoleMessageView.prototype._formatParameter):
Treat a Proxy like any other object.

LayoutTests:

* inspector/console/console-log-proxy-expected.txt: Added.
* inspector/console/console-log-proxy.html: Added.
Add a test specific to console logs of Proxy objects to ensure the get
trap is not used in different cases.

* inspector/model/remote-object-expected.txt:
* inspector/model/remote-object.html:
* platform/mac/inspector/model/remote-object-expected.txt:
Update results for Proxy objects and include a test for a multi-level
Proxy object, which should preview the target.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207228 => 207229)


--- trunk/LayoutTests/ChangeLog	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/LayoutTests/ChangeLog	2016-10-12 18:47:53 UTC (rev 207229)
@@ -1,5 +1,24 @@
 2016-10-12  Joseph Pecoraro  <pecor...@apple.com>
 
+        Web Inspector: Improve support for logging Proxy objects in console
+        https://bugs.webkit.org/show_bug.cgi?id=163323
+        <rdar://problem/28432553>
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/console/console-log-proxy-expected.txt: Added.
+        * inspector/console/console-log-proxy.html: Added.
+        Add a test specific to console logs of Proxy objects to ensure the get
+        trap is not used in different cases.
+
+        * inspector/model/remote-object-expected.txt:
+        * inspector/model/remote-object.html:
+        * platform/mac/inspector/model/remote-object-expected.txt:
+        Update results for Proxy objects and include a test for a multi-level
+        Proxy object, which should preview the target.
+
+2016-10-12  Joseph Pecoraro  <pecor...@apple.com>
+
         Emit DebugHooks uniformly with pause locations instead of having separate pause locations and op_debug emits
         https://bugs.webkit.org/show_bug.cgi?id=162809
 

Added: trunk/LayoutTests/inspector/console/console-log-proxy-expected.txt (0 => 207229)


--- trunk/LayoutTests/inspector/console/console-log-proxy-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/console-log-proxy-expected.txt	2016-10-12 18:47:53 UTC (rev 207229)
@@ -0,0 +1,14 @@
+CONSOLE MESSAGE: line 16: [object Proxy]
+CONSOLE MESSAGE: line 30: 0
+CONSOLE MESSAGE: line 31: [object Proxy]
+CONSOLE MESSAGE: line 32: 1
+Tests for the console.log with Proxy objects.
+
+
+== Running test suite: console.log.proxy
+-- Running test case: BasicProxyLog
+PASS: Logging Proxy objects should not have triggered get trap.
+
+-- Running test case: AvoidTrapWhenCheckingConsoleRepeat
+PASS: Logging Proxy objects and primitives should not have triggered get trap.
+

Added: trunk/LayoutTests/inspector/console/console-log-proxy.html (0 => 207229)


--- trunk/LayoutTests/inspector/console/console-log-proxy.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/console-log-proxy.html	2016-10-12 18:47:53 UTC (rev 207229)
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function triggerProxyConsoleLog() {
+    window.accessedHandlerGet = false;
+
+    let proxy = new Proxy({foo: 1}, {
+        get(target, name, receiver) {
+            window.accessedHandlerGet = true;
+            return target[name];
+        }
+    });
+
+    console.log(proxy);
+}
+
+function triggerProxyAndPrimitiveConsoleLog() {
+    window.accessedHandlerGet = false;
+
+    let proxy = new Proxy({bar: 2}, {
+        get(target, name, receiver) {
+            window.accessedHandlerGet = true;
+            console.log(1);
+            return target[name];
+        }
+    });
+
+    console.log(0);
+    console.log(proxy);
+    console.log(1);
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("console.log.proxy");
+
+    suite.addTestCase({
+        name: "BasicProxyLog",
+        description: "console.log of a Proxy object should not trigger proxy get trap.",
+        test(resolve, reject) {
+            InspectorTest.evaluateInPage("triggerProxyConsoleLog()", () => {
+                InspectorTest.evaluateInPage("window.accessedHandlerGet", (error, result) => {
+                    let value = WebInspector.RemoteObject.fromPayload(result).value;
+                    InspectorTest.expectEqual(value, false, "Logging Proxy objects should not have triggered get trap.");
+                    resolve();
+                });
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "AvoidTrapWhenCheckingConsoleRepeat",
+        description: "console.log repeat checking should not trigger proxy get trap.",
+        test(resolve, reject) {
+            InspectorTest.evaluateInPage("triggerProxyAndPrimitiveConsoleLog()", () => {
+                InspectorTest.evaluateInPage("window.accessedHandlerGet", (error, result) => {
+                    let value = WebInspector.RemoteObject.fromPayload(result).value;
+                    InspectorTest.expectEqual(value, false, "Logging Proxy objects and primitives should not have triggered get trap.");
+                    resolve();
+                });
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests for the console.log with Proxy objects.</p>
+</body>
+</html>

Modified: trunk/LayoutTests/inspector/model/remote-object-expected.txt (207228 => 207229)


--- trunk/LayoutTests/inspector/model/remote-object-expected.txt	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/LayoutTests/inspector/model/remote-object-expected.txt	2016-10-12 18:47:53 UTC (rev 207229)
@@ -4659,64 +4659,28 @@
 _expression_: new Proxy({x:1, y:1}, {handler: true})
 {
   "_type": "object",
+  "_subtype": "proxy",
   "_objectId": "<filtered>",
-  "_description": "ProxyObject",
+  "_description": "Proxy",
   "_preview": {
     "_listeners": null,
     "_type": "object",
-    "_description": "ProxyObject",
-    "_lossless": true,
+    "_subtype": "proxy",
+    "_description": "Proxy",
+    "_lossless": false,
     "_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
+        "_name": "x",
+        "_type": "number",
+        "_value": "1"
       },
       {
         "_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
+        "_name": "y",
+        "_type": "number",
+        "_value": "1"
       }
     ],
     "_entries": null
@@ -4724,6 +4688,38 @@
 }
 
 -----------------------------------------------------
+_expression_: new Proxy(new Proxy({foo:1, bar:1}, {}), {})
+{
+  "_type": "object",
+  "_subtype": "proxy",
+  "_objectId": "<filtered>",
+  "_description": "Proxy",
+  "_preview": {
+    "_listeners": null,
+    "_type": "object",
+    "_subtype": "proxy",
+    "_description": "Proxy",
+    "_lossless": false,
+    "_overflow": false,
+    "_properties": [
+      {
+        "_listeners": null,
+        "_name": "foo",
+        "_type": "number",
+        "_value": "1"
+      },
+      {
+        "_listeners": null,
+        "_name": "bar",
+        "_type": "number",
+        "_value": "1"
+      }
+    ],
+    "_entries": null
+  }
+}
+
+-----------------------------------------------------
 _expression_: Person = class Person { constructor(name){} get fullName(){} methodName(p1, p2){} }; Person
 {
   "_type": "function",

Modified: trunk/LayoutTests/inspector/model/remote-object.html (207228 => 207229)


--- trunk/LayoutTests/inspector/model/remote-object.html	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/LayoutTests/inspector/model/remote-object.html	2016-10-12 18:47:53 UTC (rev 207229)
@@ -170,6 +170,7 @@
 
         // Proxy
         {_expression_: "new Proxy({x:1, y:1}, {handler: true})"},
+        {_expression_: "new Proxy(new Proxy({foo:1, bar:1}, {}), {})"},
 
     // Classes
 

Modified: trunk/LayoutTests/platform/mac/inspector/model/remote-object-expected.txt (207228 => 207229)


--- trunk/LayoutTests/platform/mac/inspector/model/remote-object-expected.txt	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/LayoutTests/platform/mac/inspector/model/remote-object-expected.txt	2016-10-12 18:47:53 UTC (rev 207229)
@@ -4660,74 +4660,58 @@
 _expression_: new Proxy({x:1, y:1}, {handler: true})
 {
   "_type": "object",
+  "_subtype": "proxy",
   "_objectId": "<filtered>",
-  "_description": "ProxyObject",
+  "_description": "Proxy",
   "_preview": {
     "_listeners": null,
     "_type": "object",
-    "_description": "ProxyObject",
-    "_lossless": true,
+    "_subtype": "proxy",
+    "_description": "Proxy",
+    "_lossless": false,
     "_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
+        "_name": "x",
+        "_type": "number",
+        "_value": "1"
       },
       {
         "_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
-      },
+        "_name": "y",
+        "_type": "number",
+        "_value": "1"
+      }
+    ],
+    "_entries": null
+  }
+}
+
+-----------------------------------------------------
+_expression_: new Proxy(new Proxy({foo:1, bar:1}, {}), {})
+{
+  "_type": "object",
+  "_subtype": "proxy",
+  "_objectId": "<filtered>",
+  "_description": "Proxy",
+  "_preview": {
+    "_listeners": null,
+    "_type": "object",
+    "_subtype": "proxy",
+    "_description": "Proxy",
+    "_lossless": false,
+    "_overflow": false,
+    "_properties": [
       {
         "_listeners": null,
-        "_name": "x",
+        "_name": "foo",
         "_type": "number",
         "_value": "1"
       },
       {
         "_listeners": null,
-        "_name": "y",
+        "_name": "bar",
         "_type": "number",
         "_value": "1"
       }

Modified: trunk/Source/_javascript_Core/ChangeLog (207228 => 207229)


--- trunk/Source/_javascript_Core/ChangeLog	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-10-12 18:47:53 UTC (rev 207229)
@@ -1,5 +1,53 @@
 2016-10-12  Joseph Pecoraro  <pecor...@apple.com>
 
+        Web Inspector: Improve support for logging Proxy objects in console
+        https://bugs.webkit.org/show_bug.cgi?id=163323
+        <rdar://problem/28432553>
+
+        Reviewed by Timothy Hatcher.
+
+        This is based off of similiar patches in Blink for Proxy handling.
+
+        * bindings/ScriptValue.cpp:
+        (Deprecated::ScriptValue::isEqual):
+        Use strict equality. This is the intent, and it prevents the possibility of triggering
+        primitive conversion on objects in previous ConsoleMessage argument lists.
+
+        * inspector/InjectedScriptSource.js:
+        (InjectedScript.prototype._propertyDescriptors):
+        Bail if the object is a Proxy.
+
+        (InjectedScript.prototype._describe):
+        Provide a friendlier name, "Proxy" instead of "ProxyObject".
+        
+        (InjectedScript.RemoteObject):
+        When generating a preview for a Proxy object, generate it from the final target
+        and mark it as lossy so that the object can always be expanded to get the internal
+        target/handler properties.
+
+        * inspector/JSInjectedScriptHost.h:
+        * inspector/JSInjectedScriptHost.cpp:
+        (Inspector::JSInjectedScriptHost::subtype):
+        New subtype for Proxy objects.
+
+        (Inspector::JSInjectedScriptHost::proxyTargetValue):
+        Resolve the final target value for a Proxy.
+
+        * inspector/JSInjectedScriptHostPrototype.cpp:
+        (Inspector::JSInjectedScriptHostPrototype::finishCreation):
+        (Inspector::jsInjectedScriptHostPrototypeFunctionProxyTargetValue):
+        Add the new method.
+
+        * inspector/ScriptArguments.cpp:
+        (Inspector::ScriptArguments::getFirstArgumentAsString):
+        Avoid triggering Proxy traps on a Proxy object when getting a quick
+        string description for ConsoleMessages.
+
+        * inspector/protocol/Runtime.json:
+        Add new "proxy" subtype.
+
+2016-10-12  Joseph Pecoraro  <pecor...@apple.com>
+
         Emit DebugHooks uniformly with pause locations instead of having separate pause locations and op_debug emits
         https://bugs.webkit.org/show_bug.cgi?id=162809
 

Modified: trunk/Source/_javascript_Core/bindings/ScriptValue.cpp (207228 => 207229)


--- trunk/Source/_javascript_Core/bindings/ScriptValue.cpp	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/_javascript_Core/bindings/ScriptValue.cpp	2016-10-12 18:47:53 UTC (rev 207229)
@@ -135,7 +135,7 @@
 {
     if (hasNoValue())
         return anotherValue.hasNoValue();
-    return JSValueIsEqual(toRef(scriptState), toRef(scriptState, jsValue()), toRef(scriptState, anotherValue.jsValue()), nullptr);
+    return JSValueIsStrictEqual(toRef(scriptState), toRef(scriptState, jsValue()), toRef(scriptState, anotherValue.jsValue()));
 }
 
 bool ScriptValue::isNull() const

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (207228 => 207229)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2016-10-12 18:47:53 UTC (rev 207229)
@@ -574,6 +574,9 @@
 
     _propertyDescriptors: function(object, collectionMode, nativeGettersAsValues)
     {
+        if (InjectedScriptHost.subtype(object) === "proxy")
+            return [];
+
         var descriptors = [];
         var nameProcessed = new Set;
 
@@ -732,8 +735,7 @@
         try {
             if (typeof obj.splice === "function" && isFinite(obj.length))
                 return "array";
-        } catch (e) {
-        }
+        } catch (e) {}
 
         return null;
     },
@@ -791,6 +793,9 @@
         if (subtype === "error")
             return toString(obj);
 
+        if (subtype === "proxy")
+            return "Proxy";
+
         if (subtype === "node")
             return this._nodePreview(obj);
 
@@ -958,8 +963,13 @@
         this.className = object.name;
     }
 
-    if (generatePreview && this.type === "object")
-        this.preview = this._generatePreview(object, undefined, columnNames);
+    if (generatePreview && this.type === "object") {
+        if (subtype === "proxy") {
+            this.preview = this._generatePreview(InjectedScriptHost.proxyTargetValue(object));
+            this.preview.lossless = false;
+        } else
+            this.preview = this._generatePreview(object, undefined, columnNames);
+    }
 };
 
 InjectedScript.RemoteObject.createObjectPreviewForValue = function(value, generatePreview)

Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp (207228 => 207229)


--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp	2016-10-12 18:47:53 UTC (rev 207229)
@@ -167,6 +167,8 @@
         return jsNontrivialString(exec, ASCIILiteral("date"));
     if (value.inherits(RegExpObject::info()))
         return jsNontrivialString(exec, ASCIILiteral("regexp"));
+    if (value.inherits(ProxyObject::info()))
+        return jsNontrivialString(exec, ASCIILiteral("proxy"));
 
     if (value.inherits(JSMap::info()))
         return jsNontrivialString(exec, ASCIILiteral("map"));
@@ -377,6 +379,23 @@
     return jsUndefined();
 }
 
+JSValue JSInjectedScriptHost::proxyTargetValue(ExecState *exec)
+{
+    if (exec->argumentCount() < 1)
+        return jsUndefined();
+
+    JSValue value = exec->uncheckedArgument(0);
+    ProxyObject* proxy = jsDynamicCast<ProxyObject*>(value);
+    if (!proxy)
+        return jsUndefined();
+
+    JSObject* target = proxy->target();
+    while (ProxyObject* proxy = jsDynamicCast<ProxyObject*>(target))
+        target = proxy->target();
+
+    return target;
+}
+
 JSValue JSInjectedScriptHost::weakMapSize(ExecState* exec)
 {
     if (exec->argumentCount() < 1)

Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.h (207228 => 207229)


--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.h	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.h	2016-10-12 18:47:53 UTC (rev 207229)
@@ -65,6 +65,7 @@
     JSC::JSValue subtype(JSC::ExecState*);
     JSC::JSValue functionDetails(JSC::ExecState*);
     JSC::JSValue getInternalProperties(JSC::ExecState*);
+    JSC::JSValue proxyTargetValue(JSC::ExecState*);
     JSC::JSValue weakMapSize(JSC::ExecState*);
     JSC::JSValue weakMapEntries(JSC::ExecState*);
     JSC::JSValue weakSetSize(JSC::ExecState*);

Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp (207228 => 207229)


--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHostPrototype.cpp	2016-10-12 18:47:53 UTC (rev 207229)
@@ -43,6 +43,7 @@
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionGetInternalProperties(ExecState*);
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionInternalConstructorName(ExecState*);
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection(ExecState*);
+static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionProxyTargetValue(ExecState*);
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState*);
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapEntries(ExecState*);
 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetSize(ExecState*);
@@ -65,6 +66,7 @@
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("getInternalProperties", jsInjectedScriptHostPrototypeFunctionGetInternalProperties, DontEnum, 1);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("internalConstructorName", jsInjectedScriptHostPrototypeFunctionInternalConstructorName, DontEnum, 1);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("isHTMLAllCollection", jsInjectedScriptHostPrototypeFunctionIsHTMLAllCollection, DontEnum, 1);
+    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("proxyTargetValue", jsInjectedScriptHostPrototypeFunctionProxyTargetValue, DontEnum, 1);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakMapSize", jsInjectedScriptHostPrototypeFunctionWeakMapSize, DontEnum, 1);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakMapEntries", jsInjectedScriptHostPrototypeFunctionWeakMapEntries, DontEnum, 1);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("weakSetSize", jsInjectedScriptHostPrototypeFunctionWeakSetSize, DontEnum, 1);
@@ -114,6 +116,19 @@
     return JSValue::encode(castedThis->isHTMLAllCollection(exec));
 }
 
+EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionProxyTargetValue(ExecState* exec)
+{
+    VM& vm = exec->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    JSValue thisValue = exec->thisValue();
+    JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(thisValue);
+    if (!castedThis)
+        return throwVMTypeError(exec, scope);
+
+    return JSValue::encode(castedThis->proxyTargetValue(exec));
+}
+
 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakMapSize(ExecState* exec)
 {
     VM& vm = exec->vm();

Modified: trunk/Source/_javascript_Core/inspector/ScriptArguments.cpp (207228 => 207229)


--- trunk/Source/_javascript_Core/inspector/ScriptArguments.cpp	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/_javascript_Core/inspector/ScriptArguments.cpp	2016-10-12 18:47:53 UTC (rev 207229)
@@ -33,6 +33,7 @@
 #include "ScriptArguments.h"
 
 #include "JSCInlines.h"
+#include "ProxyObject.h"
 #include "ScriptValue.h"
 
 namespace Inspector {
@@ -86,6 +87,12 @@
         return false;
     }
 
+    JSC::JSValue value = argumentAt(0).jsValue();
+    if (JSC::jsDynamicCast<JSC::ProxyObject*>(value)) {
+        result = ASCIILiteral("[object Proxy]");
+        return true;
+    }
+
     result = argumentAt(0).toString(globalState());
     return true;
 }

Modified: trunk/Source/_javascript_Core/inspector/protocol/Runtime.json (207228 => 207229)


--- trunk/Source/_javascript_Core/inspector/protocol/Runtime.json	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/_javascript_Core/inspector/protocol/Runtime.json	2016-10-12 18:47:53 UTC (rev 207229)
@@ -13,7 +13,7 @@
             "description": "Mirror object referencing original _javascript_ object.",
             "properties": [
                 { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." },
-                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "weakset", "iterator", "class"], "description": "Object subtype hint. Specified for <code>object</code> <code>function</code> (for class) type values only." },
+                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "weakset", "iterator", "class", "proxy"], "description": "Object subtype hint. Specified for <code>object</code> <code>function</code> (for class) type values only." },
                 { "name": "className", "type": "string", "optional": true, "description": "Object class (constructor) name. Specified for <code>object</code> type values only." },
                 { "name": "value", "type": "any", "optional": true, "description": "Remote object value (in case of primitive values or JSON values if it was requested)." },
                 { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
@@ -29,7 +29,7 @@
             "description": "Object containing abbreviated remote object value.",
             "properties": [
                 { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." },
-                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "weakset", "iterator", "class"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
+                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "weakset", "iterator", "class", "proxy"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
                 { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
                 { "name": "lossless", "type": "boolean", "description": "Determines whether preview is lossless (contains all information of the original object)." },
                 { "name": "overflow", "type": "boolean", "optional": true, "description": "True iff some of the properties of the original did not fit." },
@@ -44,7 +44,7 @@
             "properties": [
                 { "name": "name", "type": "string", "description": "Property name." },
                 { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor"], "description": "Object type." },
-                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "weakset", "iterator", "class"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
+                { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap", "weakset", "iterator", "class", "proxy"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
                 { "name": "value", "type": "string", "optional": true, "description": "User-friendly property value string." },
                 { "name": "valuePreview", "$ref": "ObjectPreview", "optional": true, "description": "Nested value preview." },
                 { "name": "internal", "type": "boolean", "optional": true, "description": "True if this is an internal property." }

Modified: trunk/Source/WebInspectorUI/ChangeLog (207228 => 207229)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-10-12 18:47:53 UTC (rev 207229)
@@ -1,5 +1,17 @@
 2016-10-12  Joseph Pecoraro  <pecor...@apple.com>
 
+        Web Inspector: Improve support for logging Proxy objects in console
+        https://bugs.webkit.org/show_bug.cgi?id=163323
+        <rdar://problem/28432553>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/ConsoleMessageView.js:
+        (WebInspector.ConsoleMessageView.prototype._formatParameter):
+        Treat a Proxy like any other object.
+
+2016-10-12  Joseph Pecoraro  <pecor...@apple.com>
+
         Emit DebugHooks uniformly with pause locations instead of having separate pause locations and op_debug emits
         https://bugs.webkit.org/show_bug.cgi?id=162809
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (207228 => 207229)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2016-10-12 18:47:48 UTC (rev 207228)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2016-10-12 18:47:53 UTC (rev 207229)
@@ -536,6 +536,7 @@
             "weakset": this._formatParameterAsObject,
             "iterator": this._formatParameterAsObject,
             "class": this._formatParameterAsObject,
+            "proxy": this._formatParameterAsObject,
             "array": this._formatParameterAsArray,
             "node": this._formatParameterAsNode,
             "string": this._formatParameterAsString,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to