If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Typing Object.getPrototypeOf(new Date()) in the devtools js console makes it stop working

RESOLVED FIXED in Firefox 36



Developer Tools: Console
3 years ago
3 years ago


(Reporter: NiKo, Assigned: Sami Jaktholm)


33 Branch
Firefox 36
Mac OS X

Firefox Tracking Flags

(Not tracked)



(2 attachments, 1 obsolete attachment)

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)
The bug is confirmed using the latest beta update.
Actually simply entering `(new Date())` is enough to break the console.
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 ?
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.
(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.
Issue confirmed using a fresh profile. Note that I'm on OSX 10.9.5.

Confirmed as well using nightly compiled from fx-team.
Created attachment 8500038 [details]
Screencast of bug scenario (GIF).
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.
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.

Comment 10

3 years ago
Created attachment 8507362 [details] [diff] [review]

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:

[1] http://es5.github.io/#x15.9.5
Attachment #8507362 - Flags: review?(bgrinstead)
Comment on attachment 8507362 [details] [diff] [review]

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+

Comment 12

3 years ago
Created attachment 8507682 [details] [diff] [review]

Thanks for the review. Here's a patch with r=bgrins in the commit message.
Assignee: nobody → sjakthol
Attachment #8507362 - Attachment is obsolete: true
Attachment #8507682 - Flags: review+


3 years ago
Keywords: checkin-needed
Keywords: checkin-needed
Whiteboard: [fixed-in-fx-team]
Last Resolved: 3 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 36
See Also: → bug 861219
You need to log in before you can comment on or make changes to this bug.