Date.prototype.toJSON computes 'this' incorrectly

RESOLVED FIXED

Status

()

RESOLVED FIXED
8 years ago
8 years ago

People

(Reporter: jimb, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [fixed-in-tracemonkey])

Attachments

(1 attachment)

(Reporter)

Description

8 years ago
Created attachment 479882 [details] [diff] [review]
Correctly compute |this| in Date.prototype.toJSON.

ES5 15.9.5.44 step 1 says that Date.prototype.toJSON must apply ToObject to the given |this| value. However, jsdate.cpp:date_toJSON calls ComputeThisFromVp, which does null->global and other sorts of transitions.

With the strict |this| patch applied, this causes regressions in ecma_5/Date/toJSON-01.js (but only in the browser, as the real global and the XPCCrossOriginWrapper seem to respond to DefaultValue differently, leading the shell to spuriously throw the correct error).
Attachment #479882 - Flags: review?(jwalden+bmo)

Comment 1

8 years ago
Comment on attachment 479882 [details] [diff] [review]
Correctly compute |this| in Date.prototype.toJSON.

I had completely forgotten about toJSON-01.js conditionally testing strict-this behavior!

Let's remove the if-strict-mode-this-is-supported guard around these tests since we know we support it now, same as with the function bind test changes.
Attachment #479882 - Flags: review?(jwalden+bmo) → review+

Comment 2

8 years ago
...in the strict-this bug, of course, after this patch lands as-is.
OS: Linux → Windows CE
(Reporter)

Comment 3

8 years ago
http://hg.mozilla.org/tracemonkey/rev/3bd3e00203fa
Status: NEW → ASSIGNED
Whiteboard: [fixed-in-tracemonkey]

Comment 4

8 years ago
http://hg.mozilla.org/mozilla-central/rev/3bd3e00203fa
Status: ASSIGNED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.