From c2fdb371f918feff9e8d9f7319dc64c9915c25ba Mon Sep 17 00:00:00 2001 From: Laurent Jouanneau Date: Tue, 21 Oct 2008 16:41:28 -0400 Subject: [PATCH] Bug 424359. Fix OutputBodyOnly to not output a stray and fix newline stuff for doctypes, comments, and the entire XML serializer. Now with even better passing tests. Third time is the charm! r=smaug, sr=bzbarsky --- content/base/test/file_htmlserializer_1.html | 43 ++++ .../test/file_htmlserializer_1_bodyonly.html | 38 ++++ .../test/file_htmlserializer_1_format.html | 47 ++++ .../test/file_htmlserializer_1_linebreak.html | 44 ++++ .../test/file_htmlserializer_1_links.html | 44 ++++ .../file_htmlserializer_1_nested_body.html | 44 ++++ .../test/file_htmlserializer_1_no_body.html | 8 + .../test/file_htmlserializer_1_noflag.html | 44 ++++ .../file_htmlserializer_1_noformatpre.html | 48 +++++ .../base/test/file_htmlserializer_1_raw.html | 42 ++++ .../file_htmlserializer_1_sibling_body.html | 44 ++++ ...mlserializer_1_sibling_body_only_body.html | 38 ++++ content/base/test/file_htmlserializer_2.html | 29 +++ .../test/file_htmlserializer_2_basic.html | 29 +++ .../test/file_htmlserializer_2_enthtml.html | 50 +++++ .../test/file_htmlserializer_2_entw3c.html | 50 +++++ .../test/file_htmlserializer_2_latin1.html | 36 ++++ content/base/test/test_bug424359-1.html | 201 ++++++++++++++++++ content/base/test/test_bug424359-2.html | 96 +++++++++ content/base/test/unit/1_original.xml | 3 + content/base/test/unit/1_result.xml | 3 + content/base/test/unit/2_original.xml | 16 ++ content/base/test/unit/2_result_1.xml | 14 ++ content/base/test/unit/head_utilities.js | 68 ++++++ content/base/test/unit/test_xmlserializer.js | 75 +++++++ 25 files changed, 1154 insertions(+) create mode 100644 content/base/test/file_htmlserializer_1.html create mode 100644 content/base/test/file_htmlserializer_1_bodyonly.html create mode 100644 content/base/test/file_htmlserializer_1_format.html create mode 100644 content/base/test/file_htmlserializer_1_linebreak.html create mode 100644 content/base/test/file_htmlserializer_1_links.html create mode 100644 content/base/test/file_htmlserializer_1_nested_body.html create mode 100644 content/base/test/file_htmlserializer_1_no_body.html create mode 100644 content/base/test/file_htmlserializer_1_noflag.html create mode 100644 content/base/test/file_htmlserializer_1_noformatpre.html create mode 100644 content/base/test/file_htmlserializer_1_raw.html create mode 100644 content/base/test/file_htmlserializer_1_sibling_body.html create mode 100644 content/base/test/file_htmlserializer_1_sibling_body_only_body.html create mode 100644 content/base/test/file_htmlserializer_2.html create mode 100644 content/base/test/file_htmlserializer_2_basic.html create mode 100644 content/base/test/file_htmlserializer_2_enthtml.html create mode 100644 content/base/test/file_htmlserializer_2_entw3c.html create mode 100644 content/base/test/file_htmlserializer_2_latin1.html create mode 100644 content/base/test/test_bug424359-1.html create mode 100644 content/base/test/test_bug424359-2.html create mode 100644 content/base/test/unit/1_original.xml create mode 100644 content/base/test/unit/1_result.xml create mode 100644 content/base/test/unit/2_original.xml create mode 100644 content/base/test/unit/2_result_1.xml create mode 100644 content/base/test/unit/head_utilities.js create mode 100644 content/base/test/unit/test_xmlserializer.js diff --git a/content/base/test/file_htmlserializer_1.html b/content/base/test/file_htmlserializer_1.html new file mode 100644 index 00000000000..2fdd09cf670 --- /dev/null +++ b/content/base/test/file_htmlserializer_1.html @@ -0,0 +1,43 @@ + + + + + Test for html serializer + + + +

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero + + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_bodyonly.html b/content/base/test/file_htmlserializer_1_bodyonly.html new file mode 100644 index 00000000000..6329a10fd3c --- /dev/null +++ b/content/base/test/file_htmlserializer_1_bodyonly.html @@ -0,0 +1,38 @@ + + +

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer +adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. +Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_format.html b/content/base/test/file_htmlserializer_1_format.html new file mode 100644 index 00000000000..d6ecbd218f8 --- /dev/null +++ b/content/base/test/file_htmlserializer_1_format.html @@ -0,0 +1,47 @@ + + + + + Test for html serializer + + +

Hello world

+

Lorem ipsum dolor sit amet, consectetuer +adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. +Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu +ad litora torquent per +conubia nostra, per inceptos hymenaeos.

+ +
Duis tristique egestas ligula. Mauris quis felis.
+ +
    +
  1. Fusce a ipsum
  2. +
  3. non lacus posuere aliquet.
  4. +
  5. Sed fermentum posuere nulla
  6. +
  7. Donec tempor.
  8. +
+Donec sollicitudin tortor +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero + + diff --git a/content/base/test/file_htmlserializer_1_linebreak.html b/content/base/test/file_htmlserializer_1_linebreak.html new file mode 100644 index 00000000000..81ba1853441 --- /dev/null +++ b/content/base/test/file_htmlserializer_1_linebreak.html @@ -0,0 +1,44 @@ + + + + + + Test for html serializer + + +

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer +adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. +Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_links.html b/content/base/test/file_htmlserializer_1_links.html new file mode 100644 index 00000000000..d020fd6a349 --- /dev/null +++ b/content/base/test/file_htmlserializer_1_links.html @@ -0,0 +1,44 @@ + + + + + + Test for html serializer + + +

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer +adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. +Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_nested_body.html b/content/base/test/file_htmlserializer_1_nested_body.html new file mode 100644 index 00000000000..ffcc6aa312f --- /dev/null +++ b/content/base/test/file_htmlserializer_1_nested_body.html @@ -0,0 +1,44 @@ + + + + + + Test for html serializer + + +

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer +adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. +Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero +

this is an other body element

\ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_no_body.html b/content/base/test/file_htmlserializer_1_no_body.html new file mode 100644 index 00000000000..b3bf69725ac --- /dev/null +++ b/content/base/test/file_htmlserializer_1_no_body.html @@ -0,0 +1,8 @@ + + + + + + Test for html serializer + + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_noflag.html b/content/base/test/file_htmlserializer_1_noflag.html new file mode 100644 index 00000000000..81ba1853441 --- /dev/null +++ b/content/base/test/file_htmlserializer_1_noflag.html @@ -0,0 +1,44 @@ + + + + + + Test for html serializer + + +

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer +adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. +Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_noformatpre.html b/content/base/test/file_htmlserializer_1_noformatpre.html new file mode 100644 index 00000000000..d4486dc320e --- /dev/null +++ b/content/base/test/file_htmlserializer_1_noformatpre.html @@ -0,0 +1,48 @@ + + + + + + Test for html serializer + + +

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer +adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. +Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+
+ Cras quis
+
+ nisi at odio
+
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum, 
+
+lacus risus pulvinar ante.
+
+ut gravida eros leo ut libero + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_raw.html b/content/base/test/file_htmlserializer_1_raw.html new file mode 100644 index 00000000000..9b7a0cd9c87 --- /dev/null +++ b/content/base/test/file_htmlserializer_1_raw.html @@ -0,0 +1,42 @@ + + + + + + Test for html serializer + + +

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_sibling_body.html b/content/base/test/file_htmlserializer_1_sibling_body.html new file mode 100644 index 00000000000..564761ff6d8 --- /dev/null +++ b/content/base/test/file_htmlserializer_1_sibling_body.html @@ -0,0 +1,44 @@ + + + + + + Test for html serializer + +

this is an other body element

+

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer +adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. +Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_1_sibling_body_only_body.html b/content/base/test/file_htmlserializer_1_sibling_body_only_body.html new file mode 100644 index 00000000000..76a21801841 --- /dev/null +++ b/content/base/test/file_htmlserializer_1_sibling_body_only_body.html @@ -0,0 +1,38 @@ + +

this is an other body element

+

Hello world

+ + Lorem ipsum dolor sit amet, consectetuer +adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. +Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad + litora torquent per conubia +nostra, per inceptos hymenaeos.

+ + + +
Duis tristique egestas ligula. Mauris quis felis.
+ + +
  1. Fusce + a ipsum
  2. non lacus posuere aliquet.
  3. Sed fermentum posuere nulla
  4. Donec tempor.
+Donec sollicitudin tortor + +
lacinia libero ullamcorper laoreet.
+ Cras quis
+ nisi at odio
+ consectetuer molestie. Curabitur consectetuer urna a sem. Nunc non urna. Cras in massa. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sollicitudin, nulla at pharetra rutrum,
+lacus risus pulvinar ante. +
+ut gravida eros leo ut libero + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_2.html b/content/base/test/file_htmlserializer_2.html new file mode 100644 index 00000000000..c5033998c15 --- /dev/null +++ b/content/base/test/file_htmlserializer_2.html @@ -0,0 +1,29 @@ + + + + Test for html serializer with entities + + + +

The basic set is just   & < > " for interoperability with older products that don't support α and friends.

+ +

latin1 ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ +µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ +Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø +Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê +ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý +þ ÿ

+

symbols, math.. ƒ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ +Φ Χ Ψ Ω α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς +σ τ υ φ χ ψ ω ϑ ϒ ϖ • … ′ ″ ‾ ⁄ ℘ ℑ ℜ +™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉ +∋ ∏ ∑ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ +⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ ⟨ ⟩ ◊ ♠ ♣ ♥ ♦ +

+

others +Œ œ Š š Ÿ ˆ ˜       ‌ ‍ ‎ ‏–— ‘ ’ +‚“ ” „ † ‡ ‰ ‹ › € +

+ + + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_2_basic.html b/content/base/test/file_htmlserializer_2_basic.html new file mode 100644 index 00000000000..61b9faec93e --- /dev/null +++ b/content/base/test/file_htmlserializer_2_basic.html @@ -0,0 +1,29 @@ + + + + + + Test for html serializer with entities + + +

The basic set is just   & < > " for interoperability with older products that don't support α and friends.

+ +

latin1 ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ +µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ +Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø +Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê +ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý +þ ÿ

+

symbols, math.. ƒ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ +Φ Χ Ψ Ω α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς +σ τ υ φ χ ψ ω ϑ ϒ ϖ • … ′ ″ ‾ ⁄ ℘ ℑ ℜ +™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉ +∋ ∏ ∑ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ +⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ 〈 〉 ◊ ♠ ♣ ♥ ♦ +

+

others +Œ œ Š š Ÿ ˆ ˜       ‌ ‍ ‎ ‏–— ‘ ’ +‚“ ” „ † ‡ ‰ ‹ › € +

+ + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_2_enthtml.html b/content/base/test/file_htmlserializer_2_enthtml.html new file mode 100644 index 00000000000..4148ff46ead --- /dev/null +++ b/content/base/test/file_htmlserializer_2_enthtml.html @@ -0,0 +1,50 @@ + + + + + + Test for html serializer with entities + + +

The basic set is just   & < > " for interoperability with older products that don't support α and friends.

+ +

latin1 ¡ ¢ £ ¤ ¥ ¦ § ¨ +© ª « ¬ ­ ® ¯ ° ± ² +³ ´ µ ¶ · ¸ ¹ º » +¼ ½ ¾ ¿ À Á Â Ã +Ä Å Æ +Ç È É Ê Ë Ì Í Î +Ï Ð Ñ Ò Ó Ô Õ Ö × +Ø +Ù Ú Û Ü Ý Þ ß à +á â ã ä å æ ç è +é ê ë ì í î ï ð ñ +ò ó ô õ ö ÷ ø ù +ú û ü ý þ ÿ

+

symbols, math.. ƒ Α Β Γ Δ Ε +Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο +Π Ρ Σ Τ Υ +Φ Χ Ψ Ω α β γ δ ε +ζ η θ ι κ λ μ ν ξ ο +π ρ ς +σ τ υ φ χ ψ ω ϑ ϒ +ϖ • … ′ ″ ‾ ⁄ ℘ ℑ +ℜ +™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ +⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ +∈ ∉ +∋ ∏ ∑ − ∗ √ ∝ ∞ ∠ ∧ +∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ +≥ +⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ +⌉ ⌊ ⌋ ⟨ ⟩ ◊ ♠ ♣ ♥ +♦ +

+

others +Œ œ Š š Ÿ ˆ ˜     +  ‌ ‍ ‎ ‏–— ‘ ’ +‚“ ” „ † ‡ ‰ ‹ +› € +

+ + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_2_entw3c.html b/content/base/test/file_htmlserializer_2_entw3c.html new file mode 100644 index 00000000000..4148ff46ead --- /dev/null +++ b/content/base/test/file_htmlserializer_2_entw3c.html @@ -0,0 +1,50 @@ + + + + + + Test for html serializer with entities + + +

The basic set is just   & < > " for interoperability with older products that don't support α and friends.

+ +

latin1 ¡ ¢ £ ¤ ¥ ¦ § ¨ +© ª « ¬ ­ ® ¯ ° ± ² +³ ´ µ ¶ · ¸ ¹ º » +¼ ½ ¾ ¿ À Á Â Ã +Ä Å Æ +Ç È É Ê Ë Ì Í Î +Ï Ð Ñ Ò Ó Ô Õ Ö × +Ø +Ù Ú Û Ü Ý Þ ß à +á â ã ä å æ ç è +é ê ë ì í î ï ð ñ +ò ó ô õ ö ÷ ø ù +ú û ü ý þ ÿ

+

symbols, math.. ƒ Α Β Γ Δ Ε +Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο +Π Ρ Σ Τ Υ +Φ Χ Ψ Ω α β γ δ ε +ζ η θ ι κ λ μ ν ξ ο +π ρ ς +σ τ υ φ χ ψ ω ϑ ϒ +ϖ • … ′ ″ ‾ ⁄ ℘ ℑ +ℜ +™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ +⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ +∈ ∉ +∋ ∏ ∑ − ∗ √ ∝ ∞ ∠ ∧ +∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ +≥ +⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ +⌉ ⌊ ⌋ ⟨ ⟩ ◊ ♠ ♣ ♥ +♦ +

+

others +Œ œ Š š Ÿ ˆ ˜     +  ‌ ‍ ‎ ‏–— ‘ ’ +‚“ ” „ † ‡ ‰ ‹ +› € +

+ + \ No newline at end of file diff --git a/content/base/test/file_htmlserializer_2_latin1.html b/content/base/test/file_htmlserializer_2_latin1.html new file mode 100644 index 00000000000..4e3587be649 --- /dev/null +++ b/content/base/test/file_htmlserializer_2_latin1.html @@ -0,0 +1,36 @@ + + + + + + Test for html serializer with entities + + +

The basic set is just   & < > " for interoperability with older products that don't support α and friends.

+ +

latin1 ¡ ¢ £ ¤ ¥ ¦ § ¨ +© ª « ¬ ­ ® ¯ ° ± ² +³ ´ µ ¶ · ¸ ¹ º » +¼ ½ ¾ ¿ À Á Â Ã +Ä Å Æ +Ç È É Ê Ë Ì Í Î +Ï Ð Ñ Ò Ó Ô Õ Ö × +Ø +Ù Ú Û Ü Ý Þ ß à +á â ã ä å æ ç è +é ê ë ì í î ï ð ñ +ò ó ô õ ö ÷ ø ù +ú û ü ý þ ÿ

+

symbols, math.. ƒ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ +Φ Χ Ψ Ω α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς +σ τ υ φ χ ψ ω ϑ ϒ ϖ • … ′ ″ ‾ ⁄ ℘ ℑ ℜ +™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉ +∋ ∏ ∑ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ +⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ 〈 〉 ◊ ♠ ♣ ♥ ♦ +

+

others +Œ œ Š š Ÿ ˆ ˜       ‌ ‍ ‎ ‏–— ‘ ’ +‚“ ” „ † ‡ ‰ ‹ › € +

+ + \ No newline at end of file diff --git a/content/base/test/test_bug424359-1.html b/content/base/test/test_bug424359-1.html new file mode 100644 index 00000000000..b4e8e8d4791 --- /dev/null +++ b/content/base/test/test_bug424359-1.html @@ -0,0 +1,201 @@ + + + + + Test for HTML serializer + + + + + +Mozilla Bug +

+ +
+
+
+ + + + + + diff --git a/content/base/test/test_bug424359-2.html b/content/base/test/test_bug424359-2.html new file mode 100644 index 00000000000..48b967b3f36 --- /dev/null +++ b/content/base/test/test_bug424359-2.html @@ -0,0 +1,96 @@ + + + + + Test HTML serializer with entities + + + + + +Mozilla Bug +

+ +
+
+
+ + \ No newline at end of file diff --git a/content/base/test/unit/1_original.xml b/content/base/test/unit/1_original.xml new file mode 100644 index 00000000000..4b7915159de --- /dev/null +++ b/content/base/test/unit/1_original.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/content/base/test/unit/1_result.xml b/content/base/test/unit/1_result.xml new file mode 100644 index 00000000000..61d4458be93 --- /dev/null +++ b/content/base/test/unit/1_result.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/content/base/test/unit/2_original.xml b/content/base/test/unit/2_original.xml new file mode 100644 index 00000000000..75640616b06 --- /dev/null +++ b/content/base/test/unit/2_original.xml @@ -0,0 +1,16 @@ + + + + + <robots> & <aliens> + a a a a a éèàùûî + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam tellus massa, fringilla aliquam, fermentum sit amet, posuere ac, est. Duis tristique egestas ligula. Mauris quis felis. Fusce a ipsum non lacus posuere aliquet. Sed fermentum posuere nulla. Donec tempor. Donec sollicitudin tortor lacinia libero ullamcorper laoreet. Cras quis nisi at odio consectetuer molestie. + + + + + \ No newline at end of file diff --git a/content/base/test/unit/2_result_1.xml b/content/base/test/unit/2_result_1.xml new file mode 100644 index 00000000000..a8ad34a63c2 --- /dev/null +++ b/content/base/test/unit/2_result_1.xml @@ -0,0 +1,14 @@ + + + + + <robots> & <aliens> + a a a a a éèàùûî + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam eu sapien. Sed viverra lacus. Donec quis ipsum. Nunc cursus aliquet lectus. Nunc vitae eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam tellus massa, fringilla aliquam, fermentum sit amet, posuere ac, est. Duis tristique egestas ligula. Mauris quis felis. Fusce a ipsum non lacus posuere aliquet. Sed fermentum posuere nulla. Donec tempor. Donec sollicitudin tortor lacinia libero ullamcorper laoreet. Cras quis nisi at odio consectetuer molestie. + + + + + \ No newline at end of file diff --git a/content/base/test/unit/head_utilities.js b/content/base/test/unit/head_utilities.js new file mode 100644 index 00000000000..aeeadd03574 --- /dev/null +++ b/content/base/test/unit/head_utilities.js @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla.org + * + * The Initial Developer of the Original Code is Disruptive Innovations. + * + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Laurent Jouanneau , Original author + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +const gBasePath = "content/base/test/unit/"; +const nsIDocumentEncoder = Components.interfaces.nsIDocumentEncoder; +const replacementChar = Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER; + +function loadContentFile(aFile, aCharset) { + //if(aAsIso == undefined) aAsIso = false; + if(aCharset == undefined) + aCharset = 'UTF-8'; + + var file = do_get_file(gBasePath+aFile); + var ios = Components.classes['@mozilla.org/network/io-service;1'] + .getService(Components.interfaces.nsIIOService); + var chann = ios.newChannelFromURI ( ios.newFileURI (file) ); + chann.contentCharset = aCharset; + + /*var inputStream = Components.classes["@mozilla.org/scriptableinputstream;1"] + .createInstance(Components.interfaces.nsIScriptableInputStream); + inputStream.init(chann.open()); + return inputStream.read(file.fileSize); + */ + + var inputStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"] + .createInstance(Components.interfaces.nsIConverterInputStream); + inputStream.init(chann.open(), aCharset, 1024, replacementChar); + var str = {}, content = ''; + while (inputStream.readString(4096, str) != 0) { + content += str.value; + } + return content; +} diff --git a/content/base/test/unit/test_xmlserializer.js b/content/base/test/unit/test_xmlserializer.js new file mode 100644 index 00000000000..7a6678c248c --- /dev/null +++ b/content/base/test/unit/test_xmlserializer.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla.org. + * + * The Initial Developer of the Original Code is Disruptive Innovations. + * + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Laurent Jouanneau , Original author + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +function xmlEncode(aFile, aFlags, aCharset) { + if(aFlags == undefined) aFlags = 0; + if(aCharset == undefined) aCharset = "UTF-8"; + + var doc = do_parse_document(gBasePath+aFile, "text/xml"); + + var encoder = Components.classes["@mozilla.org/layout/documentEncoder;1?type=text/xml"] + .createInstance(nsIDocumentEncoder); + encoder.setCharset(aCharset); + encoder.init(doc, "text/xml", aFlags); + return encoder.encodeToString(); +} + +function run_test() +{ + var result, expected; + const de = Components.interfaces.nsIDocumentEncoder; + + result = xmlEncode("1_original.xml", de.OutputLFLineBreak); + expected =loadContentFile("1_result.xml"); + do_check_eq(expected, result); + + result = xmlEncode("2_original.xml", de.OutputLFLineBreak); + expected = loadContentFile("2_result_1.xml"); + do_check_eq(expected, result); + + result = xmlEncode("2_original.xml", de.OutputLFLineBreak); + do_check_eq(expected, result); + + result = xmlEncode("2_original.xml", de.OutputCRLineBreak); + expected = expected.replace(/\n/g, "\r"); + do_check_eq(expected, result); + + result = xmlEncode("2_original.xml", de.OutputLFLineBreak | de.OutputCRLineBreak); + expected = expected.replace(/\r/mg, "\r\n"); + do_check_eq(expected, result); +}