Closed
Bug 656461
Opened 13 years ago
Closed 13 years ago
Web Console calls getters when displaying an object
Categories
(DevTools :: General, defect)
Tracking
(Not tracked)
RESOLVED
INCOMPLETE
People
(Reporter: mossop, Assigned: past)
Details
If you have a page with something like this: var OBJ = { get foo() { return "bar"; } } If you then evaluate "OBJ" in the webconsole it will display something like this: ({foo:"bar"}) Clearly it is calling the getter to get that value. In this case that isn't a big deal but getters can mutate the underlying object or really do anything if the developer is a bit loopy, and as a rule inspection tools shouldn't be accidentally mutating the object.
Assignee | ||
Updated•13 years ago
|
Assignee: nobody → past
Status: NEW → ASSIGNED
Assignee | ||
Comment 1•13 years ago
|
||
Unless I am missing something here, we are not calling the getter in this case, we just evaluate OBJ in a sandbox and then call OBJ.toSource() in order to display the result. I have used a slightly modified version of the above to verify this: var OBJ = { get foo() { alert(1); delete OBJ.foo; return "bar"; } } In the following session OBJ.foo is never called, unless I explicitly reference it: [12:35:56.147] file:///Users/past/foo.html [12:35:58.737] OBJ [12:35:58.746] ({get foo () {alert(1);delete OBJ.foo;return "bar";}}) [12:36:02.824] OBJ [12:36:02.831] ({get foo () {alert(1);delete OBJ.foo;return "bar";}}) [12:36:07.128] OBJ.toSource() [12:36:07.137] "({get foo () {alert(1);delete OBJ.foo;return \"bar\";}})" [12:36:10.047] OBJ [12:36:10.055] ({get foo () {alert(1);delete OBJ.foo;return "bar";}}) -- [12:36:21.584] OBJ.foo [12:36:22.533] "bar" -- [12:36:28.959] OBJ [12:36:28.968] [object Object]
Comment 2•13 years ago
|
||
I see the same thing you're seeing Panos. One interesting note: if you click on the object output in the console, the object inspector does say "foo": "bar", which means that the object inspector is running the getter...
Assignee | ||
Comment 3•13 years ago
|
||
(In reply to comment #2) > cc: kdangoor@mozilla.comI see the same thing you're seeing Panos. One > interesting note: if you click on the object output in the console, the > object inspector does say "foo": "bar", which means that the object > inspector is running the getter... This only happens on Firefox 4, (devtools) Nightly displays "foo": Getter. Not sure when it was fixed though.
Comment 4•13 years ago
|
||
(In reply to comment #3) > This only happens on Firefox 4, (devtools) Nightly displays "foo": Getter. > Not sure when it was fixed though. ahh, right. That would be bug 632347
Reporter | ||
Comment 5•13 years ago
|
||
Odd, perhaps I shouldn't have fudged the simple example. I suspect the problem is to do with cross-context objects but I need to figure out how to create a testcase from it.
Assignee | ||
Comment 6•13 years ago
|
||
Dave, can you reproduce this, or should we close the bug?
Reporter | ||
Comment 7•13 years ago
|
||
I don't have the time to try to reproduce this
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → INCOMPLETE
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•