Bug 539684 - Serializer tests fail with the HTML5 parser due to whitespace differences and doctype case differences. r=laurent.

--HG--
extra : rebase_source : d7855eca3004f7eceaefcdd8a1b0bfb7794a1e46
This commit is contained in:
Henri Sivonen 2009-12-21 13:39:00 +02:00
parent 84a8e6139d
commit 08283bd925
22 changed files with 106 additions and 151 deletions

View File

@ -1,11 +1,7 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Test for html serializer</title>
</head>
<body>
</head><body>
<p>Hello world</p> <p>
Lorem ipsum dolor sit amet, <strong>consectetuer</strong> adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti <span>sociosqu ad
@ -45,6 +41,4 @@ ut gravida eros leo ut libero
<p></p>
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
</body>
</html>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>

View File

@ -44,5 +44,4 @@ ut gravida eros leo ut libero
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
</body>
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body>

View File

@ -1,4 +1,4 @@
<!DOCTYPE HTML>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

View File

@ -1,8 +1,6 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>Test for html serializer</title>
</head><body>
@ -51,5 +49,4 @@ ut gravida eros leo ut libero
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
</body></html>
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>

View File

@ -1,8 +1,6 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>Test for html serializer</title>
</head><body>
@ -52,5 +50,4 @@ ut gravida eros leo ut libero
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
</body></html>
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>

View File

@ -1,8 +1,6 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>Test for html serializer</title>
</head><body>
@ -51,5 +49,5 @@ ut gravida eros leo ut libero
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
<body><p>this is an other body element</p></body></body></html>
aliquet lectus. Nunc vitae eros. Class aptent taciti</p><body><p>this is
an other body element</p></body></body></html>

View File

@ -1,8 +1,6 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>Test for html serializer</title>
</head></html>

View File

@ -1,8 +1,6 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>Test for html serializer</title>
</head><body>
@ -51,5 +49,4 @@ ut gravida eros leo ut libero
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
</body></html>
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>

View File

@ -1,8 +1,6 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>Test for html serializer</title>
</head><body>
@ -55,5 +53,4 @@ ut gravida eros leo ut libero
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
</body></html>
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>

View File

@ -1,8 +1,5 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Test for html serializer</title>
</head><body>
@ -45,5 +42,4 @@ ut gravida eros leo ut libero
<p></p>
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
</body></html>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>

View File

@ -1,8 +1,6 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html><head><meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<title>Test for html serializer</title>
</head><body><p>this is an other body element</p></body><body>
@ -51,5 +49,4 @@ ut gravida eros leo ut libero
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
</body></html>
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body></html>

View File

@ -44,5 +44,4 @@ ut gravida eros leo ut libero
<noscript>
<p>Curabitur consectetuer urna a sem. Nunc & non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus</p></noscript>
<p>Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus
aliquet lectus. Nunc vitae eros. Class aptent taciti</p>
</body>
aliquet lectus. Nunc vitae eros. Class aptent taciti</p></body>

View File

@ -1,9 +1,5 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for html serializer with entities</title>
</head>
<body>
<!DOCTYPE html><html><head><title>Test for html serializer with entities</title>
</head><body>
<p>The basic set is just &nbsp; &amp; &lt; &gt; &quot; for interoperability with older products that don't support &alpha; and friends.</p>
@ -18,12 +14,9 @@
&sigma; &tau; &upsilon; &phi; &chi; &psi; &omega; &thetasym; &upsih; &piv; &bull; &hellip; &prime; &Prime; &oline; &frasl; &weierp; &image; &real;
&trade; &alefsym; &larr; &uarr; &rarr; &darr; &harr; &crarr; &lArr; &uArr; &rArr; &dArr; &hArr; &forall; &part; &exist; &empty; &nabla; &isin; &notin;
&ni; &prod; &sum; &minus; &lowast; &radic; &prop; &infin; &ang; &and; &or; &cap; &cup; &int; &there4; &sim; &cong; &asymp; &ne; &equiv; &le; &ge;
&sub; &sup; &nsub; &sube; &supe; &oplus; &otimes; &perp; &sdot; &lceil; &rceil; &lfloor; &rfloor; &lang; &rang; &loz; &spades; &clubs; &hearts; &diams;
&sub; &sup; &nsub; &sube; &supe; &oplus; &otimes; &perp; &sdot; &lceil; &rceil; &lfloor; &rfloor; &loz; &spades; &clubs; &hearts; &diams;
</p>
<p> others
&OElig; &oelig; &Scaron; &scaron; &Yuml; &circ; &tilde; &ensp; &emsp; &thinsp; &zwnj; &zwj; &lrm; &rlm;&ndash;&mdash; &lsquo; &rsquo;
&sbquo;&ldquo; &rdquo; &bdquo; &dagger; &Dagger; &permil; &lsaquo; &rsaquo; &euro;
</p>
</body>
</html>
</p></body></html>

View File

@ -1,9 +1,7 @@
<!DOCTYPE HTML>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=">
<title>Test for html serializer with entities</title>
<meta http-equiv="content-type" content="text/html; charset="><title>Test
for html serializer with entities</title>
</head><body>
<p>The basic set is just &nbsp; &amp; &lt; &gt; " for interoperability
@ -20,11 +18,9 @@ with older products that don't support α and friends.</p>
σ τ υ φ χ ψ ω ϑ ϒ ϖ • … ″ ‾
™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉
∋ ∏ ∑ √ ∝ ∞ ∠ ∧ ∫ ∴ ≅ ≈ ≠ ≡ ≤ ≥
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ 〈 〉 ◊ ♠ ♣ ♥ ♦
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ ◊ ♠ ♣ ♥ ♦
</p>
<p> others
Œ œ Š š Ÿ ˆ ˜ ‏–—
‚“ ” „ † ‡ ‰
</p>
</body></html>
</p></body></html>

View File

@ -1,9 +1,7 @@
<!DOCTYPE HTML>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=">
<title>Test for html serializer with entities</title>
<meta http-equiv="content-type" content="text/html; charset="><title>Test
for html serializer with entities</title>
</head><body>
<p>The basic set is just &nbsp; &amp; &lt; &gt; " for interoperability
@ -41,14 +39,11 @@ with older products that don't support &alpha; and friends.</p>
&or; &cap; &cup; &int; &there4; &sim; &cong; &asymp; &ne; &equiv; &le;
&ge;
&sub; &sup; &nsub; &sube; &supe; &oplus; &otimes; &perp; &sdot; &lceil;
&rceil; &lfloor; &rfloor; &lang; &rang; &loz; &spades; &clubs; &hearts;
&diams;
&rceil; &lfloor; &rfloor; &loz; &spades; &clubs; &hearts; &diams;
</p>
<p> others
&OElig; &oelig; &Scaron; &scaron; &Yuml; &circ; &tilde; &ensp; &emsp;
&thinsp; &zwnj; &zwj; &lrm; &rlm;&ndash;&mdash; &lsquo; &rsquo;
&sbquo;&ldquo; &rdquo; &bdquo; &dagger; &Dagger; &permil; &lsaquo;
&rsaquo; &euro;
</p>
</body></html>
</p></body></html>

View File

@ -1,9 +1,7 @@
<!DOCTYPE HTML>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=">
<title>Test for html serializer with entities</title>
<meta http-equiv="content-type" content="text/html; charset="><title>Test
for html serializer with entities</title>
</head><body>
<p>The basic set is just &nbsp; &amp; &lt; &gt; " for interoperability
@ -41,14 +39,11 @@ with older products that don't support &alpha; and friends.</p>
&or; &cap; &cup; &int; &there4; &sim; &cong; &asymp; &ne; &equiv; &le;
&ge;
&sub; &sup; &nsub; &sube; &supe; &oplus; &otimes; &perp; &sdot; &lceil;
&rceil; &lfloor; &rfloor; &lang; &rang; &loz; &spades; &clubs; &hearts;
&diams;
&rceil; &lfloor; &rfloor; &loz; &spades; &clubs; &hearts; &diams;
</p>
<p> others
&OElig; &oelig; &Scaron; &scaron; &Yuml; &circ; &tilde; &ensp; &emsp;
&thinsp; &zwnj; &zwj; &lrm; &rlm;&ndash;&mdash; &lsquo; &rsquo;
&sbquo;&ldquo; &rdquo; &bdquo; &dagger; &Dagger; &permil; &lsaquo;
&rsaquo; &euro;
</p>
</body></html>
</p></body></html>

View File

@ -1,9 +1,7 @@
<!DOCTYPE HTML>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=">
<title>Test for html serializer with entities</title>
<meta http-equiv="content-type" content="text/html; charset="><title>Test
for html serializer with entities</title>
</head><body>
<p>The basic set is just &nbsp; &amp; &lt; &gt; " for interoperability
@ -30,11 +28,9 @@ with older products that don't support α and friends.</p>
σ τ υ φ χ ψ ω ϑ ϒ ϖ • … ″ ‾
™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉
∋ ∏ ∑ √ ∝ ∞ ∠ ∧ ∫ ∴ ≅ ≈ ≠ ≡ ≤ ≥
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ 〈 〉 ◊ ♠ ♣ ♥ ♦
⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ ◊ ♠ ♣ ♥ ♦
</p>
<p> others
Œ œ Š š Ÿ ˆ ˜ ‏–—
‚“ ” „ † ‡ ‰
</p>
</body></html>
</p></body></html>

View File

@ -1,8 +1,5 @@
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!DOCTYPE html><html><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Testcase for IPv6 addresses</title>
<body>
<a href="http://[2001:4860:a003::68]/">Test</a>
</body>
</html>
</body></html>

View File

@ -1,7 +1,6 @@
<!DOCTYPE HTML>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>Testcase for IPv6 addresses</title>
</head><body>
<a href="http://[2001:4860:a003::68]/">Test</a>

View File

@ -44,6 +44,11 @@ function loadFileContent(aFile, aCharset) {
return content;
}
function isRoughly(actual, expected, message) {
return is(actual.replace("<!DOCTYPE HTML", "<!DOCTYPE html"),
expected,
message);
}
function testHtmlSerializer_1 () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@ -63,26 +68,26 @@ function testHtmlSerializer_1 () {
encoder.setCharset("UTF-8");
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_noflag.html");
is(out, expected, "test no flags");
isRoughly(out, expected, "test no flags");
//------------- unsupported flags
// since the following flags are not supported, we should
// have a result like the one without flag
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputPreformatted);
out = encoder.encodeToString();
is(out, expected, "test OutputPreformatted");
isRoughly(out, expected, "test OutputPreformatted");
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputFormatFlowed);
out = encoder.encodeToString();
is(out, expected, "test OutputFormatFlowed");
isRoughly(out, expected, "test OutputFormatFlowed");
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputNoScriptContent);
out = encoder.encodeToString();
is(out, expected, "test OutputNoScriptContent");
isRoughly(out, expected, "test OutputNoScriptContent");
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputNoFramesContent);
out = encoder.encodeToString();
is(out, expected, "test OutputNoFramesContent");
isRoughly(out, expected, "test OutputNoFramesContent");
//------------ OutputWrap
@ -90,25 +95,25 @@ function testHtmlSerializer_1 () {
// when there are no flags.
encoder.init(doc, "text/html", de.OutputLFLineBreak |de.OutputWrap);
out = encoder.encodeToString();
is(out, expected, "test OutputWrap");
isRoughly(out, expected, "test OutputWrap");
//------------ OutputFormatted
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputFormatted);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_format.html");
is(out, expected, "test OutputFormatted");
isRoughly(out, expected, "test OutputFormatted");
//------------ OutputRaw
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputRaw);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_raw.html");
is(out, expected, "test OutputRaw");
isRoughly(out, expected, "test OutputRaw");
//------------ OutputBodyOnly
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputBodyOnly);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_bodyonly.html");
is(out, expected, "test OutputBodyOnly");
isRoughly(out, expected, "test OutputBodyOnly");
@ -116,31 +121,31 @@ function testHtmlSerializer_1 () {
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_links.html");
is(out, expected, "test OutputAbsoluteLinks");
isRoughly(out, expected, "test OutputAbsoluteLinks");
//------------ OutputLFLineBreak
encoder.init(doc, "text/html",de.OutputLFLineBreak);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_linebreak.html");
is(out, expected, "test OutputLFLineBreak");
isRoughly(out, expected, "test OutputLFLineBreak");
//------------ OutputCRLineBreak
encoder.init(doc, "text/html",de.OutputCRLineBreak);
out = encoder.encodeToString();
expected = expected.replace(/\n/mg, "\r");
is(out, expected, "test OutputCRLineBreak");
isRoughly(out, expected, "test OutputCRLineBreak");
//------------ OutputLFLineBreak + OutputCRLineBreak
encoder.init(doc, "text/html",de.OutputLFLineBreak | de.OutputCRLineBreak);
out = encoder.encodeToString();
expected = expected.replace(/\r/mg, "\r\n");
is(out, expected, "test OutputLFLineBreak + OutputCRLineBreak");
isRoughly(out, expected, "test OutputLFLineBreak + OutputCRLineBreak");
//------------ OutputNoFormattingInPre
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputNoFormattingInPre);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_noformatpre.html");
is(out, expected, "test OutputNoFormattingInPre");
isRoughly(out, expected, "test OutputNoFormattingInPre");
// ------------- nested body elements
var body2 = doc.createElement('body');
@ -156,7 +161,7 @@ function testHtmlSerializer_1 () {
encoder.setCharset("UTF-8");
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_nested_body.html");
is(out, expected, "test with two nested body elements");
isRoughly(out, expected, "test with two nested body elements");
// ------------- two body elements
body.parentNode.insertBefore(body2, body);
@ -166,13 +171,13 @@ function testHtmlSerializer_1 () {
encoder.setCharset("UTF-8");
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_sibling_body.html");
is(out, expected, "test with two body elements");
isRoughly(out, expected, "test with two body elements");
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputBodyOnly);
encoder.setCharset("UTF-8");
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_sibling_body_only_body.html");
is(out, expected, "test with two body elements, and output body only");
isRoughly(out, expected, "test with two body elements, and output body only");
// --------------- no body element
doc.documentElement.removeChild(body);
@ -182,7 +187,7 @@ function testHtmlSerializer_1 () {
encoder.setCharset("UTF-8");
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_1_no_body.html");
is(out, expected, "test with no body element");
isRoughly(out, expected, "test with no body element");
SimpleTest.finish();
}

View File

@ -44,6 +44,11 @@ function loadFileContent(aFile, aCharset) {
return content;
}
function isRoughly(actual, expected, message) {
return is(actual.replace("<!DOCTYPE HTML", "<!DOCTYPE html"),
expected,
message);
}
function testHtmlSerializer_1 () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@ -62,25 +67,25 @@ function testHtmlSerializer_1 () {
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeW3CEntities);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_2_entw3c.html");
is(out, expected, "test OutputEncodeW3CEntities");
isRoughly(out, expected, "test OutputEncodeW3CEntities");
//------------ OutputEncodeBasicEntities
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeBasicEntities);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_2_basic.html");
is(out, expected, "test OutputEncodeBasicEntities");
isRoughly(out, expected, "test OutputEncodeBasicEntities");
//------------ OutputEncodeLatin1Entities
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeLatin1Entities);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_2_latin1.html");
is(out, expected, "test OutputEncodeLatin1Entities");
isRoughly(out, expected, "test OutputEncodeLatin1Entities");
//------------ OutputEncodeHTMLEntities
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputEncodeHTMLEntities);
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_2_enthtml.html");
is(out, expected, "test OutputEncodeHTMLEntities");
isRoughly(out, expected, "test OutputEncodeHTMLEntities");
// tests on the serialization of selections

View File

@ -43,6 +43,11 @@ function loadFileContent(aFile, aCharset) {
return content;
}
function isRoughly(actual, expected, message) {
return is(actual.replace("<!DOCTYPE HTML", "<!DOCTYPE html"),
expected,
message);
}
function testHtmlSerializer_1 () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@ -62,19 +67,19 @@ function testHtmlSerializer_1 () {
encoder.setCharset("UTF-8");
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_ipv6_out.html");
is(out, expected, "test no flags");
isRoughly(out, expected, "test no flags");
//------------ OutputAbsoluteLinks
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
encoder.setCharset("UTF-8");
out = encoder.encodeToString();
expected = loadFileContent("file_htmlserializer_ipv6_out.html");
is(out, expected, "test OutputAbsoluteLinks");
isRoughly(out, expected, "test OutputAbsoluteLinks");
//------------ serializing a selection
encoder.init(doc, "text/html", de.OutputLFLineBreak | de.OutputAbsoluteLinks);
encoder.setNode(doc.links[0]);
out = encoder.encodeToString();
expected = "<a href=\"http://[2001:4860:a003::68]/\">Test</a>";
is(out, expected, "test selection");
isRoughly(out, expected, "test selection");
SimpleTest.finish();