JSON.stringify should convert boolean wrapper objects

RESOLVED DUPLICATE of bug 557371

Status

()

Core
JavaScript Engine
RESOLVED DUPLICATE of bug 557371
7 years ago
7 years ago

People

(Reporter: jandem, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

7 years ago
The IE test site has 81 JSON tests. We fail only 2 of them, tests like this:
--
function testcase() {
    var obj = {prop: 42, toJSON: function () {return new Boolean(true);}};
    return JSON.stringify([obj]) === "[true]";
}
--
Fix is super easy, will attach a patch in a minute.
See bug 557371, with an attached and reviewed patch.  The only problem it encountered on initial landing was some JSON tests outside js/src/ which expected equality of output between native JSON and json2.js, which is not a proper expectation.  The fix was non-obvious at the time (I perennially forget that dom/src/json has tests that can fail when json.cpp changes), so I backed out and punted to next release, when I'd have time to fully adjust those tests to be correct.
(Reporter)

Comment 2

7 years ago
Thanks, that's even easier :) Marking this as depending on bug 557371 then. Maybe a duplicate, but that bug does not mention the Boolean case, so I'll keep this open.
Depends on: 557371
(Reporter)

Updated

7 years ago
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 557371
You need to log in before you can comment on or make changes to this bug.