JSON.stringify now correctly handles spaces
Bug 505228 (from Sep 2009) is now checked in. The patch fixes a problem with the TraceMonkey JSON encoder where the nesting of arrays is correct for all but the first line of the output string when the “space” argument is specified. See the ECMAScript wiki for more information on JSON support. My initial patch simply (and naively) called the WriteIndent function. I didn’t catch this mistake until I wrote an automated test for the bug. This was the first bug for which I wrote an xpcshell test – it’s amazing how difficult it was for me to figure out how to run these (rather embarrassing in retrospect, but oh well, at least I stayed the course). The JSON xpcshell tests can be run using:
cd ~/mozilla/obj make -C dom/src/json/test/ xpcshell-tests
To check just the specific file in question (the one to which I added the test), I used
make SOLO_FILE="test_replacer.js" -C dom/src/json/test/ check-one
This was helpful since I could run a smaller subset of tests while developing, and then later run the whole JSON test suite.
Leave a Reply