Fix for bug 633934. r=bzbarsky

Two files need to be patched:

/dom/src/json/nsJSON.cpp
/dom/src/json/test/unit/test_encode.js

The first problem is a wrong nsnull initialization parameter in one of
the nsJSONWriter constructor.

The second problem is caused by related bug 410005 and only happens on
windows and can be solved by calling the clone() method before calling
filesize attribute on a file that has been created and later on modified
by adding extra content.

The BOM check set to true causes this behaviour

 // check BOMs
  // the clone() calls are there to work around -- bug 410005
  var f = writeToFile({},"UTF-8", true).clone();

As discussed Linux is not affected.

The overall 410005 seems to be related to a wrong logic in the mDirty and
MakeDirty() flag in nsLocalFileWin.cpp implementation.
This commit is contained in:
Emanuele Costa 2011-04-04 16:10:10 -07:00
parent 913f30bfe6
commit 9d6cbc70b0
2 changed files with 6 additions and 6 deletions

View File

@ -297,7 +297,7 @@ nsJSONWriter::nsJSONWriter() : mStream(nsnull),
{
}
nsJSONWriter::nsJSONWriter(nsIOutputStream *aStream) : mStream(nsnull),
nsJSONWriter::nsJSONWriter(nsIOutputStream *aStream) : mStream(aStream),
mBuffer(nsnull),
mBufferCount(0),
mDidWrite(PR_FALSE),

View File

@ -138,11 +138,12 @@ function testOutputStreams() {
}
// check BOMs
var f = writeToFile({},"UTF-8", true);
// the clone() calls are there to work around -- bug 410005
var f = writeToFile({},"UTF-8", true).clone();
do_check_eq(f.fileSize, 5);
var f = writeToFile({},"UTF-16LE", true);
var f = writeToFile({},"UTF-16LE", true).clone();
do_check_eq(f.fileSize, 6);
var f = writeToFile({},"UTF-16BE", true);
var f = writeToFile({},"UTF-16BE", true).clone();
do_check_eq(f.fileSize, 6);
outputDir.remove(true);
@ -163,7 +164,6 @@ function run_test() {
testStringEncode();
throwingToJSON();
// failing on windows -- bug 410005
// testOutputStreams();
testOutputStreams();
}