Closed
Bug 1424722
Opened 7 years ago
Closed 7 years ago
Create actors for symbol values
Categories
(DevTools :: Console, enhancement)
DevTools
Console
Tracking
(firefox59 fixed)
RESOLVED
FIXED
Firefox 59
Tracking | Status | |
---|---|---|
firefox59 | --- | fixed |
People
(Reporter: Oriol, Assigned: Oriol)
References
Details
Attachments
(1 file)
Necessary to be able to store logged symbols as variables (bug 1396434).
Comment hidden (mozreview-request) |
Assignee | ||
Comment 2•7 years ago
|
||
So this patch seems to do the trick (mostly I copied the code for longStrings).
The problem is that then reps display the symbol as "Object { }".
I filed https://github.com/devtools-html/devtools-core/issues/842.
Comment hidden (mozreview-request) |
Assignee | ||
Comment 4•7 years ago
|
||
Should I add a server unit test?
Note symbols still can't be stored in a global variable, this will be tested in bug 1396434.
Assignee: nobody → oriol-bugzilla
Status: NEW → ASSIGNED
Comment 5•7 years ago
|
||
Yes, a server unit test would be nice to make sure the packet do have a string "actor" property
Comment 6•7 years ago
|
||
mozreview-review |
Comment on attachment 8936254 [details]
Bug 1424722 - Create actors for symbol values.
https://reviewboard.mozilla.org/r/207016/#review215330
Thanks for the patch Oriol. This definitely needs tests to make sure everything works as expected (hence the r-).
Also, I am not sure we need to create a specific class for symbol actors, but there's probably a good reason you did it, so let's discuss :)
::: devtools/server/actors/object.js:2339
(Diff revision 2)
> "substring": LongStringActor.prototype.onSubstring,
> "release": LongStringActor.prototype.onRelease
> };
>
> /**
> + * Creates an actor for the specied symbol.
should it be "specified" ?
::: devtools/server/actors/object.js:2372
(Diff revision 2)
> + type: "symbol",
> + actor: this.actorID,
> + };
> + let name = getSymbolName(this.symbol);
> + if (name !== undefined) {
> + form.name = createValueGrip(name, this.registeredPool);
Maybe say we are creating a grip for the name because it might be a longString ?
::: devtools/server/actors/object.js:2382
(Diff revision 2)
> + /**
> + * Handle a request to release this SymbolActor instance.
> + */
> + onRelease: function () {
> + // TODO: also check if registeredPool === threadActor.threadLifetimePool
> + // when the web console moves aray from manually releasing pause-scoped
s/aray/away
::: devtools/server/actors/object.js:2498
(Diff revision 2)
> - let form = {
> + return symbolGrip(value, pool);
> - type: "symbol"
> - };
> - let name = getSymbolName(value);
> - if (name !== undefined) {
> - form.name = createValueGrip(name, pool, makeObjectGrip);
> - }
> - return form;
Why do we need to create a new SymbolActor "class" ? I may be missing something but it does not seem to have specific method in comparison to the ObjectActor.
Attachment #8936254 -
Flags: review?(nchevobbe) → review-
Assignee | ||
Comment 7•7 years ago
|
||
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #6)
> Why do we need to create a new SymbolActor "class" ? I may be missing
> something but it does not seem to have specific method in comparison to the
> ObjectActor.
I just copied what LongStringActor does. And some methods are still needed, like rawValue() when storing as a global variable.
Comment 8•7 years ago
|
||
(In reply to Oriol Brufau [:Oriol] from comment #7)
> (In reply to Nicolas Chevobbe [:nchevobbe] from comment #6)
> > Why do we need to create a new SymbolActor "class" ? I may be missing
> > something but it does not seem to have specific method in comparison to the
> > ObjectActor.
>
> I just copied what LongStringActor does. And some methods are still needed,
> like rawValue() when storing as a global variable.
And couldn't this be achived by https://searchfox.org/mozilla-central/rev/51cd1093c5c2113e7b041e8cc5c9bf2186abda13/devtools/server/actors/object.js#72-74 ? I am genuinely asking, I don't have much experience with unsafeDereference.
If not, I'll be happy to r+ this patch once we have tests for it (getting a grip, checking the .symbolActors object, ensuring releaseActors does what it should, ...)
I don't think we have good testing for the other actors at the moment, but this would be nice to start with symbols.
Assignee | ||
Comment 9•7 years ago
|
||
No, unsafeDereference is a Debugger.Object method. But Debugger.Object objects can only refer to objects, not primitives like symbols, e.g.
Components.utils.import('resource://gre/modules/jsdebugger.jsm');
addDebuggerToGlobal(this);
var global = Cu.Sandbox(null);
var dbg = new Debugger().addDebuggee(global);
var value = Symbol();
dbg.makeDebuggeeValue(value) === value; // true
It should be possible to reuse more code with a class based approach where some actor classes extend others, e.g.
- BasicActor
- PrimitiveActor
- LongStringActor
- SymbolActor
- ArrayBufferActor
- ObjectActor
But this would require some refactoring.
Comment 10•7 years ago
|
||
(In reply to Oriol Brufau [:Oriol] from comment #9)
> No, unsafeDereference is a Debugger.Object method. But Debugger.Object
> objects can only refer to objects, not primitives like symbols, e.g.
>
> Components.utils.import('resource://gre/modules/jsdebugger.jsm');
> addDebuggerToGlobal(this);
> var global = Cu.Sandbox(null);
> var dbg = new Debugger().addDebuggee(global);
> var value = Symbol();
> dbg.makeDebuggeeValue(value) === value; // true
>
> It should be possible to reuse more code with a class based approach where
> some actor classes extend others, e.g.
>
> - BasicActor
> - PrimitiveActor
> - LongStringActor
> - SymbolActor
> - ArrayBufferActor
> - ObjectActor
>
> But this would require some refactoring.
Yes, I agree it would be too much work and not really in the scope of this bug. Let's add unit tests and land your patch ;)
Comment hidden (mozreview-request) |
Assignee | ||
Comment 12•7 years ago
|
||
The test is based on test_longstringactor.js
Comment 13•7 years ago
|
||
mozreview-review |
Comment on attachment 8936254 [details]
Bug 1424722 - Create actors for symbol values.
https://reviewboard.mozilla.org/r/207016/#review216128
Looks good and TRY is green, so let's land this.
Thanks Oriol !
Attachment #8936254 -
Flags: review?(nchevobbe) → review+
Comment 14•7 years ago
|
||
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c9cf2b131951
Create actors for symbol values. r=nchevobbe
Comment 15•7 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox59:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 59
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•