Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Web Inspector: Support ES2022 Private Fields
https://bugs.webkit.org/show_bug.cgi?id=254961 <rdar://problem/107863310> Reviewed by Patrick Angle and Justin Michaud. Web Inspector should show private fields when logging objects in the Console. As private field usage becomes more and more popular, not being able to see private fields in the Console will become increasingly disruptive to the debugging experience. * Source/JavaScriptCore/inspector/InjectedScriptSource.js: (InjectedScript.prototype._forEachPropertyDescriptor): (InjectedScript.prototype._forEachPropertyDescriptor.processProperty): * Source/JavaScriptCore/inspector/JSInjectedScriptHost.h: * Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::getOwnPrivatePropertyDescriptors): Added. * Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp: (Inspector::JSInjectedScriptHostPrototype::finishCreation): (Inspector::jsInjectedScriptHostPrototypeFunctionGetOwnPrivatePropertyDescriptors): Added. Create a `InjectedScriptHost` method similar to `Object.getOwnPropertyDescriptors` but only for private fields. Use it when fetching property descriptors for the frontend to grab private fields just like all other public fields. * Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp: (JSC::PropertyListNode::emitDeclarePrivateFieldNames): Pass along the `PropertyNode::name` when creating a private symbol for the private field. * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitCreatePrivateBrand): AFAIK there is no name in this scenario, just a private symbol to mark with a private brand, so use an empty string for the name. * Source/JavaScriptCore/runtime/JSGlobalObject.cpp: (JSC::createPrivateSymbol): (JSC::JSGlobalObject::init): Require a name when calling `@createPrivateSymbol`. * Source/JavaScriptCore/runtime/PrivateName.h: (JSC::PrivateName::PrivateName): Deleted. * Source/JavaScriptCore/runtime/Symbol.cpp: (JSC::Symbol::Symbol): * Source/WTF/wtf/text/SymbolImpl.h: * Source/WTF/wtf/text/SymbolImpl.cpp: (WTF::PrivateSymbolImpl::createNullSymbol): Deleted. * Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp: (WebKit::IPCTestingAPI::JSMessageListener::JSMessageListener): Require that all `PrivateName` and `PrivateSymbolImpl` be created with a name (or at least an empty string). * Source/JavaScriptCore/inspector/protocol/Runtime.json: * Source/WebInspectorUI/UserInterface/Models/PropertyDescriptor.js: (WI.PropertyDescriptor): (WI.PropertyDescriptor.fromPayload): (WI.PropertyDescriptor.get isPrivateProperty): Added. Expose a way for clients to know that this `WI.PropertyDescriptor` is for a private field. * Source/WebInspectorUI/UserInterface/Models/PropertyPath.js: (WI.PropertyPath.prototype.appendPrivatePropertyName): Added. (WI.PropertyPath.prototype.appendPropertyDescriptor): Make sure that private fields are sufficiently hidden (i.e. do not show "Copy Path to Property" since it won't work). * Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js: (WI.ObjectTreeView.comparePropertyDescriptors): Sort private fields above all other non-internal properties. * Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js: (WI.ObjectTreePropertyTreeElement.prototype._createTitlePropertyStyle): * Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.css: (.object-tree-property .property-name:is(.private, .not-enumerable)): Renamed from `.object-tree-property .property-name.not-enumerable`. Display private fields as a greyed out property (similar to internal properties) in order to help emphasize their semi-unreachable nature. * LayoutTests/inspector/runtime/getDisplayableProperties.html: * LayoutTests/inspector/runtime/getDisplayableProperties-expected.txt: * LayoutTests/inspector/runtime/getProperties.html: * LayoutTests/inspector/runtime/getProperties-expected.txt: * LayoutTests/inspector/runtime/resources/property-descriptor-utilities.js: (ProtocolTest.PropertyDescriptorUtilities.logForEach): Canonical link: https://commits.webkit.org/262882@main
- Loading branch information
Showing
23 changed files
with
291 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.