Closed
Bug 1077857
Opened 10 years ago
Closed 10 years ago
Typing Object.getPrototypeOf(new Date()) in the devtools js console makes it stop working
Categories
(DevTools :: Console, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 36
People
(Reporter: NiKo, Assigned: sjakthol)
References
Details
Attachments
(2 files, 1 obsolete file)
243.65 KB,
image/gif
|
Details | |
2.25 KB,
patch
|
sjakthol
:
review+
|
Details | Diff | Splinter Review |
1. Open the devtools
2. Click the Console tab
3. Enter Object.getPrototypeOf(new Date()) and press Enter
4. Nothing is printed out, whatever else you enter won't have any consequence
(Just seen that I have a pending Firefox update, I'll confirm this is still a bug after restarting the browser)
Reporter | ||
Comment 1•10 years ago
|
||
The bug is confirmed using the latest beta update.
Reporter | ||
Comment 2•10 years ago
|
||
Actually simply entering `(new Date())` is enough to break the console.
Comment 3•10 years ago
|
||
Works for me on the latest nightly and beta too. Is there any specific page that you are trying on ? Can you try with a fresh new profile ?
Reporter | ||
Comment 4•10 years ago
|
||
It's actually a bit more complicated; (new Date()) doesn't break it, I was confused because even after reloading the page you're on, the console stays broken whatever you keep entering if you entered `Object.getPrototypeOf(new Date())` in the first place for that page.
Reporter | ||
Comment 5•10 years ago
|
||
(In reply to Girish Sharma [:Optimizer] from comment #3)
> Works for me on the latest nightly and beta too. Is there any specific page
> that you are trying on ? Can you try with a fresh new profile ?
I've tried it with many different pages, including the one I'm currently writing a comment on.
Will try with a fresh profile.
Reporter | ||
Comment 6•10 years ago
|
||
Issue confirmed using a fresh profile. Note that I'm on OSX 10.9.5.
Confirmed as well using nightly compiled from fx-team.
Reporter | ||
Comment 7•10 years ago
|
||
Comment 8•10 years ago
|
||
I can reproduce with FF 32.0.3 on GNU/Linux (like in the screencast, even something that would result in an exception is not displayed). I can't reproduce with Nightly 35.0a1 (2014-10-04) on the same OS. I'm not using the same profile for both however.
Comment 9•10 years ago
|
||
For me, Object.getPrototypeOf(new Date()) behaves similar to what is shown in the attachment, but even after entering that, console works just fine for other inputs.
Assignee | ||
Comment 10•10 years ago
|
||
When the code is evaluated in the console a following exception occurs in the console output formatter:
TypeError: invalid 'in' operand preview
This seem to cause the entire console to break in FF33 but no longer in current Nightly.
Here's the sequence of events that lead to this:
- Date.prototype has class "Date" (as per [1])
- debugger tries to create a preview grip for the prototype with "Date" class using the Date previewer
- At toolkit/devtools/server/actors/script.js:3626 the Date object previewer aborts due to obj.proto.class being "Object", not "Date" (obj = Date.prototype)
- the grip for "Date" returned from server has no "preview" defined
- back on the client in browser/devtools/webconsole/console-output:2457 the code '"timestamp" in preview' throws an exception as preview is undefined
Here's a patch that changes the console output formatter to check for undefined preview before trying to use it. The output looks like following:
< Date.prototype
> Date ['Date' is a variables view link for Date.prototype]
However running print(Date.prototype) outputs "Invalid Date" which is a bit inconsistent. This follows from the ES5 spec[1] which states:
> The Date prototype object is itself a Date object (its [[Class]] is
> "Date") whose [[PrimitiveValue]] is NaN.
So Date.prototype could output "Invalid Date" to keep consistent but that might be somewhat confusing...
(For the record, Chrome outputs "Invalid Date" when evaluating Date.prototype in console.)
Here's a try run with the patch:
https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=f79e9b0475ef
https://tbpl.mozilla.org/?tree=Try&rev=f79e9b0475ef
[1] http://es5.github.io/#x15.9.5
Attachment #8507362 -
Flags: review?(bgrinstead)
Comment 11•10 years ago
|
||
Comment on attachment 8507362 [details] [diff] [review]
webconsole-date-prototype-exception.patch
Review of attachment 8507362 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks Sami for this patch! I think this is a pretty safe and simple fix to the problem to land as-is. Please just add r=bgrins to the end of the commit message.
With regards to the consistency issue with these two cases:
1) print(Date.prototype) -> "Invalid Date"
2) Date.prototype -> 'Date' link to variables view
It seems to make sense to me - the Date.prototype object itself is an inspectable object so we should present it as such, but when calling Date.prototype.toString() in the console you can see the "Invalid date" message. This is something that you could follow up with on the devtools mailing list to see if there are other opinions, but surely something we could do as a follow up.
Attachment #8507362 -
Flags: review?(bgrinstead) → review+
Assignee | ||
Comment 12•10 years ago
|
||
Thanks for the review. Here's a patch with r=bgrins in the commit message.
Assignee: nobody → sjakthol
Attachment #8507362 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8507682 -
Flags: review+
Assignee | ||
Updated•10 years ago
|
Keywords: checkin-needed
Comment 13•10 years ago
|
||
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 36
Updated•6 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•