Ignore:
Timestamp:
Oct 12, 2016, 11:47:53 AM (9 years ago)
Author:
Joseph Pecoraro
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/JavaScriptCore:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp

    r205569 r207229  
    136136    if (hasNoValue())
    137137        return anotherValue.hasNoValue();
    138     return JSValueIsEqual(toRef(scriptState), toRef(scriptState, jsValue()), toRef(scriptState, anotherValue.jsValue()), nullptr);
     138    return JSValueIsStrictEqual(toRef(scriptState), toRef(scriptState, jsValue()), toRef(scriptState, anotherValue.jsValue()));
    139139}
    140140
Note: See TracChangeset for help on using the changeset viewer.