Open Bug 1188668 Opened 9 years ago Updated 2 years ago

Console log does not reference the correct state of the JS object

Categories

(DevTools :: Console, defect, P2)

defect

Tracking

(Not tracked)

People

(Reporter: andreio, Unassigned)

References

Details

(Whiteboard: [btpp-fix-later])

Not sure I described the issue well enough in the title feel free to edit.

Test case:
http://jsbin.com/zevojiqogi/1/edit?html,js,console,output
Check the console, click on the `Array [ ]` for the expanded view.

Behavior:
Console output shows an empty array but clicking on it reveals elements that have been added at a later step (after printing).

Expected behavior:
Show the empty array state at the moment of printing it.
Jeff, what do you think of this case?

It seems different than what we're tracking in bug 754861, since having the console open is not enough.  Maybe it's a regression in array previewers?  Unsure.
Flags: needinfo?(jgriffiths)
Same thing happens if you replace the array with an empty object literal.
(In reply to J. Ryan Stinnett [:jryans] (use ni?) from comment #1)
> Jeff, what do you think of this case?
> 
> It seems different than what we're tracking in bug 754861, since having the
> console open is not enough.  Maybe it's a regression in array previewers? 
> Unsure.

It's definitely wrong and we should fix it.

Can you assign a [difficulty=] whiteboard to this? If you're not that familiar with the code I guess we should ask Brian or Panos.
Flags: needinfo?(jgriffiths) → needinfo?(jryans)
Priority: -- → P1
Whiteboard: [polish-backlog]
I don't know the console well... let's see what Panos thinks.
Flags: needinfo?(jryans) → needinfo?(past)
I don't think this is a regression as the preview is accurate even in the presence of a timeout. Inspecting the logged result is something different and I don't remember us ever handling it correctly. Interestingly enough, I see that neither Chrome nor Safari seem to allow inspection of the output of console.log. I'm pretty sure that they used to do that and they may have taken it away to avoid problems like this (which as bug 754861 comment 9 indicates they used to share). Perhaps we should do the same.
Flags: needinfo?(past)
(In reply to Panos Astithas [:past] from comment #5)
> I don't think this is a regression as the preview is accurate even in the
> presence of a timeout. Inspecting the logged result is something different
> and I don't remember us ever handling it correctly. Interestingly enough, I
> see that neither Chrome nor Safari seem to allow inspection of the output of
> console.log. I'm pretty sure that they used to do that and they may have
> taken it away to avoid problems like this (which as bug 754861 comment 9
> indicates they used to share). Perhaps we should do the same.

I'm not sure I know what you mean. If I open the chrome devtools on bugzilla and run `console.log(YAHOO)`, I can click into that object as per normal. Is that what you mean by 'inspect', or something else?
Sorry, I shouldn't have generalized before: Chrome doesn't seem to let you expand an object or array when the preview is sufficiently complete. I was actually playing with the example from comment 0, but here is a better example that demonstrates that Chrome has the same bug in the general case:

http://jsbin.com/pokupawiba/edit?html,js,console,output

When you inspect the properties of |obj|, you see the "b" property that was added after logging present in both browsers.
(In reply to Panos Astithas [:past] from comment #7)
> Sorry, I shouldn't have generalized before: Chrome doesn't seem to let you
> expand an object or array when the preview is sufficiently complete.

And realizing that I didn't elaborate on this point: setting |obj| to, say {a: 1} in my test page behaves properly in Chrome, because you can't click and inspect it.
Component: Developer Tools → Developer Tools: Console
Priority: P1 → P2
Whiteboard: [polish-backlog] → [btpp-fix-later]
Product: Firefox → DevTools
See Also: → 1541525
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.