RESOLVED FIXED 163323
Web Inspector: Improve support for logging Proxy objects in console
https://bugs.webkit.org/show_bug.cgi?id=163323
Summary Web Inspector: Improve support for logging Proxy objects in console
Joseph Pecoraro
Reported 2016-10-12 00:16:22 PDT
Summary: Improve support for logging Proxy objects in console - Avoid accessing Proxy traps where possible - Display "Proxy" but preview the target value since that is what users will want - Expanding should show Internal [[Target]] and [[Handler]] properties Test: <script> console.log(new Proxy({foo:1}, { get() { alert('error'); } }); </script>
Attachments
[PATCH] Proposed Fix (25.89 KB, patch)
2016-10-12 00:24 PDT, Joseph Pecoraro
no flags
[PATCH] Proposed Fix (27.19 KB, patch)
2016-10-12 11:25 PDT, Joseph Pecoraro
timothy: review+
Joseph Pecoraro
Comment 1 2016-10-12 00:16:31 PDT
Joseph Pecoraro
Comment 2 2016-10-12 00:24:04 PDT
Created attachment 291343 [details] [PATCH] Proposed Fix
Saam Barati
Comment 3 2016-10-12 00:35:34 PDT
Comment on attachment 291343 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=291343&action=review > Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp:393 > + while (ProxyObject* proxy = jsDynamicCast<ProxyObject*>(target)) Would it ever be worth showing the intermediate Proxy tree or is it worth reviewing until we find a non-proxy target?
Saam Barati
Comment 4 2016-10-12 00:38:05 PDT
Comment on attachment 291343 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=291343&action=review > Source/JavaScriptCore/bindings/ScriptValue.cpp:138 > + return JSValueIsStrictEqual(toRef(scriptState), toRef(scriptState, jsValue()), toRef(scriptState, anotherValue.jsValue())); Maybe it's worth adding a test here like where you log an object followed by a number and ensure that valueOf isn't called in the object?
Joseph Pecoraro
Comment 5 2016-10-12 00:41:38 PDT
Comment on attachment 291343 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=291343&action=review >> Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp:393 >> + while (ProxyObject* proxy = jsDynamicCast<ProxyObject*>(target)) > > Would it ever be worth showing the intermediate Proxy tree or is it worth reviewing until we find a non-proxy target? Expanding a Proxy object will show you the full Proxy tree. However the initial preview will show the final target value. For example: var innerProxy = new Proxy({foo:1, bar:2}, {}); var outerProxy = new Proxy(innerProxy, {}); Logging just the outerProxy would show something immediately useful like: ▶︎ Proxy {foo: 1, bar: 2} Expanding the Proxy would show [[Target]] and [[Handler]] so you get the full tree: ▼ Proxy handler: {} target: ▼ Proxy handler: {} target: {foo: 1, bar: 2}
Joseph Pecoraro
Comment 6 2016-10-12 11:25:02 PDT
Comment on attachment 291343 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=291343&action=review >> Source/JavaScriptCore/bindings/ScriptValue.cpp:138 >> + return JSValueIsStrictEqual(toRef(scriptState), toRef(scriptState, jsValue()), toRef(scriptState, anotherValue.jsValue())); > > Maybe it's worth adding a test here like where you log an object followed by a number and ensure that valueOf isn't called in the object? I'll add a test.
Joseph Pecoraro
Comment 7 2016-10-12 11:25:58 PDT
Created attachment 291372 [details] [PATCH] Proposed Fix
Joseph Pecoraro
Comment 8 2016-10-15 00:27:03 PDT
Note You need to log in before you can comment on or make changes to this bug.