Closed Bug 600943 Opened 14 years ago Closed 14 years ago

Date.prototype.toJSON computes 'this' incorrectly

Categories

(Core :: JavaScript Engine, defect)

x86_64
Windows CE
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jimb, Unassigned)

References

Details

(Whiteboard: [fixed-in-tracemonkey])

Attachments

(1 file)

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 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+
...in the strict-this bug, of course, after this patch lands as-is.
OS: Linux → Windows CE
http://hg.mozilla.org/tracemonkey/rev/3bd3e00203fa
Status: NEW → ASSIGNED
Whiteboard: [fixed-in-tracemonkey]
http://hg.mozilla.org/mozilla-central/rev/3bd3e00203fa
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: