Closed Bug 605470 Opened 14 years ago Closed 14 years ago

Variables defined in web console can disappear with no warning

Categories

(DevTools :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

(blocking2.0 final+)

RESOLVED WORKSFORME
Tracking Status
blocking2.0 --- final+

People

(Reporter: jdm, Unassigned)

References

Details

Open a blank page, and open the web console. Type |var f = document.createElement("iframe")|, then |f| to verify that f contains a value, and sit back and wait for (presumably) a GC to occur. Type |f| in the console again, note that you now have "ReferenceError: f is not defined" instead of the previous value.
This is a surprising and unfortunate user experience; I suspect blocking is in order.
blocking2.0: --- → ?
It's unfortunate for a lot of reasons!
(In reply to comment #0) > Open a blank page, and open the web console. Type |var f = > document.createElement("iframe")|, then |f| to verify that f contains a value, > and sit back and wait for (presumably) a GC to occur. Type |f| in the console > again, note that you now have "ReferenceError: f is not defined" instead of the > previous value. Could you retest with today's nightly? There were some changes made to evalInSandbox (oustanding wrapper+compartments fixes) last night that may have fixed this.
Blocks: devtools4b7
The error message has changed to "10:44:27.213: Error: Permission denied to access property 'f'" in today's nightly.
blocking2.0: ? → final+
curious to hear if this is still happening in current nightlies. I'm hoping the modifications to the evaluation code in bug 599940 have cured this.
I tried to reproduce and no longer can.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WORKSFORME
great success! thanks for the follow-up.
For future generations, my theory as to what was happening, was that evalInSandbox(with(__helpers__) { with(__window__) { var a = Object; } }); Was executing | var a = Object | inside a separate scope from the sandbox itself. This allowed the garbage collector to detect that these variables were disconnected and clean them up. The magic sauce was removing the always awful with() statements.
That should be quoted, as in: evalInSandbox("with(__helpers__) { with(__window__) { var a = Object; } }"); (bugzilla needs a js parser)
let this be a lesson to us! 'with' is one of the "bad parts" of JS:)
(In reply to comment #10) > let this be a lesson to us! 'with' is one of the "bad parts" of JS:) I'm pretty sure I read that in a book somewhere. hmm...
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.