Closed Bug 1499679 Opened 6 years ago Closed 4 years ago

Display private fields in ObjectInspector

Categories

(DevTools :: Object Inspector, task, P2)

task

Tracking

(firefox90 fixed)

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

Details

Attachments

(3 files)

With Bug 1499448, we'll be able to declare private fields on ES classes. Given the following piece of code: ```js class MyClass { #myPrivate = "this is private"; myPublic = "this is public"; } const x = new MyClass(); x; ``` we should provide a way for the user to access the `#myPrivate` property. This could be by directly showing them in the console output: > → x; > ← ▶︎ myClass { myPublic: "this is public", #myPrivate: "this is private" } We might not want to show them directly as the can be confused with public properties, but could give access when inspecting the object: > → x; > ← ▼ myClass > | myPublic: "this is public" > | ▼ <private> > | | #myPrivate: "this is private" > | ▶︎ <prototype>
Summary: Expose instance fields in Console → Expose ES.next class instance fields in Console
Severity: normal → major
Priority: -- → P2

public fields are displayed just fine for now, and private fields are not enabled (see Bug 1562054)

Depends on: private-fields
Type: enhancement → task

I just noticed this bug! Bug 1650188 may be a dupe of this (though, that bug also includes point about the result computation system)

It would be great to do something similar to what Chrome is doing.
Matthew, do you have an idea of how much work there is on the platform to provide a way for DevTools to retrieve the private fields and their value?

Flags: needinfo?(mgaudet)

So, the functionality is at least partially already extant.

From devtools perspective, I'm not sure what things look like, but from the JSAPI side, you're looking at a call to js::GetPropertyKeys, and you just need to add JSITER_PRIVATE to the flags to have it include private names in the list.

Flags: needinfo?(mgaudet)

Getting values should just be a matter of calling GetOwnProperty with the private name JSID.

Depends on: 1711859
Component: Console → Object Inspector
Summary: Expose ES.next class instance fields in Console → Display private fields in ObjectInspector
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Blocks: 1650188
No longer depends on: private-fields

This patch makes use of the new getOwnPrivateProperties method on DebuggerObject
to include private properties in object grip preview.

We're also adding a PrivatePropertiesIterator actor (and associated front) that
will allow us to retrieve all the private properties (e.g. when expanding an
object in the ObjectInspector).

A xpcshell test is added to ensure we do return the expected properties.

This patch surface the private properties in Reps and in the ObjectInspector.
Tests cases are added to cover the basic behaviors we want to have in the
same version private fields are shipped in (90).

Depends on D114373

assertPreviews was hovering over a token and then checking the Redux store in
order to assert what should be in the popup. This can be a bit brittle and it's
probably safer to check what's rendered in the DOM, as it directly maps to what's
shown to the user.
Some unused or irrelevant test helpers are removed, and tests are updated accordingly.

Depends on D115702

Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f1b290559447 [devtools] Add PrivatePropertiesIterator actor to retrieve private properties of a given object. r=bomsy,devtools-backward-compat-reviewers. https://hg.mozilla.org/integration/autoland/rev/31e604725431 [devtools] Check the DOM instead of Redux store in assertPreviews. r=bomsy. https://hg.mozilla.org/integration/autoland/rev/92356fb78f95 [devtools] Display private properties in ObjectInspector. r=bomsy,devtools-backward-compat-reviewers.
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: