Closed
Bug 367827
Opened 18 years ago
Closed 18 years ago
Testing for DOM serialization with different output encodings
Categories
(Core :: DOM: Serializers, defect)
Core
DOM: Serializers
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: Waldo, Assigned: Waldo)
References
()
Details
Attachments
(1 file, 1 obsolete file)
3.70 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
Before bug 361933, serialization to a particular encoding didn't actually change the XML declaration to reflect the output encoding, even if the declaration associated with the node being serialized had a different encoding. (In other words serializing a document with encoding="ISO-8859-1" to UTF-16 would leave the encoding="ISO-8859-1" in the UTF-16-converted serialization.) That was fixed, but the test for it checked serialization string equality and not byte equality, so the actual output encoding wasn't tested. This patch tests the actual output encoding with byte-by-byte decoding of a couple encodings. (Aren't UTF-8 and endianness fun?)
Flags: in-testsuite?
Attachment #252426 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 1•18 years ago
|
||
bz's suggested I use nsIConverterInputStream to do the conversion instead (can use 0x0 as the replacement character to cause throws if the conversion fails), and then compare the strings produced by readString afterward. Simpler, no encoding hassle, etc. Converter testing should ensure the encoding is correct, and I'll probably move the conversion routines I have here into a test for the converter so that we can rely on it to be and remain correct.
Non-BMP character testing can be done by reading from a file instead of a JS string (neither of us thinks JS really supports non-BMP characters, except possibly in an accidental way at the very best). I'm not sure yet whether that'll happen in this patch or in another.
New patch coming soon (not bothering to obsolete to avoid the extra bugmail)...
Assignee | ||
Comment 2•18 years ago
|
||
Okay, this uses nsIConverterInputStream and eliminates half the patch :-). (I filed bug 368142 for a test for the converter itself, which *does* use the conversion functions I wrote for the initial patch, in case anyone's interested.)
I'll leave non-BMP to another patch, because I have other things I need to do besides this.
Attachment #252426 -
Attachment is obsolete: true
Attachment #252717 -
Flags: review?(bzbarsky)
Attachment #252426 -
Flags: review?(bzbarsky)
![]() |
||
Comment 3•18 years ago
|
||
Comment on attachment 252717 [details] [diff] [review]
Use a Unicode converter to check encodings
>Index: content/test/unit/test_xml_serializer.js
>+var BIS;
>+
> function run_test() {
>+ // pre-test setup
>+ BIS = Components.Constructor("@mozilla.org/binaryinputstream;1",
>+
This is unused now, right?
>+ var outString = {};
>+ var count = cin.readString(expectedString.length, outString);
>+ do_check_true(count == expectedString.length);
>+ do_check_true(outString.value == expectedString);
Add a comment like "check that the first expectedString.length chars are correct" before this?
>+ do_check_eq(0, cin.readString(1, outString));
>+ do_check_eq(outString.value, "");
Add a comment like "check that there's nothing else in the stream" before this?
With that looks good.
Attachment #252717 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 4•18 years ago
|
||
Patch checked in with BIS removed and with explanatory comments in checkSerialization.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•