Closed Bug 1351635 Opened 8 years ago Closed 5 years ago

Returns ES6 class information in Grip

Categories

(DevTools :: Console, enhancement, P3)

50 Branch
enhancement

Tracking

(firefox72 fixed)

RESOLVED FIXED
Firefox 72
Tracking Status
firefox72 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

Details

Attachments

(1 file)

At the moment, there's no way to tell if a Grip represent an ES6 class [1]. The grip labels it as a function, which, even if correct, does not convey much meanings for the users (and could be misleading since you can't call it without the `new` keyword). It would be nice if we could return in the grip if we are dealing with a class, and maybe what class it extends. I'm not sure but it looks like the changes we'd have to do can happen in this function : http://searchfox.org/mozilla-central/source/devtools/server/actors/object.js#1117-1155 [1] Grip example : ``` { "from": "server2.conn5.child1/consoleActor2", "input": "(class A{})", "result": { "type": "object", "actor": "server2.conn5.child1/obj32", "class": "Function", "extensible": true, "frozen": false, "sealed": false, "name": "A", "displayName": "A" }, "timestamp": 1490770293758, "exception": null, "frame": null, "helperResult": null, "notes": null } ```
Thinking about this a little more, I think we could even have all the method, and if they are static or not so we can do a better job at representing classes. We could do the same thing that we do for plain object, which is having a `preview` property that exposes those additional information. This could looks like: ``` { "from": "server2.conn2.child1/consoleActor2", "input": "(A = {constructor() {}, eat(){}})", "result": { "type": "object", "actor": "server2.conn5.child1/obj32", "class": "Function", "extensible": true, "frozen": false, "sealed": false, "name": "A", "displayName": "A" "preview": { "kind": "Class", "extends" : {/* extended class or null */}, "methods": { "constructor": { "configurable": true, "enumerable": true, "writable": true, "value": { "type": "object", "actor": "server2.conn2.child1/obj38", "class": "Function", "extensible": true, "frozen": false, "sealed": false, "name": "constructor", "displayName": "constructor", "location": { "url": "debugger eval code", "line": 1 } } }, "eat": { "configurable": true, "enumerable": true, "writable": true, "value": { "type": "object", "actor": "server2.conn2.child1/obj39", "class": "Function", "extensible": true, "frozen": false, "sealed": false, "name": "eat", "displayName": "eat", "location": { "url": "debugger eval code", "line": 1 } } } } } }, "timestamp": 1490788386282, "exception": null, "frame": null, "helperResult": null } ```
Product: Firefox → DevTools
Depends on: 1473473
Blocks: 1592277
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED

A test is added to ensure isClassConstructor has the expected
value for ES6 class grips.

Depends on D50935

Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e54a4d3a92b8 Return isClassConstructor in class grip. r=loganfsmyth.
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 72
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: