Closed Bug 308806 Opened 19 years ago Closed 19 years ago

Object.prototype.toLocaleString() wrong

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: stryker330, Assigned: mrbkap)

Details

(Keywords: js1.6, verified1.8)

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050908 Firefox/1.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050908 Firefox/1.4

Object.prototype.toLocaleString should return the result of toString(). Right
now, it's set to simply return "[object Object]". That means that if toString is
modified, calling toLocaleString() won't reflect the change.

Reproducible: Always

Steps to Reproduce:
var o = {toString: function() { return 'foo'; }};
o.toLocaleString();

Actual Results:  
"[object Object]"

Expected Results:  
"foo"
Attached file testcase
Forgot to mention that both IE6 and Opera8 have the correct behavior.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Easy to fix, alfred says it comes up now and then.  Blake, can you take this bug
and fix it for 1.8b5?

/be
Flags: blocking1.8b5?
Keywords: js1.6
Sure.
Assignee: general → mrbkap
Status: NEW → ASSIGNED
Brendan, is this something like what you had in mind?
Attachment #197729 - Flags: review?(brendan)
It helps to change _all_ occurances of a changed function namne...
Attachment #197729 - Attachment is obsolete: true
Attachment #197730 - Flags: review?(brendan)
Attachment #197729 - Flags: review?(brendan)
Is this a regression? What's the risk of taking this patch? Bob, do we have
tests around this?
(In reply to comment #7)
> Is this a regression? 

I don't know off hand, but will find out asap.

> Bob, do we have tests around this?

No, but we will have in a few minutes.

Flags: testcase?
2005-09-29 12:09	bob%bclary.com 	mozilla/ js/ tests/ js1_5/ Object/
regress-308806-01.js 	1.1 	0/0  	Object.prototype.toLocaleString should track
Object.prototype.toString, Regression test for bug 308806 by Bryant Chen, not
part of the build


This test fails in Mozilla 1.4, Firefox 1.0 and today's Firefox 1.5.
Flags: testcase? → testcase+
Attachment #197730 - Flags: review?(shaver)
Comment on attachment 197730 [details] [diff] [review]
Actually compiling

r=shaver
Attachment #197730 - Flags: review?(shaver) → review+
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment on attachment 197730 [details] [diff] [review]
Actually compiling

This fix is extremely safe (only affects callers of toLocaleString) and fixes a
standards compliance issue by simply doing what the spec tells us to do (return
the result of toString).
Attachment #197730 - Flags: approval1.8b5?
Comment on attachment 197730 [details] [diff] [review]
Actually compiling

Nit: canonical name for a JSString * is str.

/be
Attachment #197730 - Flags: review?(brendan) → review+
Attachment #197730 - Flags: approval1.8b5? → approval1.8b5+
Fix checked into MOZILLA_1_8_BRANCH.
Keywords: fixed1.8
Flags: blocking1.8b5? → blocking1.8b5+
verified fixed 1.8.x and trunk.
Status: RESOLVED → VERIFIED
Keywords: fixed1.8verified1.8
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: