summaryrefslogtreecommitdiffstats
path: root/parser/htmlparser/tests/reftest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /parser/htmlparser/tests/reftest
parentInitial commit. (diff)
downloadfirefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.tar.xz
firefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'parser/htmlparser/tests/reftest')
-rw-r--r--parser/htmlparser/tests/reftest/after-1kb-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/after-1kb.html955
-rw-r--r--parser/htmlparser/tests/reftest/after-bogus-after-1kb-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/after-bogus-after-1kb.html933
-rw-r--r--parser/htmlparser/tests/reftest/after-bogus-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/after-bogus.html10
-rw-r--r--parser/htmlparser/tests/reftest/after-head-after-1kb-crlf-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/after-head-after-1kb-crlf.html927
-rw-r--r--parser/htmlparser/tests/reftest/after-head-after-1kb-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/after-head-after-1kb.html933
-rw-r--r--parser/htmlparser/tests/reftest/after-head-in-1kb-crlf-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/after-head-in-1kb-crlf.html932
-rw-r--r--parser/htmlparser/tests/reftest/after-head-in-1kb-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/after-head-in-1kb.html938
-rw-r--r--parser/htmlparser/tests/reftest/baseline-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/baseline.html10
-rw-r--r--parser/htmlparser/tests/reftest/bug1153920-1-ref.html4
-rw-r--r--parser/htmlparser/tests/reftest/bug1153920-1.html3
-rw-r--r--parser/htmlparser/tests/reftest/bug1319410-1-ref.html6
-rw-r--r--parser/htmlparser/tests/reftest/bug1319410-1.html5
-rw-r--r--parser/htmlparser/tests/reftest/bug1636607-1-ref.html18
-rw-r--r--parser/htmlparser/tests/reftest/bug1636607-1.html18
-rw-r--r--parser/htmlparser/tests/reftest/bug1636607-2-ref.html17
-rw-r--r--parser/htmlparser/tests/reftest/bug1636607-2.html18
-rw-r--r--parser/htmlparser/tests/reftest/bug1650087-1-ref.html8
-rw-r--r--parser/htmlparser/tests/reftest/bug1650087-1.html7
-rw-r--r--parser/htmlparser/tests/reftest/bug1726374-1-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug1726374-1.html1
-rw-r--r--parser/htmlparser/tests/reftest/bug1749522-1-ref.txt3
-rw-r--r--parser/htmlparser/tests/reftest/bug1749522-1.txt3
-rw-r--r--parser/htmlparser/tests/reftest/bug482921-1-ref.html27
-rw-r--r--parser/htmlparser/tests/reftest/bug482921-1.html24
-rw-r--r--parser/htmlparser/tests/reftest/bug482921-2-ref.html28
-rw-r--r--parser/htmlparser/tests/reftest/bug482921-2.xhtml25
-rw-r--r--parser/htmlparser/tests/reftest/bug535530-1-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug535530-1.html14
-rw-r--r--parser/htmlparser/tests/reftest/bug535530-2-ref.html17
-rw-r--r--parser/htmlparser/tests/reftest/bug535530-2.html14
-rw-r--r--parser/htmlparser/tests/reftest/bug566280-1-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug566280-1.htmlbin0 -> 19 bytes
-rw-r--r--parser/htmlparser/tests/reftest/bug569229-1-ref.xml2
-rw-r--r--parser/htmlparser/tests/reftest/bug569229-1.xml6
-rw-r--r--parser/htmlparser/tests/reftest/bug577418-1-ref.html6
-rw-r--r--parser/htmlparser/tests/reftest/bug577418-1.html15
-rw-r--r--parser/htmlparser/tests/reftest/bug582788-1-ref.html11
-rw-r--r--parser/htmlparser/tests/reftest/bug582788-1.html11
-rw-r--r--parser/htmlparser/tests/reftest/bug582940-1-ref.html16
-rw-r--r--parser/htmlparser/tests/reftest/bug582940-1.html16
-rw-r--r--parser/htmlparser/tests/reftest/bug592656-1-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug592656-1.html32
-rw-r--r--parser/htmlparser/tests/reftest/bug599320-1-ref.html17
-rw-r--r--parser/htmlparser/tests/reftest/bug599320-1.htmlbin0 -> 616 bytes
-rw-r--r--parser/htmlparser/tests/reftest/bug608373-1-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug608373-1.html14
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-1-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-1.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-2-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-2.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-3-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-3.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-4-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-4.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-5-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-5.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-6-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug659763-6.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug673094-1-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug673094-1.html9
-rw-r--r--parser/htmlparser/tests/reftest/bug696651-1-ref.html1
-rw-r--r--parser/htmlparser/tests/reftest/bug696651-1.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug696651-2-ref.html1
-rw-r--r--parser/htmlparser/tests/reftest/bug696651-2.html6
-rw-r--r--parser/htmlparser/tests/reftest/bug696651-external.js1
-rw-r--r--parser/htmlparser/tests/reftest/bug700260-1-ref.html3
-rw-r--r--parser/htmlparser/tests/reftest/bug700260-1.html3
-rw-r--r--parser/htmlparser/tests/reftest/bug704667-1-ref.html4
-rw-r--r--parser/htmlparser/tests/reftest/bug704667-1.html1
-rw-r--r--parser/htmlparser/tests/reftest/bug731234-1-ref.html30
-rw-r--r--parser/htmlparser/tests/reftest/bug731234-1.html27
-rw-r--r--parser/htmlparser/tests/reftest/bug820508-1-ref.html6
-rw-r--r--parser/htmlparser/tests/reftest/bug820508-1.html6
-rw-r--r--parser/htmlparser/tests/reftest/bug910588-1-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug910588-1.html1
-rw-r--r--parser/htmlparser/tests/reftest/document-write-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/document-write.html10
-rw-r--r--parser/htmlparser/tests/reftest/frame582940-ref.html51
-rw-r--r--parser/htmlparser/tests/reftest/frame582940.html51
-rw-r--r--parser/htmlparser/tests/reftest/frame599320-1-ref.html15
-rw-r--r--parser/htmlparser/tests/reftest/frame599320-1.html1092
-rw-r--r--parser/htmlparser/tests/reftest/in-comment-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/in-comment.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-noscript-after-template-after-1kb-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/in-noscript-after-template-after-1kb.html894
-rw-r--r--parser/htmlparser/tests/reftest/in-noscript-after-template-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/in-noscript-after-template.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-noscript-ncr-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/in-noscript-ncr.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-noscript-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/in-noscript.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-object-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/in-object.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-script-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/in-script.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-style-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/in-style.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-svg-in-cdata-after-gt-ref.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-svg-in-cdata-after-gt.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-svg-in-cdata-ref.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-svg-in-cdata.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-svg-ref.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-svg.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-template-after-1kb-ref.html8
-rw-r--r--parser/htmlparser/tests/reftest/in-template-after-1kb.html1046
-rw-r--r--parser/htmlparser/tests/reftest/in-template-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/in-template.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-title-ref.html10
-rw-r--r--parser/htmlparser/tests/reftest/in-title.html10
-rw-r--r--parser/htmlparser/tests/reftest/incomplete-xml-decl-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/incomplete-xml-decl.xml1
-rw-r--r--parser/htmlparser/tests/reftest/ncr-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/ncr.html10
-rw-r--r--parser/htmlparser/tests/reftest/non-ascii-in-comment-before-ref.html9
-rw-r--r--parser/htmlparser/tests/reftest/non-ascii-in-comment-before.html11
-rw-r--r--parser/htmlparser/tests/reftest/non-ascii-in-title-before-ref.html10
-rw-r--r--parser/htmlparser/tests/reftest/non-ascii-in-title-before.html11
-rw-r--r--parser/htmlparser/tests/reftest/reftest.list73
-rw-r--r--parser/htmlparser/tests/reftest/view-source-bom-ref.html10
-rw-r--r--parser/htmlparser/tests/reftest/view-source-bom.html9
-rw-r--r--parser/htmlparser/tests/reftest/vs-after-head-after-1kb-ref.html11
-rw-r--r--parser/htmlparser/tests/reftest/vs-after-head-after-1kb.html10
-rw-r--r--parser/htmlparser/tests/reftest/vs-after-head-in-1kb-ref.html12
-rw-r--r--parser/htmlparser/tests/reftest/vs-after-head-in-1kb.html11
-rw-r--r--parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before-ref.html12
-rw-r--r--parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before.html11
-rw-r--r--parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before.sjs16
-rw-r--r--parser/htmlparser/tests/reftest/xml-1.xml1
-rw-r--r--parser/htmlparser/tests/reftest/xml-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/xml-trickle-1.sjs17
-rw-r--r--parser/htmlparser/tests/reftest/xml-trickle-2.sjs17
-rw-r--r--parser/htmlparser/tests/reftest/xml-trickle-3.sjs21
-rw-r--r--parser/htmlparser/tests/reftest/xml-trickle-4.sjs17
-rw-r--r--parser/htmlparser/tests/reftest/xml-trickle-5.sjs17
-rw-r--r--parser/htmlparser/tests/reftest/xml-trickle-6.sjs21
-rw-r--r--parser/htmlparser/tests/reftest/xml-utf-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/xml-without-tags-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/xml-without-tags.xml1
146 files changed, 10091 insertions, 0 deletions
diff --git a/parser/htmlparser/tests/reftest/after-1kb-ref.html b/parser/htmlparser/tests/reftest/after-1kb-ref.html
new file mode 100644
index 0000000000..edb0ae9c72
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-1kb-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>In <code>head</code>, after first kilobyte.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-1kb.html b/parser/htmlparser/tests/reftest/after-1kb.html
new file mode 100644
index 0000000000..01eedca187
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-1kb.html
@@ -0,0 +1,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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<meta charset="windows-1251">
+</head>
+<body>
+<p>In <code>head</code>, after first kilobyte.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-bogus-after-1kb-ref.html b/parser/htmlparser/tests/reftest/after-bogus-after-1kb-ref.html
new file mode 100644
index 0000000000..c6f129a89e
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-bogus-after-1kb-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>After <code>bogus</code>, before <code>head</code> end tag, after first kilobyte.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-bogus-after-1kb.html b/parser/htmlparser/tests/reftest/after-bogus-after-1kb.html
new file mode 100644
index 0000000000..f44fda1e6d
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-bogus-after-1kb.html
@@ -0,0 +1,933 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/after-bogus-after-1kb-ref.html">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<bogus><meta charset="windows-1251">
+</head>
+<body>
+<p>After <code>bogus</code>, before <code>head</code> end tag, after first kilobyte.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-bogus-ref.html b/parser/htmlparser/tests/reftest/after-bogus-ref.html
new file mode 100644
index 0000000000..f8080e60aa
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-bogus-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta after <code>bogus</code>.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-bogus.html b/parser/htmlparser/tests/reftest/after-bogus.html
new file mode 100644
index 0000000000..7eeedde7af
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-bogus.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/after-bogus-ref.html">
+<bogus><meta charset="windows-1251">
+</head>
+<body>
+<p>Meta after <code>bogus</code>.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-head-after-1kb-crlf-ref.html b/parser/htmlparser/tests/reftest/after-head-after-1kb-crlf-ref.html
new file mode 100644
index 0000000000..868a9639bf
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-head-after-1kb-crlf-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>After <code>head</code>, before <code>body</code>, after first kilobyte, with a CRLF in the first kilobyte.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-head-after-1kb-crlf.html b/parser/htmlparser/tests/reftest/after-head-after-1kb-crlf.html
new file mode 100644
index 0000000000..10a6d1c3d7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-head-after-1kb-crlf.html
@@ -0,0 +1,927 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/after-head-after-1kb-crlf-ref.html">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</head>
+<meta charset="windows-1251">
+<body>
+<p>After <code>head</code>, before <code>body</code>, after first kilobyte, with a CRLF in the first kilobyte.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-head-after-1kb-ref.html b/parser/htmlparser/tests/reftest/after-head-after-1kb-ref.html
new file mode 100644
index 0000000000..bde4745b26
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-head-after-1kb-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>After <code>head</code>, before <code>body</code>, after first kilobyte.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-head-after-1kb.html b/parser/htmlparser/tests/reftest/after-head-after-1kb.html
new file mode 100644
index 0000000000..d514fdfbff
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-head-after-1kb.html
@@ -0,0 +1,933 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/after-head-after-1kb-ref.html">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</head>
+<meta charset="windows-1251">
+<body>
+<p>After <code>head</code>, before <code>body</code>, after first kilobyte.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-head-in-1kb-crlf-ref.html b/parser/htmlparser/tests/reftest/after-head-in-1kb-crlf-ref.html
new file mode 100644
index 0000000000..0676d7374e
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-head-in-1kb-crlf-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>After <code>head</code>, before <code>body</code>, within first kilobyte, with a CRLF in the first kilobyte.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-head-in-1kb-crlf.html b/parser/htmlparser/tests/reftest/after-head-in-1kb-crlf.html
new file mode 100644
index 0000000000..e5c95e7036
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-head-in-1kb-crlf.html
@@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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<meta charset="windows-1251">
+<body>
+<p>After <code>head</code>, before <code>body</code>, within first kilobyte, with a CRLF in the first kilobyte.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-head-in-1kb-ref.html b/parser/htmlparser/tests/reftest/after-head-in-1kb-ref.html
new file mode 100644
index 0000000000..75fc2dd618
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-head-in-1kb-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>After <code>head</code>, before <code>body</code>, within first kilobyte.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/after-head-in-1kb.html b/parser/htmlparser/tests/reftest/after-head-in-1kb.html
new file mode 100644
index 0000000000..e73522d373
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/after-head-in-1kb.html
@@ -0,0 +1,938 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/after-head-in-1kb-ref.html">
+</head>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<meta charset="windows-1251">
+<body>
+<p>After <code>head</code>, before <code>body</code>, within first kilobyte.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/baseline-ref.html b/parser/htmlparser/tests/reftest/baseline-ref.html
new file mode 100644
index 0000000000..21b939efe0
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/baseline-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Normal meta.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/baseline.html b/parser/htmlparser/tests/reftest/baseline.html
new file mode 100644
index 0000000000..40bce2f63f
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/baseline.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/baseline-ref.html">
+<meta charset="windows-1251">
+</head>
+<body>
+<p>Normal meta.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/bug1153920-1-ref.html b/parser/htmlparser/tests/reftest/bug1153920-1-ref.html
new file mode 100644
index 0000000000..6c7e8fb13c
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1153920-1-ref.html
@@ -0,0 +1,4 @@
+<html><head><meta name="viewport" content="width=device-width"><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
+<span id="line2"></span></span><span>&lt;<span class="start-tag">a</span> <span class="attribute-name">href</span>='<a class="attribute-value" href="?a=b&amp;c=d&amp;a0b=c&amp;copy=1&amp;noti=n&amp;not=in&amp;notin=%26%238713%3B%AC&amp;;&amp;%20&amp;">?a=b<span><span>&amp;</span>c</span>=d<span><span>&amp;</span>a</span>0b=c<span><span>&amp;</span>copy</span>=1<span><span>&amp;</span>noti</span>=n<span><span>&amp;</span>not</span>=in<span><span>&amp;</span>notin</span>=<span class="entity"><span>&amp;</span>notin;</span><span class="entity"><span>&amp;</span>not;</span><span><span>&amp;</span></span>;<span><span>&amp;</span></span> <span><span>&amp;</span></span></a>'&gt;</span><span>Link</span><span>&lt;/<span class="end-tag">a</span>&gt;</span><span>
+<span id="line3"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>Text: ?a=b<span><span>&amp;</span>c</span>=d<span><span>&amp;</span>a</span>0b=c<span class="error entity" title="Named character reference was not terminated by a semicolon. (Or “&amp;” should have been escaped as “&amp;amp;”.)"><span>&amp;</span>copy</span>=1<span class="error entity" title="Named character reference was not terminated by a semicolon. (Or “&amp;” should have been escaped as “&amp;amp;”.)"><span>&amp;</span>noti</span>=n<span class="error entity" title="Named character reference was not terminated by a semicolon. (Or “&amp;” should have been escaped as “&amp;amp;”.)"><span>&amp;</span>not</span>=in<span class="error entity" title="Named character reference was not terminated by a semicolon. (Or “&amp;” should have been escaped as “&amp;amp;”.)"><span>&amp;</span>notin</span>=<span class="entity"><span>&amp;</span>notin;</span><span class="entity"><span>&amp;</span>not;</span><span><span>&amp;</span></span>;<span><span>&amp;</span></span> <span><span>&amp;</span></span></span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line4"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/bug1153920-1.html b/parser/htmlparser/tests/reftest/bug1153920-1.html
new file mode 100644
index 0000000000..f36b2b0581
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1153920-1.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<a href='?a=b&c=d&a0b=c&copy=1&noti=n&not=in&notin=&notin;&not;&;& &'>Link</a>
+<p>Text: ?a=b&c=d&a0b=c&copy=1&noti=n&not=in&notin=&notin;&not;&;& &</p>
diff --git a/parser/htmlparser/tests/reftest/bug1319410-1-ref.html b/parser/htmlparser/tests/reftest/bug1319410-1-ref.html
new file mode 100644
index 0000000000..abce6d8540
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1319410-1-ref.html
@@ -0,0 +1,6 @@
+<html><head><meta name="viewport" content="width=device-width"><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
+<span id="line2"></span></span><span class="comment">&lt;!-- -- --&gt;</span><span>
+<span id="line3"></span></span><span class="error comment" title="Saw “<!--” within a comment. Probable cause: Nested comment (not allowed).">&lt;!-- &lt;!-- --&gt;</span><span> --&gt;
+<span id="line4"></span></span><span class="error comment" title="Premature end of comment. Use “-->” to end a comment properly.">&lt;!--&gt;</span><span>
+<span id="line5"></span></span><span class="comment">&lt;!--&lt;!--&gt;
+<span id="line6"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/bug1319410-1.html b/parser/htmlparser/tests/reftest/bug1319410-1.html
new file mode 100644
index 0000000000..04363210af
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1319410-1.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<!-- -- -->
+<!-- <!-- --> -->
+<!-->
+<!--<!-->
diff --git a/parser/htmlparser/tests/reftest/bug1636607-1-ref.html b/parser/htmlparser/tests/reftest/bug1636607-1-ref.html
new file mode 100644
index 0000000000..b5e24f87a7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1636607-1-ref.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<style>
+div { border: medium solid blue }
+span { background: #9090ff; }
+span.test::before {
+ white-space: pre;
+ content: "\A";
+}
+</style>
+<p>This document is in <span id="mode"></span> mode.</p>
+<p>This is a test for the line height quirk which is present in limited-quirks mode <b>and</b> quirks mode:</p>
+<div><span style="font-size: 50%">hello<br>hello</span></div>
+<p>This is a test for the hashless hex color quirk which is present in quirks mode <b>only</b>:</p>
+<div style="background-color: 9090ff">test</div>
+
+<script>
+document.getElementById("mode").innerText = document.compatMode;
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug1636607-1.html b/parser/htmlparser/tests/reftest/bug1636607-1.html
new file mode 100644
index 0000000000..af2c2cb3e8
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1636607-1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//FR" "http://www.w3.org/TR/html4/loose.dtd">
+<style>
+div { border: medium solid blue }
+span { background: #9090ff; }
+span.test::before {
+ white-space: pre;
+ content: "\A";
+}
+</style>
+<p>This document is in <span id="mode"></span> mode.</p>
+<p>This is a test for the line height quirk which is present in limited-quirks mode <b>and</b> quirks mode:</p>
+<div><span style="font-size: 50%">hello<br>hello</span></div>
+<p>This is a test for the hashless hex color quirk which is present in quirks mode <b>only</b>:</p>
+<div style="background-color: 9090ff">test</div>
+
+<script>
+document.getElementById("mode").innerText = document.compatMode;
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug1636607-2-ref.html b/parser/htmlparser/tests/reftest/bug1636607-2-ref.html
new file mode 100644
index 0000000000..e82fd73824
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1636607-2-ref.html
@@ -0,0 +1,17 @@
+<style>
+div { border: medium solid blue }
+span { background: #9090ff; }
+span.test::before {
+ white-space: pre;
+ content: "\A";
+}
+</style>
+<p>This document is in <span id="mode"></span> mode.</p>
+<p>This is a test for the line height quirk which is present in limited-quirks mode <b>and</b> quirks mode:</p>
+<div><span style="font-size: 50%">hello<br>hello</span></div>
+<p>This is a test for the hashless hex color quirk which is present in quirks mode <b>only</b>:</p>
+<div style="background-color: 9090ff">test</div>
+
+<script>
+document.getElementById("mode").innerText = document.compatMode;
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug1636607-2.html b/parser/htmlparser/tests/reftest/bug1636607-2.html
new file mode 100644
index 0000000000..f551df5ac1
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1636607-2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//FR">
+<style>
+div { border: medium solid blue }
+span { background: #9090ff; }
+span.test::before {
+ white-space: pre;
+ content: "\A";
+}
+</style>
+<p>This document is in <span id="mode"></span> mode.</p>
+<p>This is a test for the line height quirk which is present in limited-quirks mode <b>and</b> quirks mode:</p>
+<div><span style="font-size: 50%">hello<br>hello</span></div>
+<p>This is a test for the hashless hex color quirk which is present in quirks mode <b>only</b>:</p>
+<div style="background-color: 9090ff">test</div>
+
+<script>
+document.getElementById("mode").innerText = document.compatMode;
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug1650087-1-ref.html b/parser/htmlparser/tests/reftest/bug1650087-1-ref.html
new file mode 100644
index 0000000000..284f097100
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1650087-1-ref.html
@@ -0,0 +1,8 @@
+<html><head><meta name="viewport" content="width=device-width"><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
+<span id="line2"></span></span><span>&lt;<span class="start-tag">template</span>&gt;</span><span></span><span>&lt;<span class="start-tag">td</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">template</span>&gt;</span><span>
+<span id="line3"></span></span><span>&lt;<span class="start-tag">template</span>&gt;</span><span></span><span>&lt;<span class="start-tag">tr</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">template</span>&gt;</span><span>
+<span id="line4"></span></span><span>&lt;<span class="start-tag">template</span>&gt;</span><span></span><span>&lt;<span class="start-tag">thead</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">template</span>&gt;</span><span>
+<span id="line5"></span></span><span>&lt;<span class="start-tag">template</span>&gt;</span><span></span><span>&lt;<span class="start-tag">tbody</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">template</span>&gt;</span><span>
+<span id="line6"></span></span><span>&lt;<span class="start-tag">template</span>&gt;</span><span></span><span>&lt;<span class="start-tag">tfoot</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">template</span>&gt;</span><span>
+<span id="line7"></span></span><span>&lt;<span class="start-tag">template</span>&gt;</span><span></span><span>&lt;<span class="start-tag">colgroup</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">template</span>&gt;</span><span>
+<span id="line8"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/bug1650087-1.html b/parser/htmlparser/tests/reftest/bug1650087-1.html
new file mode 100644
index 0000000000..c5b92f1615
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1650087-1.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<template><td></template>
+<template><tr></template>
+<template><thead></template>
+<template><tbody></template>
+<template><tfoot></template>
+<template><colgroup></template>
diff --git a/parser/htmlparser/tests/reftest/bug1726374-1-ref.html b/parser/htmlparser/tests/reftest/bug1726374-1-ref.html
new file mode 100644
index 0000000000..1bd351963d
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1726374-1-ref.html
@@ -0,0 +1,2 @@
+<html><head><meta name="viewport" content="width=device-width"><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span></span><span class="comment">&lt;!-- a &lt;!--&gt;</span><span>b
+<span id="line2"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/bug1726374-1.html b/parser/htmlparser/tests/reftest/bug1726374-1.html
new file mode 100644
index 0000000000..edcb3952c5
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1726374-1.html
@@ -0,0 +1 @@
+<!DOCTYPE html><!-- a <!-->b
diff --git a/parser/htmlparser/tests/reftest/bug1749522-1-ref.txt b/parser/htmlparser/tests/reftest/bug1749522-1-ref.txt
new file mode 100644
index 0000000000..c95d7230fd
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1749522-1-ref.txt
@@ -0,0 +1,3 @@
+<script>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+To jest test kodowania znaków. W przypadku niektórych języków, które używają znaków łacińskich, potrzebujemy więcej danych, aby podjąć decyzję.
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug1749522-1.txt b/parser/htmlparser/tests/reftest/bug1749522-1.txt
new file mode 100644
index 0000000000..3520d89838
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug1749522-1.txt
@@ -0,0 +1,3 @@
+<script>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+To jest test kodowania znakw. W przypadku niektrych jzykw, ktre uywaj znakw aciskich, potrzebujemy wicej danych, aby podj decyzj.
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug482921-1-ref.html b/parser/htmlparser/tests/reftest/bug482921-1-ref.html
new file mode 100644
index 0000000000..71c0f91c08
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug482921-1-ref.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">html</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">head</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">title</span>&gt;</span><span>Title</span><span>&lt;/<span class="end-tag">title</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">script</span>&gt;</span>
+<span id></span>var lt = "&lt;";
+<span id></span>&lt;!--
+<span id></span>var s = "&lt;script&gt;foo&lt;/script&gt;";
+<span id></span>--&gt;
+<span id></span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span></span><span class="comment">&lt;!-- Comment. --&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">style</span>&gt;</span>
+<span id></span>/* &lt;/foo&gt; */
+<span id></span><span>&lt;/<span class="end-tag">style</span>&gt;</span>
+<span id></span><span>&lt;/<span class="end-tag">head</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">body</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>Entity: <span class="entity"><span>&amp;</span>amp; </span></span><span>&lt;/<span class="end-tag">p</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">iframe</span>&gt;</span>&lt;img&gt;<span>&lt;/<span class="end-tag">iframe</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">noscript</span>&gt;</span>&lt;p&gt;Not para&lt;/p&gt;<span>&lt;/<span class="end-tag">noscript</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">svg</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">title</span>&gt;</span><span></span><span class="cdata">&lt;![CDATA[bar]]&gt;</span><span></span><span>&lt;/<span class="end-tag">title</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span class="comment">&lt;!-- this is a comment --&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span>&gt;</span>
+<span id></span><span>&lt;/<span class="end-tag">svg</span>&gt;</span>
+<span id></span><span>&lt;/<span class="end-tag">body</span>&gt;</span>
+<span id></span><span>&lt;/<span class="end-tag">html</span>&gt;</span>
+<span id></span>
+</pre>
+<!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
diff --git a/parser/htmlparser/tests/reftest/bug482921-1.html b/parser/htmlparser/tests/reftest/bug482921-1.html
new file mode 100644
index 0000000000..ca603844f2
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug482921-1.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Title</title>
+<script>
+var lt = "<";
+<!--
+var s = "<script>foo</script>";
+-->
+</script><!-- Comment. -->
+<style>
+/* </foo> */
+</style>
+</head>
+<body>
+<p>Entity: &amp; </p>
+<iframe><img></iframe>
+<noscript><p>Not para</p></noscript>
+<svg>
+<title><![CDATA[bar]]></title>
+<script><!-- this is a comment --></script>
+</svg>
+</body>
+</html>
diff --git a/parser/htmlparser/tests/reftest/bug482921-2-ref.html b/parser/htmlparser/tests/reftest/bug482921-2-ref.html
new file mode 100644
index 0000000000..d764c70bca
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug482921-2-ref.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="pi">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
+<span id></span><span class="pi">&lt;?foo bar?&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">html</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">head</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">title</span>&gt;</span><span>Title</span><span>&lt;/<span class="end-tag">title</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">script</span>&gt;</span>
+<span id></span>var s = "<span>&lt;<span class="start-tag">script</span>&gt;</span><span>foo</span><span>&lt;/<span class="end-tag">script</span>&gt;</span>";
+<span id></span><span class="comment">&lt;!--
+<span id></span>var s = "&lt;script&gt;foo&lt;/script&gt;";
+<span id></span>--&gt;</span>
+<span id></span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span></span>
+<span id></span><span>&lt;<span class="start-tag">style</span>&gt;</span>
+<span id></span>/* <span>&lt;<span class="start-tag">foo</span><span>/</span>&gt;</span> */
+<span id></span><span>&lt;/<span class="end-tag">style</span>&gt;</span>
+<span id></span><span>&lt;/<span class="end-tag">head</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">body</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>Entity: <span class="entity"><span>&amp;</span>amp; </span></span><span>&lt;/<span class="end-tag">p</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">iframe</span>&gt;</span><span></span><span>&lt;<span class="start-tag">img</span>&gt;</span><span>&lt;/<span class="end-tag">iframe</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">noscript</span>&gt;</span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>Not para</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>&lt;/<span class="end-tag">noscript</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">svg</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">title</span>&gt;</span><span></span><span class="cdata">&lt;![CDATA[bar]]&gt;</span><span></span><span>&lt;/<span class="end-tag">title</span>&gt;</span>
+<span id></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span class="comment">&lt;!-- this is a comment --&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span>&gt;</span>
+<span id></span><span>&lt;/<span class="end-tag">svg</span>&gt;</span>
+<span id></span><span>&lt;/<span class="end-tag">body</span>&gt;</span>
+<span id></span><span>&lt;/<span class="end-tag">html</span>&gt;</span>
+<span id></span>
+</pre>
+<!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
diff --git a/parser/htmlparser/tests/reftest/bug482921-2.xhtml b/parser/htmlparser/tests/reftest/bug482921-2.xhtml
new file mode 100644
index 0000000000..4d3f0b6a73
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug482921-2.xhtml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?foo bar?>
+<html>
+<head>
+<title>Title</title>
+<script>
+var s = "<script>foo</script>";
+<!--
+var s = "<script>foo</script>";
+-->
+</script>
+<style>
+/* <foo/> */
+</style>
+</head>
+<body>
+<p>Entity: &amp; </p>
+<iframe><img></iframe>
+<noscript><p>Not para</p></noscript>
+<svg>
+<title><![CDATA[bar]]></title>
+<script><!-- this is a comment --></script>
+</svg>
+</body>
+</html>
diff --git a/parser/htmlparser/tests/reftest/bug535530-1-ref.html b/parser/htmlparser/tests/reftest/bug535530-1-ref.html
new file mode 100644
index 0000000000..22d0dc0b0b
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug535530-1-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html><meta charset=utf-8>
+XX&amp;XX XX&amp;nXX XX&amp;noXX XX¬XX XX¬iXX XX¬inXX XX&amp;;XX XX&amp;n;XX XX&amp;no;XX XX¬XX XX¬i;XX XX∉XX
diff --git a/parser/htmlparser/tests/reftest/bug535530-1.html b/parser/htmlparser/tests/reftest/bug535530-1.html
new file mode 100644
index 0000000000..63f2d8782e
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug535530-1.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+XX&XX
+XX&nXX
+XX&noXX
+XX&notXX
+XX&notiXX
+XX&notinXX
+XX&;XX
+XX&n;XX
+XX&no;XX
+XX&not;XX
+XX&noti;XX
+XX&notin;XX
+
diff --git a/parser/htmlparser/tests/reftest/bug535530-2-ref.html b/parser/htmlparser/tests/reftest/bug535530-2-ref.html
new file mode 100644
index 0000000000..174e94dc8b
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug535530-2-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span>
+<span id></span>XX&amp;XX
+<span id></span>XX&amp;nXX
+<span id></span>XX&amp;noXX
+<span id></span>XX<span class="error entity">&amp;not</span>XX
+<span id></span>XX<span class="error entity">&amp;noti</span>XX
+<span id></span>XX<span class="error entity">&amp;notin</span>XX
+<span id></span>XX&amp;;XX
+<span id></span>XX<span class="error">&amp;</span>n;XX
+<span id></span>XX<span class="error">&amp;</span>no;XX
+<span id></span>XX<span class="entity">&amp;not;</span>XX
+<span id></span>XX<span class="error entity">&amp;noti</span>;XX
+<span id></span>XX<span class="entity">&amp;notin;</span>XX
+<span id></span>
+<span id></span>
+</pre>
+<!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
diff --git a/parser/htmlparser/tests/reftest/bug535530-2.html b/parser/htmlparser/tests/reftest/bug535530-2.html
new file mode 100644
index 0000000000..63f2d8782e
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug535530-2.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+XX&XX
+XX&nXX
+XX&noXX
+XX&notXX
+XX&notiXX
+XX&notinXX
+XX&;XX
+XX&n;XX
+XX&no;XX
+XX&not;XX
+XX&noti;XX
+XX&notin;XX
+
diff --git a/parser/htmlparser/tests/reftest/bug566280-1-ref.html b/parser/htmlparser/tests/reftest/bug566280-1-ref.html
new file mode 100644
index 0000000000..6585cac38f
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug566280-1-ref.html
@@ -0,0 +1,2 @@
+<body>hello world
+
diff --git a/parser/htmlparser/tests/reftest/bug566280-1.html b/parser/htmlparser/tests/reftest/bug566280-1.html
new file mode 100644
index 0000000000..3aa60caf34
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug566280-1.html
Binary files differ
diff --git a/parser/htmlparser/tests/reftest/bug569229-1-ref.xml b/parser/htmlparser/tests/reftest/bug569229-1-ref.xml
new file mode 100644
index 0000000000..652f1d7da8
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug569229-1-ref.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" standalone="yes" ?>
+<html xmlns="http://www.w3.org/1999/xhtml"><p>abcd</p></html>
diff --git a/parser/htmlparser/tests/reftest/bug569229-1.xml b/parser/htmlparser/tests/reftest/bug569229-1.xml
new file mode 100644
index 0000000000..2e1ff75603
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug569229-1.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" standalone="yes" ?>
+<!DOCTYPE html [
+ <!ENTITY inner "<script src='script.js'></script><p>abcd</p>">
+ <!ENTITY outer "&inner;">
+]>
+<html xmlns="http://www.w3.org/1999/xhtml">&outer;</html>
diff --git a/parser/htmlparser/tests/reftest/bug577418-1-ref.html b/parser/htmlparser/tests/reftest/bug577418-1-ref.html
new file mode 100644
index 0000000000..ff773d5364
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug577418-1-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<style>
+html {
+ background-color: lime;
+}
+</style>
diff --git a/parser/htmlparser/tests/reftest/bug577418-1.html b/parser/htmlparser/tests/reftest/bug577418-1.html
new file mode 100644
index 0000000000..cfd53be0a8
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug577418-1.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html style="width:100%;height:100%;margin:0;border:0;overflow:hidden">
+<body style="width:100%;height:100%;margin:0;border:0;overflow:hidden">
+<svg style="width:100%;height:100%">
+ <rect height="100%" width="100%" fill="red"/>
+ <foreignObject>
+ <html>
+ <body>
+ </body>
+ </html>
+ </foreignObject>
+ <rect height="100%" width="100%" fill="lime"/>
+</svg>
+</body>
+</html>
diff --git a/parser/htmlparser/tests/reftest/bug582788-1-ref.html b/parser/htmlparser/tests/reftest/bug582788-1-ref.html
new file mode 100644
index 0000000000..c1f684807a
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug582788-1-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8">
+<title>Not ISO-10646</title>
+</head>
+<body>
+<p>Not ISO-10646</p>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/bug582788-1.html b/parser/htmlparser/tests/reftest/bug582788-1.html
new file mode 100644
index 0000000000..ee31b3de9d
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug582788-1.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=iso-10646">
+<title>Not ISO-10646</title>
+</head>
+<body>
+<p>Not ISO-10646</p>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/bug582940-1-ref.html b/parser/htmlparser/tests/reftest/bug582940-1-ref.html
new file mode 100644
index 0000000000..7209c8e69e
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug582940-1-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<head>
+<meta charset=utf-8>
+<title>Fragment nav</title>
+<script>
+function loaded() {
+ document.documentElement.removeAttribute("class");
+}
+</script>
+</head>
+<body onload='setTimeout(loaded, 10);'>
+<iframe src="frame582940-ref.html#ref"></iframe>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/bug582940-1.html b/parser/htmlparser/tests/reftest/bug582940-1.html
new file mode 100644
index 0000000000..fd721a8bc3
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug582940-1.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<head>
+<meta charset=utf-8>
+<title>Fragment nav</title>
+<script>
+function loaded() {
+ document.documentElement.removeAttribute("class");
+}
+</script>
+</head>
+<body onload='setTimeout(loaded, 10);'>
+<iframe src="frame582940.html#ref%20ref"></iframe>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/bug592656-1-ref.html b/parser/htmlparser/tests/reftest/bug592656-1-ref.html
new file mode 100644
index 0000000000..824d815633
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug592656-1-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>document.write() from script-inserted inline scripts and script@onload</title>
+</head>
+<body>
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
+</body>
+</html>
diff --git a/parser/htmlparser/tests/reftest/bug592656-1.html b/parser/htmlparser/tests/reftest/bug592656-1.html
new file mode 100644
index 0000000000..769f62f648
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug592656-1.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>document.write() from script-inserted inline scripts and script@onload</title>
+</head>
+<body>
+1
+<script>
+function write(num) {
+ document.write(num + " ");
+}
+function scriptload() {
+ document.write("\u003Cscript src='data:text/javascript,write(9)'>\u003C/script> 10 \u003Cscript>write(11)\u003C/script>");
+ write(12);
+}
+function scripterror() {
+ document.write("\u003Cscript src='data:text/javascript,write(16)'>\u003C/script> 17 \u003Cscript>write(18)\u003C/script>");
+ write(19);
+}
+write(2);
+document.write("\u003Cscript src='data:text/javascript,write(3)'>\u003C/script> 4 \u003Cscript>write(5)\u003C/script>");
+var s = document.createElement("script");
+s.textContent = "write(6)";
+document.body.appendChild(s);
+write(7);
+document.write("\u003Cscript src='data:text/javascript,write(8)' onload='scriptload()'>\u003C/script> 13 \u003Cscript>write(14)\u003C/script>");
+write(15);
+document.write(`\u003Cscript src='nosuchscriptoutthere.js' onload='write("fail")' onerror='scripterror()'>\u003C/script> 20 \u003Cscript>write(21)\u003C/script>`);
+write(22);
+</script>
+</body>
+</html>
diff --git a/parser/htmlparser/tests/reftest/bug599320-1-ref.html b/parser/htmlparser/tests/reftest/bug599320-1-ref.html
new file mode 100644
index 0000000000..bb48fe5d25
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug599320-1-ref.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset=utf-8>
+<meta content="width=device-width, initial-scale=1" name="viewport">
+<title>UTF-16 doc</title>
+</head>
+<body>
+<h1>UTF-16 doc</h1>
+
+<p>Euro sign: €</p>
+<p>iframe:</p>
+<iframe src=frame599320-1-ref.html width=300 height=400></iframe>
+
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/bug599320-1.html b/parser/htmlparser/tests/reftest/bug599320-1.html
new file mode 100644
index 0000000000..590e9126c3
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug599320-1.html
Binary files differ
diff --git a/parser/htmlparser/tests/reftest/bug608373-1-ref.html b/parser/htmlparser/tests/reftest/bug608373-1-ref.html
new file mode 100644
index 0000000000..69fec47d0f
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug608373-1-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+ <iframe src="data:text/html,TEXT"></iframe>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/bug608373-1.html b/parser/htmlparser/tests/reftest/bug608373-1.html
new file mode 100644
index 0000000000..7bc47552f7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug608373-1.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<head>
+<script>
+function write() {
+ document.getElementsByTagName("iframe")[0].contentDocument.write('\u003Cscript src="data:text/javascript,var i = 0;">\u003C\/script>TEXT\u003Cscript>parent.document.documentElement.removeAttribute("class");\u003c/script>');
+}
+</script>
+</head>
+<body onload="write();">
+ <iframe></iframe>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/bug659763-1-ref.html b/parser/htmlparser/tests/reftest/bug659763-1-ref.html
new file mode 100644
index 0000000000..99429bf4e7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-1-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<iframe src="data:text/html,<i>foo</i>"></iframe>
diff --git a/parser/htmlparser/tests/reftest/bug659763-1.html b/parser/htmlparser/tests/reftest/bug659763-1.html
new file mode 100644
index 0000000000..46dbde092e
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-1.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<iframe></iframe>
+<script>
+var iframe = document.getElementsByTagName("iframe")[0];
+var doc = iframe.contentDocument;
+doc.open("text/plain");
+doc.write("<i>foo</i>");
+doc.close();
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug659763-2-ref.html b/parser/htmlparser/tests/reftest/bug659763-2-ref.html
new file mode 100644
index 0000000000..99429bf4e7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-2-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<iframe src="data:text/html,<i>foo</i>"></iframe>
diff --git a/parser/htmlparser/tests/reftest/bug659763-2.html b/parser/htmlparser/tests/reftest/bug659763-2.html
new file mode 100644
index 0000000000..c6152193aa
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-2.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<iframe></iframe>
+<script>
+var iframe = document.getElementsByTagName("iframe")[0];
+var doc = iframe.contentDocument;
+doc.open("TEXT/PLAIN");
+doc.write("<i>foo</i>");
+doc.close();
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug659763-3-ref.html b/parser/htmlparser/tests/reftest/bug659763-3-ref.html
new file mode 100644
index 0000000000..99429bf4e7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-3-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<iframe src="data:text/html,<i>foo</i>"></iframe>
diff --git a/parser/htmlparser/tests/reftest/bug659763-3.html b/parser/htmlparser/tests/reftest/bug659763-3.html
new file mode 100644
index 0000000000..bd2ed094bc
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-3.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<iframe></iframe>
+<script>
+var iframe = document.getElementsByTagName("iframe")[0];
+var doc = iframe.contentDocument;
+doc.open("foo/bar");
+doc.write("<i>foo</i>");
+doc.close();
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug659763-4-ref.html b/parser/htmlparser/tests/reftest/bug659763-4-ref.html
new file mode 100644
index 0000000000..99429bf4e7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-4-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<iframe src="data:text/html,<i>foo</i>"></iframe>
diff --git a/parser/htmlparser/tests/reftest/bug659763-4.html b/parser/htmlparser/tests/reftest/bug659763-4.html
new file mode 100644
index 0000000000..5317186351
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-4.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<iframe></iframe>
+<script>
+var iframe = document.getElementsByTagName("iframe")[0];
+var doc = iframe.contentDocument;
+doc.open("text/html");
+doc.write("<i>foo</i>");
+doc.close();
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug659763-5-ref.html b/parser/htmlparser/tests/reftest/bug659763-5-ref.html
new file mode 100644
index 0000000000..99429bf4e7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-5-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<iframe src="data:text/html,<i>foo</i>"></iframe>
diff --git a/parser/htmlparser/tests/reftest/bug659763-5.html b/parser/htmlparser/tests/reftest/bug659763-5.html
new file mode 100644
index 0000000000..23e9fd8e6f
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-5.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<iframe></iframe>
+<script>
+var iframe = document.getElementsByTagName("iframe")[0];
+var doc = iframe.contentDocument;
+doc.open();
+doc.write("<i>foo</i>");
+doc.close();
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug659763-6-ref.html b/parser/htmlparser/tests/reftest/bug659763-6-ref.html
new file mode 100644
index 0000000000..99429bf4e7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-6-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<iframe src="data:text/html,<i>foo</i>"></iframe>
diff --git a/parser/htmlparser/tests/reftest/bug659763-6.html b/parser/htmlparser/tests/reftest/bug659763-6.html
new file mode 100644
index 0000000000..f0a5ea8d3f
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug659763-6.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<iframe></iframe>
+<script>
+var iframe = document.getElementsByTagName("iframe")[0];
+var doc = iframe.contentDocument;
+doc.open("TEXT/HTML");
+doc.write("<i>foo</i>");
+doc.close();
+</script>
diff --git a/parser/htmlparser/tests/reftest/bug673094-1-ref.html b/parser/htmlparser/tests/reftest/bug673094-1-ref.html
new file mode 100644
index 0000000000..f8f8ce5939
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug673094-1-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>bidi in attribute</title>
+</head>
+<body>
+<p>Persian <a href="http://en.wiktionary.org/wiki/%D9%81%D8%A7%D8%B1%D8%B3%DB%8C" title="wikt:فارسی‎" >فارسی</a></p>
+</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/bug673094-1.html b/parser/htmlparser/tests/reftest/bug673094-1.html
new file mode 100644
index 0000000000..2fbdbfb10d
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug673094-1.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>bidi in attribute</title>
+</head>
+<body>
+<p>Persian <a href="http://en.wiktionary.org/wiki/%D9%81%D8%A7%D8%B1%D8%B3%DB%8C" title="wikt:فارسی" >فارسی</a></p>
+</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/bug696651-1-ref.html b/parser/htmlparser/tests/reftest/bug696651-1-ref.html
new file mode 100644
index 0000000000..02f59b7ae6
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug696651-1-ref.html
@@ -0,0 +1 @@
+<!DOCTYPE html>CcBbAa
diff --git a/parser/htmlparser/tests/reftest/bug696651-1.html b/parser/htmlparser/tests/reftest/bug696651-1.html
new file mode 100644
index 0000000000..50a9135aa3
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug696651-1.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<body><script>document.write("\u003cscript>document.write(\"\\u003cscript src='bug696651-external.js'>\\u003c/script>B\"); document.write(\"b\");\u003c/script>A"); document.write("a");</script>
diff --git a/parser/htmlparser/tests/reftest/bug696651-2-ref.html b/parser/htmlparser/tests/reftest/bug696651-2-ref.html
new file mode 100644
index 0000000000..7999785c09
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug696651-2-ref.html
@@ -0,0 +1 @@
+<!DOCTYPE html><iframe src="data:text/html,<!DOCTYPE html>CcBbAa"></iframe>
diff --git a/parser/htmlparser/tests/reftest/bug696651-2.html b/parser/htmlparser/tests/reftest/bug696651-2.html
new file mode 100644
index 0000000000..2d3515b6af
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug696651-2.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<body>
+<iframe></iframe>
+<script>
+var doc = document.getElementsByTagName("iframe")[0].contentDocument;
+doc.open(); doc.write("\u003cscript>document.write(\"\\u003cscript src='bug696651-external.js'>\\u003c/script>B\"); document.write(\"b\");\u003c/script>A"); doc.write("a"); doc.close();</script>
diff --git a/parser/htmlparser/tests/reftest/bug696651-external.js b/parser/htmlparser/tests/reftest/bug696651-external.js
new file mode 100644
index 0000000000..c1c2a8f788
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug696651-external.js
@@ -0,0 +1 @@
+document.write("C"); document.write("c");
diff --git a/parser/htmlparser/tests/reftest/bug700260-1-ref.html b/parser/htmlparser/tests/reftest/bug700260-1-ref.html
new file mode 100644
index 0000000000..0ba4495a09
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug700260-1-ref.html
@@ -0,0 +1,3 @@
+ 1
+ 2
+ 3
diff --git a/parser/htmlparser/tests/reftest/bug700260-1.html b/parser/htmlparser/tests/reftest/bug700260-1.html
new file mode 100644
index 0000000000..37d3008347
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug700260-1.html
@@ -0,0 +1,3 @@
+ 1
+ 2
+ 3
diff --git a/parser/htmlparser/tests/reftest/bug704667-1-ref.html b/parser/htmlparser/tests/reftest/bug704667-1-ref.html
new file mode 100644
index 0000000000..a7a939f3a4
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug704667-1-ref.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="error comment">&lt;!--&gt;</span> <span class="error comment">&lt;!X&gt;</span>
+<span id></span>
+</pre>
+<!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
diff --git a/parser/htmlparser/tests/reftest/bug704667-1.html b/parser/htmlparser/tests/reftest/bug704667-1.html
new file mode 100644
index 0000000000..553c62b309
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug704667-1.html
@@ -0,0 +1 @@
+<!--> <!X>
diff --git a/parser/htmlparser/tests/reftest/bug731234-1-ref.html b/parser/htmlparser/tests/reftest/bug731234-1-ref.html
new file mode 100644
index 0000000000..897b73ea1b
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug731234-1-ref.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="wrap highlight"><pre id><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
+<span id></span></span><span>&lt;<span class="start-tag">body</span>&gt;</span><span>
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span> &gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;/<span class="end-tag">script</span>
+<span id></span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span title="End tag had attributes." class="error">&lt;/<span class="end-tag">script</span> <span class="attribute-name">foo</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span title="End tag had attributes." class="error">&lt;/<span class="end-tag">script</span> <span class="attribute-name">foo</span>=<a class="attribute-value">bar</a>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span title="End tag had attributes." class="error">&lt;/<span class="end-tag">script</span> <span class="attribute-name">foo</span>="<a class="attribute-value">bar</a>"&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>--</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>-- </span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>-- </span><span>&lt;/<span class="end-tag">script</span> &gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>-- </span><span>&lt;/<span class="end-tag">script</span>
+<span id></span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>-- </span><span title="End tag had attributes." class="error">&lt;/<span class="end-tag">script</span> <span class="attribute-name">foo</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>-- </span><span title="End tag had attributes." class="error">&lt;/<span class="end-tag">script</span> <span class="attribute-name">foo</span>=<a class="attribute-value">bar</a>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>-- </span><span title="End tag had attributes." class="error">&lt;/<span class="end-tag">script</span> <span class="attribute-name">foo</span>="<a class="attribute-value">bar</a>"&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>-- -</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>-- --</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>-- --&gt;</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>--</span><span>&lt;s</span><span>cript&gt; &lt;/script&gt; </span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>--</span><span>&lt;s</span><span>cript&gt; &lt;/script&gt; --&gt;</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>--</span><span>&lt;s</span><span>cript &lt;/script&gt; --&gt;</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>--</span><span>&lt;s</span><span>cript&gt; &lt;/script &gt; --&gt;</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>--</span><span>&lt;s</span><span>cript&gt; &lt;/script foo&gt; --&gt;</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>--</span><span>&lt;s</span><span>cript&gt; &lt;/script foo=bar&gt; --&gt;</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span><span>&lt;<span class="start-tag">script</span>&gt;</span><span></span><span>&lt;!</span><span>--</span><span>&lt;s</span><span>cript&gt; &lt;/script foo="bar"&gt; --&gt;</span><span>&lt;/<span class="end-tag">script</span>&gt;</span><span>X
+<span id></span></span>
+</pre>
+<!-- View source CSS matches the <pre id> and <span id> elements and produces line numbers. -->
diff --git a/parser/htmlparser/tests/reftest/bug731234-1.html b/parser/htmlparser/tests/reftest/bug731234-1.html
new file mode 100644
index 0000000000..313e44cca7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug731234-1.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<body>
+<script></script>X
+<script></script >X
+<script></script
+>X
+<script></script foo>X
+<script></script foo=bar>X
+<script></script foo="bar">X
+<script><!--</script>X
+<script><!-- </script>X
+<script><!-- </script >X
+<script><!-- </script
+>X
+<script><!-- </script foo>X
+<script><!-- </script foo=bar>X
+<script><!-- </script foo="bar">X
+<script><!-- -</script>X
+<script><!-- --</script>X
+<script><!-- --></script>X
+<script><!--<script> </script> </script>X
+<script><!--<script> </script> --></script>X
+<script><!--<script </script> --></script>X
+<script><!--<script> </script > --></script>X
+<script><!--<script> </script foo> --></script>X
+<script><!--<script> </script foo=bar> --></script>X
+<script><!--<script> </script foo="bar"> --></script>X
diff --git a/parser/htmlparser/tests/reftest/bug820508-1-ref.html b/parser/htmlparser/tests/reftest/bug820508-1-ref.html
new file mode 100644
index 0000000000..e624b16885
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug820508-1-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<title>main { display: block; }</title>
+<style>div {
+ border: 2px solid blue;
+}</style>
+<div>foo</div><div>bar</div>
diff --git a/parser/htmlparser/tests/reftest/bug820508-1.html b/parser/htmlparser/tests/reftest/bug820508-1.html
new file mode 100644
index 0000000000..60eabee67d
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug820508-1.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<title>main { display: block; }</title>
+<style>main {
+ border: 2px solid blue;
+}</style>
+<main>foo</main><main>bar</main>
diff --git a/parser/htmlparser/tests/reftest/bug910588-1-ref.html b/parser/htmlparser/tests/reftest/bug910588-1-ref.html
new file mode 100644
index 0000000000..46133dd2c4
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug910588-1-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="-moz-tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span></span><span>&lt;<span class="start-tag">table</span>&gt;</span><span></span><span title="Start tag “input” seen in “table”." class="error">&lt;<span class="start-tag">input</span> <span class="attribute-name">type</span>=<a class="attribute-value">hidden</a>&gt;</span><span></span><span>&lt;/<span class="end-tag">table</span>&gt;</span><span>
+<span id="line2"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/bug910588-1.html b/parser/htmlparser/tests/reftest/bug910588-1.html
new file mode 100644
index 0000000000..d0f5958582
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug910588-1.html
@@ -0,0 +1 @@
+<!DOCTYPE html><table><input type=hidden></table>
diff --git a/parser/htmlparser/tests/reftest/document-write-ref.html b/parser/htmlparser/tests/reftest/document-write-ref.html
new file mode 100644
index 0000000000..9902cf77d1
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/document-write-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta from <code>document.write</code> (with concatenation in the middle of <code>charset</code> to require execution for effect).</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/document-write.html b/parser/htmlparser/tests/reftest/document-write.html
new file mode 100644
index 0000000000..b70a15c567
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/document-write.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/document-write-ref.html">
+<script>document.write('<meta char' + 'set="windows-1251">');</script>
+</head>
+<body>
+<p>Meta from <code>document.write</code> (with concatenation in the middle of <code>charset</code> to require execution for effect).</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/frame582940-ref.html b/parser/htmlparser/tests/reftest/frame582940-ref.html
new file mode 100644
index 0000000000..ac665679b5
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/frame582940-ref.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset=utf-8>
+<title>Fragment nav</title>
+</head>
+<body>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p><a name='ref'>Ref!</a></p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/frame582940.html b/parser/htmlparser/tests/reftest/frame582940.html
new file mode 100644
index 0000000000..646b7d5a71
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/frame582940.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset=utf-8>
+<title>Fragment nav</title>
+</head>
+<body>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p><a name='ref%20ref'>Ref!</a></p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+<p>Filler</p>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/frame599320-1-ref.html b/parser/htmlparser/tests/reftest/frame599320-1-ref.html
new file mode 100644
index 0000000000..735c368f8b
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/frame599320-1-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset=utf-8>
+<meta content="width=device-width, initial-scale=1" name="viewport">
+<title>Non-UTF-16 doc</title>
+</head>
+<body>
+<h1>Non-UTF-16 doc</h1>
+
+<p>Euro sign: €</p>
+
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/frame599320-1.html b/parser/htmlparser/tests/reftest/frame599320-1.html
new file mode 100644
index 0000000000..145ee94ba8
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/frame599320-1.html
@@ -0,0 +1,1092 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<!-- More than 1 KB of space -->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+<meta charset=utf-8>
+<meta content="width=device-width, initial-scale=1" name="viewport">
+<title>Non-UTF-16 doc</title>
+</head>
+<body>
+<h1>Non-UTF-16 doc</h1>
+
+<p>Euro sign: €</p>
+<script>
+window.onload = function() {
+ window.requestAnimationFrame(function() {
+ parent.document.documentElement.removeAttribute("class");
+ });
+}
+</script>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/reftest/in-comment-ref.html b/parser/htmlparser/tests/reftest/in-comment-ref.html
new file mode 100644
index 0000000000..94b2016e0d
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-comment-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta inside comment.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-comment.html b/parser/htmlparser/tests/reftest/in-comment.html
new file mode 100644
index 0000000000..65828a1872
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-comment.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-comment-ref.html">
+<!--<meta charset="windows-1251">-->
+</head>
+<body>
+<p>Meta inside comment.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-noscript-after-template-after-1kb-ref.html b/parser/htmlparser/tests/reftest/in-noscript-after-template-after-1kb-ref.html
new file mode 100644
index 0000000000..12e9b93626
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-noscript-after-template-after-1kb-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta in <code>noscript</code> after <code>template</code> (which is also inside the <code>noscript</code>) after 1kb of padding following the template.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-noscript-after-template-after-1kb.html b/parser/htmlparser/tests/reftest/in-noscript-after-template-after-1kb.html
new file mode 100644
index 0000000000..d22e83aaa7
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-noscript-after-template-after-1kb.html
@@ -0,0 +1,894 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-noscript-after-template-after-1kb-ref.html">
+<noscript><template></template>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<meta charset="windows-1251"></noscript>
+</head>
+<body>
+<p>Meta in <code>noscript</code> after <code>template</code> (which is also inside the <code>noscript</code>) after 1kb of padding following the template.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-noscript-after-template-ref.html b/parser/htmlparser/tests/reftest/in-noscript-after-template-ref.html
new file mode 100644
index 0000000000..27defe54c0
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-noscript-after-template-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta in <code>noscript</code> after <code>template</code> (which is also inside the <code>noscript</code>).</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-noscript-after-template.html b/parser/htmlparser/tests/reftest/in-noscript-after-template.html
new file mode 100644
index 0000000000..71ef9144e0
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-noscript-after-template.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-noscript-after-template-ref.html">
+<noscript><template></template><meta charset="windows-1251"></noscript>
+</head>
+<body>
+<p>Meta in <code>noscript</code> after <code>template</code> (which is also inside the <code>noscript</code>).</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-noscript-ncr-ref.html b/parser/htmlparser/tests/reftest/in-noscript-ncr-ref.html
new file mode 100644
index 0000000000..3581ab68db
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-noscript-ncr-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta with NCR in the encoding label in <code>noscript</code>.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-noscript-ncr.html b/parser/htmlparser/tests/reftest/in-noscript-ncr.html
new file mode 100644
index 0000000000..645f151b26
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-noscript-ncr.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-noscript-ncr-ref.html">
+<noscript><meta charset="&#119;indows-1251"></noscript>
+</head>
+<body>
+<p>Meta with NCR in the encoding label in <code>noscript</code>.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-noscript-ref.html b/parser/htmlparser/tests/reftest/in-noscript-ref.html
new file mode 100644
index 0000000000..9bb9f24b88
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-noscript-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta in <code>noscript</code>.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-noscript.html b/parser/htmlparser/tests/reftest/in-noscript.html
new file mode 100644
index 0000000000..e76054d618
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-noscript.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-noscript-ref.html">
+<noscript><meta charset="windows-1251"></noscript>
+</head>
+<body>
+<p>Meta in <code>noscript</code>.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-object-ref.html b/parser/htmlparser/tests/reftest/in-object-ref.html
new file mode 100644
index 0000000000..3f52d0efe9
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-object-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta in <code>object</code>.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-object.html b/parser/htmlparser/tests/reftest/in-object.html
new file mode 100644
index 0000000000..32535b8eba
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-object.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/in-object-ref.html">
+<object><meta charset="windows-1251"></object>
+</head>
+<body>
+<p>Meta in <code>object</code>.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-script-ref.html b/parser/htmlparser/tests/reftest/in-script-ref.html
new file mode 100644
index 0000000000..bbb63fd931
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-script-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta in <code>script</code>.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-script.html b/parser/htmlparser/tests/reftest/in-script.html
new file mode 100644
index 0000000000..0c18a4435e
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-script.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-script-ref.html">
+<script><meta charset="windows-1251"></script>
+</head>
+<body>
+<p>Meta in <code>script</code>.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-style-ref.html b/parser/htmlparser/tests/reftest/in-style-ref.html
new file mode 100644
index 0000000000..9669146eb5
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-style-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta in <code>style</code>.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-style.html b/parser/htmlparser/tests/reftest/in-style.html
new file mode 100644
index 0000000000..69d8fa429c
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-style.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-style-ref.html">
+<style><meta charset="windows-1251"></style>
+</head>
+<body>
+<p>Meta in <code>style</code>.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-svg-in-cdata-after-gt-ref.html b/parser/htmlparser/tests/reftest/in-svg-in-cdata-after-gt-ref.html
new file mode 100644
index 0000000000..2868f47fc2
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-svg-in-cdata-after-gt-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<svg></svg>
+<p>In SVG in CDATA after greater-than sign in the CDATA (after head).</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-svg-in-cdata-after-gt.html b/parser/htmlparser/tests/reftest/in-svg-in-cdata-after-gt.html
new file mode 100644
index 0000000000..56783b7afc
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-svg-in-cdata-after-gt.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-svg-in-cdata-after-gt-ref.html">
+</head>
+<body>
+<svg><![CDATA[><meta charset="windows-1251">]]></svg>
+<p>In SVG in CDATA after greater-than sign in the CDATA (after head).</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-svg-in-cdata-ref.html b/parser/htmlparser/tests/reftest/in-svg-in-cdata-ref.html
new file mode 100644
index 0000000000..1d17d2720b
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-svg-in-cdata-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<svg></svg>
+<p>In SVG in CDATA (after head).</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-svg-in-cdata.html b/parser/htmlparser/tests/reftest/in-svg-in-cdata.html
new file mode 100644
index 0000000000..d1c4ca12b3
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-svg-in-cdata.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-svg-in-cdata-ref.html">
+</head>
+<body>
+<svg><![CDATA[<meta charset="windows-1251">]]></svg>
+<p>In SVG in CDATA (after head).</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-svg-ref.html b/parser/htmlparser/tests/reftest/in-svg-ref.html
new file mode 100644
index 0000000000..c9e41aa177
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-svg-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<svg></svg>
+<p>In SVG (after head).</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-svg.html b/parser/htmlparser/tests/reftest/in-svg.html
new file mode 100644
index 0000000000..cb29164289
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-svg.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/in-svg-ref.html">
+</head>
+<body>
+<svg><meta charset="windows-1251"></svg>
+<p>In SVG (after head).</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-template-after-1kb-ref.html b/parser/htmlparser/tests/reftest/in-template-after-1kb-ref.html
new file mode 100644
index 0000000000..df20eba39b
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-template-after-1kb-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<head>
+</head>
+<body>
+<p>In <code>template</code>, before <code>head</code> end tag, after first kilobyte.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-template-after-1kb.html b/parser/htmlparser/tests/reftest/in-template-after-1kb.html
new file mode 100644
index 0000000000..ae77decea2
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-template-after-1kb.html
@@ -0,0 +1,1046 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-template-after-1kb-ref.html">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<template><meta charset="windows-1251"></template>
+</head>
+<body>
+<p>In <code>template</code>, before <code>head</code> end tag, after first kilobyte.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-template-ref.html b/parser/htmlparser/tests/reftest/in-template-ref.html
new file mode 100644
index 0000000000..83c0e93072
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-template-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Meta in <code>template</code>.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-template.html b/parser/htmlparser/tests/reftest/in-template.html
new file mode 100644
index 0000000000..264affc269
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-template.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/in-template-ref.html">
+<template><meta charset="windows-1251"></template>
+</head>
+<body>
+<p>Meta in <code>template</code>.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-title-ref.html b/parser/htmlparser/tests/reftest/in-title-ref.html
new file mode 100644
index 0000000000..5fb8a05f2d
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-title-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+<title><meta charset="windows-1251"></title>
+</head>
+<body>
+<p>Meta in <code>title</code>.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/in-title.html b/parser/htmlparser/tests/reftest/in-title.html
new file mode 100644
index 0000000000..7b72c48dd8
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/in-title.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/in-title-ref.html">
+<title><meta charset="windows-1251"></title>
+</head>
+<body>
+<p>Meta in <code>title</code>.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/incomplete-xml-decl-ref.html b/parser/htmlparser/tests/reftest/incomplete-xml-decl-ref.html
new file mode 100644
index 0000000000..201fe664d5
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/incomplete-xml-decl-ref.html
@@ -0,0 +1,2 @@
+<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>incomplete-xml-decl.xml</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="pi">&lt;?xml
+<span id="line2"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/incomplete-xml-decl.xml b/parser/htmlparser/tests/reftest/incomplete-xml-decl.xml
new file mode 100644
index 0000000000..1b345b6c84
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/incomplete-xml-decl.xml
@@ -0,0 +1 @@
+<?xml
diff --git a/parser/htmlparser/tests/reftest/ncr-ref.html b/parser/htmlparser/tests/reftest/ncr-ref.html
new file mode 100644
index 0000000000..1d25b4d23d
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/ncr-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>NCR in encoding label.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/ncr.html b/parser/htmlparser/tests/reftest/ncr.html
new file mode 100644
index 0000000000..9f8b7308ad
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/ncr.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/ncr-ref.html">
+<meta charset="&#119;indows-1251">
+</head>
+<body>
+<p>NCR in encoding label.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/non-ascii-in-comment-before-ref.html b/parser/htmlparser/tests/reftest/non-ascii-in-comment-before-ref.html
new file mode 100644
index 0000000000..bd2acd274c
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/non-ascii-in-comment-before-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<p>Normal meta. Non-ASCII in comment before.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/non-ascii-in-comment-before.html b/parser/htmlparser/tests/reftest/non-ascii-in-comment-before.html
new file mode 100644
index 0000000000..148c6544a3
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/non-ascii-in-comment-before.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/non-ascii-in-comment-before-ref.html">
+<!-- -->
+<meta charset="windows-1251">
+</head>
+<body>
+<p>Normal meta. Non-ASCII in comment before.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/non-ascii-in-title-before-ref.html b/parser/htmlparser/tests/reftest/non-ascii-in-title-before-ref.html
new file mode 100644
index 0000000000..4f54732432
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/non-ascii-in-title-before-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<meta charset="utf-8">
+<title>ж</title>
+</head>
+<body>
+<p>Normal meta. Non-ASCII in title before.</p>
+<p>Test: ж</p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/non-ascii-in-title-before.html b/parser/htmlparser/tests/reftest/non-ascii-in-title-before.html
new file mode 100644
index 0000000000..aac0ca94c1
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/non-ascii-in-title-before.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/non-ascii-in-title-before-ref.html">
+<title></title>
+<meta charset="windows-1251">
+</head>
+<body>
+<p>Normal meta. Non-ASCII in title before.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/reftest.list b/parser/htmlparser/tests/reftest/reftest.list
new file mode 100644
index 0000000000..6607a6112c
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/reftest.list
@@ -0,0 +1,73 @@
+== bug535530-1.html bug535530-1-ref.html
+== view-source:bug535530-2.html bug535530-2-ref.html
+== bug566280-1.html bug566280-1-ref.html
+== bug569229-1.xml bug569229-1-ref.xml
+== bug577418-1.html bug577418-1-ref.html
+== bug582788-1.html bug582788-1-ref.html
+fuzzy(0-2,0-5) skip-if(OSX) == bug582940-1.html bug582940-1-ref.html
+== bug592656-1.html bug592656-1-ref.html
+fuzzy(0-1,0-5) == bug599320-1.html bug599320-1-ref.html
+fuzzy(0-2,0-5) == bug608373-1.html bug608373-1-ref.html
+== view-source:bug482921-1.html bug482921-1-ref.html
+== view-source:bug482921-2.xhtml bug482921-2-ref.html
+fuzzy(0-2,0-5) == bug659763-1.html bug659763-1-ref.html
+fuzzy(0-1,0-5) == bug659763-2.html bug659763-2-ref.html
+fuzzy(0-1,0-5) == bug659763-3.html bug659763-3-ref.html
+fuzzy(0-2,0-3) == bug659763-4.html bug659763-4-ref.html
+fuzzy(0-1,0-5) == bug659763-5.html bug659763-5-ref.html
+fuzzy(0-1,0-5) == bug659763-6.html bug659763-6-ref.html
+== view-source:bug673094-1.html view-source:bug673094-1-ref.html
+== bug696651-1.html bug696651-1-ref.html
+== bug696651-2.html bug696651-2-ref.html
+== view-source:bug700260-1.html view-source:bug700260-1-ref.html
+== view-source:bug704667-1.html bug704667-1-ref.html
+== view-source:bug731234-1.html bug731234-1-ref.html
+== bug820508-1.html bug820508-1-ref.html
+== view-source:bug910588-1.html bug910588-1-ref.html
+== bug1636607-1.html bug1636607-1-ref.html
+== bug1636607-2.html bug1636607-2-ref.html
+== view-source:bug1319410-1.html bug1319410-1-ref.html
+== view-source:bug1650087-1.html bug1650087-1-ref.html
+== view-source:bug1726374-1.html bug1726374-1-ref.html
+== view-source:bug1153920-1.html bug1153920-1-ref.html
+== after-1kb.html after-1kb-ref.html
+!= after-bogus-after-1kb.html after-bogus-after-1kb-ref.html
+== after-bogus.html after-bogus-ref.html
+!= after-head-after-1kb-crlf.html after-head-after-1kb-crlf-ref.html
+!= after-head-after-1kb.html after-head-after-1kb-ref.html
+== after-head-in-1kb-crlf.html after-head-in-1kb-crlf-ref.html
+== after-head-in-1kb.html after-head-in-1kb-ref.html
+== baseline.html baseline-ref.html
+!= document-write.html document-write-ref.html
+!= in-comment.html in-comment-ref.html
+!= in-noscript-after-template-after-1kb.html in-noscript-after-template-after-1kb-ref.html
+!= in-noscript-after-template.html in-noscript-after-template-ref.html
+!= in-noscript.html in-noscript-ref.html
+!= in-noscript-ncr.html in-noscript-ncr-ref.html
+== in-object.html in-object-ref.html
+!= in-script.html in-script-ref.html
+!= in-style.html in-style-ref.html
+== in-svg.html in-svg-ref.html
+!= in-svg-in-cdata-after-gt.html in-svg-in-cdata-after-gt-ref.html
+!= in-svg-in-cdata.html in-svg-in-cdata-ref.html
+!= in-template-after-1kb.html in-template-after-1kb-ref.html
+== in-template.html in-template-ref.html
+!= in-title.html in-title-ref.html
+== ncr.html ncr-ref.html
+== non-ascii-in-comment-before.html non-ascii-in-comment-before-ref.html
+== non-ascii-in-title-before.html non-ascii-in-title-before-ref.html
+== view-source:xml-1.xml xml-ref.html
+HTTP(..) == view-source:xml-trickle-1.sjs xml-ref.html
+HTTP(..) == view-source:xml-trickle-2.sjs xml-ref.html
+HTTP(..) == view-source:xml-trickle-3.sjs xml-ref.html
+HTTP(..) == view-source:xml-trickle-4.sjs xml-utf-ref.html
+HTTP(..) == view-source:xml-trickle-5.sjs xml-utf-ref.html
+HTTP(..) == view-source:xml-trickle-6.sjs xml-utf-ref.html
+skip-if(Android) HTTP(..) == view-source:vs-after-head-in-1kb.html vs-after-head-in-1kb-ref.html # Skipped on Android due to inconsistent scrollbar display
+HTTP(..) != view-source:vs-after-head-after-1kb.html vs-after-head-after-1kb-ref.html
+HTTP(..) == view-source:vs-non-ascii-in-comment-before.html vs-non-ascii-in-comment-before-ref.html
+HTTP(..) == view-source:vs-non-ascii-in-comment-before.sjs vs-non-ascii-in-comment-before-ref.html
+== view-source:xml-without-tags.xml xml-without-tags-ref.html
+== view-source:incomplete-xml-decl.xml incomplete-xml-decl-ref.html
+== view-source:view-source-bom.html view-source-bom-ref.html
+skip-if(Android) == bug1749522-1.txt bug1749522-1-ref.txt # Skipped on Android due to suspicion of harness bug
diff --git a/parser/htmlparser/tests/reftest/view-source-bom-ref.html b/parser/htmlparser/tests/reftest/view-source-bom-ref.html
new file mode 100644
index 0000000000..0ed26be850
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/view-source-bom-ref.html
@@ -0,0 +1,10 @@
+<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>view-source-bom.html</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
+<span id="line2"></span></span><span>&lt;<span class="start-tag">html</span>&gt;</span><span>
+<span id="line3"></span></span><span>&lt;<span class="start-tag">head</span>&gt;</span><span>
+<span id="line4"></span> </span><span>&lt;<span class="start-tag">title</span>&gt;</span><span>UTF-8 file with a BOM</span><span>&lt;/<span class="end-tag">title</span>&gt;</span><span>
+<span id="line5"></span></span><span>&lt;/<span class="end-tag">head</span>&gt;</span><span>
+<span id="line6"></span></span><span>&lt;<span class="start-tag">body</span>&gt;</span><span>
+<span id="line7"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>UTF-8 file with a BOM. Euro sign: €</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line8"></span></span><span>&lt;/<span class="end-tag">body</span>&gt;</span><span>
+<span id="line9"></span></span><span>&lt;/<span class="end-tag">html</span>&gt;</span><span>
+<span id="line10"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/view-source-bom.html b/parser/htmlparser/tests/reftest/view-source-bom.html
new file mode 100644
index 0000000000..d10d94fbee
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/view-source-bom.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>UTF-8 file with a BOM</title>
+</head>
+<body>
+<p>UTF-8 file with a BOM. Euro sign: €</p>
+</body>
+</html>
diff --git a/parser/htmlparser/tests/reftest/vs-after-head-after-1kb-ref.html b/parser/htmlparser/tests/reftest/vs-after-head-after-1kb-ref.html
new file mode 100644
index 0000000000..5a721755b1
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/vs-after-head-after-1kb-ref.html
@@ -0,0 +1,11 @@
+<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>vs-after-head-after-1kb.html</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
+<span id="line2"></span></span><span>&lt;<span class="start-tag">head</span>&gt;</span><span>
+<span id="line3"></span></span><span>&lt;<span class="start-tag">link</span> <span class="attribute-name">rel</span>="<a class="attribute-value">mismatch</a>" <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:references/after-head-after-1kb-ref.html">references/after-head-after-1kb-ref.html</a>"&gt;</span><span>
+<span id="line4"></span> </span><span>&lt;/<span class="end-tag">head</span>&gt;</span><span>
+<span id="line5"></span></span><span class="error" title="“meta” element between “head” and “body”.">&lt;<span class="start-tag">meta</span> <span class="attribute-name">charset</span>="<a class="attribute-value">windows-1251</a>"&gt;</span><span>
+<span id="line6"></span></span><span>&lt;<span class="start-tag">body</span>&gt;</span><span>
+<span id="line7"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>After </span><span>&lt;<span class="start-tag">code</span>&gt;</span><span>head</span><span>&lt;/<span class="end-tag">code</span>&gt;</span><span>, before </span><span>&lt;<span class="start-tag">code</span>&gt;</span><span>body</span><span>&lt;/<span class="end-tag">code</span>&gt;</span><span>, after first kilobyte.</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line8"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>Test: ж</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line9"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>If <span class="entity"><span>&amp;</span>#x0436;</span>, meta takes effect</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line10"></span></span><span>&lt;/<span class="end-tag">body</span>&gt;</span><span>
+<span id="line11"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/vs-after-head-after-1kb.html b/parser/htmlparser/tests/reftest/vs-after-head-after-1kb.html
new file mode 100644
index 0000000000..6637a2a8c5
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/vs-after-head-after-1kb.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<head>
+<link rel="mismatch" href="references/after-head-after-1kb-ref.html">
+ </head>
+<meta charset="windows-1251">
+<body>
+<p>After <code>head</code>, before <code>body</code>, after first kilobyte.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/vs-after-head-in-1kb-ref.html b/parser/htmlparser/tests/reftest/vs-after-head-in-1kb-ref.html
new file mode 100644
index 0000000000..706c20da6e
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/vs-after-head-in-1kb-ref.html
@@ -0,0 +1,12 @@
+<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>vs-after-head-in-1kb.html</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
+<span id="line2"></span></span><span>&lt;<span class="start-tag">head</span>&gt;</span><span>
+<span id="line3"></span></span><span>&lt;<span class="start-tag">link</span> <span class="attribute-name">rel</span>="<a class="attribute-value">match</a>" <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:references/after-head-in-1kb-ref.html">references/after-head-in-1kb-ref.html</a>"&gt;</span><span>
+<span id="line4"></span></span><span>&lt;/<span class="end-tag">head</span>&gt;</span><span>
+<span id="line5"></span>
+<span id="line6"></span></span><span class="error" title="“meta” element between “head” and “body”.">&lt;<span class="start-tag">meta</span> <span class="attribute-name">charset</span>="<a class="attribute-value">windows-1251</a>"&gt;</span><span>
+<span id="line7"></span></span><span>&lt;<span class="start-tag">body</span>&gt;</span><span>
+<span id="line8"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>After </span><span>&lt;<span class="start-tag">code</span>&gt;</span><span>head</span><span>&lt;/<span class="end-tag">code</span>&gt;</span><span>, before </span><span>&lt;<span class="start-tag">code</span>&gt;</span><span>body</span><span>&lt;/<span class="end-tag">code</span>&gt;</span><span>, within first kilobyte.</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line9"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>Test: ж</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line10"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>If <span class="entity"><span>&amp;</span>#x0436;</span>, meta takes effect</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line11"></span></span><span>&lt;/<span class="end-tag">body</span>&gt;</span><span>
+<span id="line12"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/vs-after-head-in-1kb.html b/parser/htmlparser/tests/reftest/vs-after-head-in-1kb.html
new file mode 100644
index 0000000000..af63f06acb
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/vs-after-head-in-1kb.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/after-head-in-1kb-ref.html">
+</head>
+
+<meta charset="windows-1251">
+<body>
+<p>After <code>head</code>, before <code>body</code>, within first kilobyte.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before-ref.html b/parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before-ref.html
new file mode 100644
index 0000000000..66f0338658
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before-ref.html
@@ -0,0 +1,12 @@
+<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>vs-non-ascii-in-comment-before.html</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span>
+<span id="line2"></span></span><span>&lt;<span class="start-tag">head</span>&gt;</span><span>
+<span id="line3"></span></span><span>&lt;<span class="start-tag">link</span> <span class="attribute-name">rel</span>="<a class="attribute-value">match</a>" <span class="attribute-name">href</span>="<a class="attribute-value" href="view-source:references/non-ascii-in-comment-before-ref.html">references/non-ascii-in-comment-before-ref.html</a>"&gt;</span><span>
+<span id="line4"></span></span><span class="comment">&lt;!-- ж --&gt;</span><span>
+<span id="line5"></span></span><span>&lt;<span class="start-tag">meta</span> <span class="attribute-name">charset</span>="<a class="attribute-value">windows-1251</a>"&gt;</span><span>
+<span id="line6"></span></span><span>&lt;/<span class="end-tag">head</span>&gt;</span><span>
+<span id="line7"></span></span><span>&lt;<span class="start-tag">body</span>&gt;</span><span>
+<span id="line8"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>Normal meta. Non-ASCII in comment before.</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line9"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>Test: ж</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line10"></span></span><span>&lt;<span class="start-tag">p</span>&gt;</span><span>If <span class="entity"><span>&amp;</span>#x0436;</span>, meta takes effect</span><span>&lt;/<span class="end-tag">p</span>&gt;</span><span>
+<span id="line11"></span></span><span>&lt;/<span class="end-tag">body</span>&gt;</span><span>
+<span id="line12"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before.html b/parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before.html
new file mode 100644
index 0000000000..148c6544a3
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<head>
+<link rel="match" href="references/non-ascii-in-comment-before-ref.html">
+<!-- -->
+<meta charset="windows-1251">
+</head>
+<body>
+<p>Normal meta. Non-ASCII in comment before.</p>
+<p>Test: </p>
+<p>If &#x0436;, meta takes effect</p>
+</body>
diff --git a/parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before.sjs b/parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before.sjs
new file mode 100644
index 0000000000..12b1919ff8
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/vs-non-ascii-in-comment-before.sjs
@@ -0,0 +1,16 @@
+var timer; // Place timer in global scope to avoid it getting GC'ed prematurely
+
+function handleRequest(request, response)
+{
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "text/html", false);
+ response.write('<!DOCTYPE html>\n<head>\n<link rel="match" href="references/non-ascii-in-comment-before-ref.html">\n<!-- \u00E6 -->\n');
+ response.bodyOutputStream.flush();
+ response.processAsync();
+ timer = Components.classes["@mozilla.org/timer;1"]
+ .createInstance(Components.interfaces.nsITimer);
+ timer.initWithCallback(function() {
+ response.write('<meta charset="windows-1251">\n</head>\n<body>\n<p>Normal meta. Non-ASCII in comment before.</p>\n<p>Test: \u00E6</p>\n<p>If &#x0436;, meta takes effect</p>\n</body>\n');
+ response.finish();
+ }, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+}
diff --git a/parser/htmlparser/tests/reftest/xml-1.xml b/parser/htmlparser/tests/reftest/xml-1.xml
new file mode 100644
index 0000000000..a6ac350ad3
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-1.xml
@@ -0,0 +1 @@
+<?xml version='1.0' encoding='windows-1251'?><root></root>
diff --git a/parser/htmlparser/tests/reftest/xml-ref.html b/parser/htmlparser/tests/reftest/xml-ref.html
new file mode 100644
index 0000000000..3bf58fb763
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-ref.html
@@ -0,0 +1,2 @@
+<html><meta charset="utf-8"><head><meta name="viewport" content="width=device-width"><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="pi">&lt;?xml version='1.0' encoding='windows-1251'?&gt;</span><span></span><span>&lt;<span class="start-tag">root</span>&gt;</span><span>ж</span><span>&lt;/<span class="end-tag">root</span>&gt;</span><span>
+<span id="line2"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/xml-trickle-1.sjs b/parser/htmlparser/tests/reftest/xml-trickle-1.sjs
new file mode 100644
index 0000000000..eaec0e37fc
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-trickle-1.sjs
@@ -0,0 +1,17 @@
+var timer; // Place timer in global scope to avoid it getting GC'ed prematurely
+
+function handleRequest(request, response)
+{
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "application/xml", false);
+ response.write("<");
+ response.bodyOutputStream.flush();
+ response.processAsync();
+ timer = Components.classes["@mozilla.org/timer;1"]
+ .createInstance(Components.interfaces.nsITimer);
+ timer.initWithCallback(function() {
+ response.write("?xml version='1.0' encoding='windows-1251'?><root>\u00E6</root>\n");
+ response.finish();
+ }, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+}
+
diff --git a/parser/htmlparser/tests/reftest/xml-trickle-2.sjs b/parser/htmlparser/tests/reftest/xml-trickle-2.sjs
new file mode 100644
index 0000000000..04c1354fa3
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-trickle-2.sjs
@@ -0,0 +1,17 @@
+var timer; // Place timer in global scope to avoid it getting GC'ed prematurely
+
+function handleRequest(request, response)
+{
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "application/xml", false);
+ response.write("<?");
+ response.bodyOutputStream.flush();
+ response.processAsync();
+ timer = Components.classes["@mozilla.org/timer;1"]
+ .createInstance(Components.interfaces.nsITimer);
+ timer.initWithCallback(function() {
+ response.write("xml version='1.0' encoding='windows-1251'?><root>\u00E6</root>\n");
+ response.finish();
+ }, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+}
+
diff --git a/parser/htmlparser/tests/reftest/xml-trickle-3.sjs b/parser/htmlparser/tests/reftest/xml-trickle-3.sjs
new file mode 100644
index 0000000000..e601f69038
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-trickle-3.sjs
@@ -0,0 +1,21 @@
+var timer; // Place timer in global scope to avoid it getting GC'ed prematurely
+
+function handleRequest(request, response)
+{
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "application/xml", false);
+ response.write("<?");
+ response.bodyOutputStream.flush();
+ response.processAsync();
+ timer = Components.classes["@mozilla.org/timer;1"]
+ .createInstance(Components.interfaces.nsITimer);
+ timer.initWithCallback(function() {
+ response.write("xml");
+ response.bodyOutputStream.flush();
+ timer.initWithCallback(function() {
+ response.write(" version='1.0' encoding='windows-1251'?><root>\u00E6</root>\n");
+ response.finish();
+ }, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+ }, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+}
+
diff --git a/parser/htmlparser/tests/reftest/xml-trickle-4.sjs b/parser/htmlparser/tests/reftest/xml-trickle-4.sjs
new file mode 100644
index 0000000000..0ac01d84da
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-trickle-4.sjs
@@ -0,0 +1,17 @@
+var timer; // Place timer in global scope to avoid it getting GC'ed prematurely
+
+function handleRequest(request, response)
+{
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "application/xml", false);
+ response.write("<");
+ response.bodyOutputStream.flush();
+ response.processAsync();
+ timer = Components.classes["@mozilla.org/timer;1"]
+ .createInstance(Components.interfaces.nsITimer);
+ timer.initWithCallback(function() {
+ response.write("?xml version='1.0'?><root>\u00D0\u00B6</root>\n");
+ response.finish();
+ }, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+}
+
diff --git a/parser/htmlparser/tests/reftest/xml-trickle-5.sjs b/parser/htmlparser/tests/reftest/xml-trickle-5.sjs
new file mode 100644
index 0000000000..815295ac30
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-trickle-5.sjs
@@ -0,0 +1,17 @@
+var timer; // Place timer in global scope to avoid it getting GC'ed prematurely
+
+function handleRequest(request, response)
+{
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "application/xml", false);
+ response.write("<?");
+ response.bodyOutputStream.flush();
+ response.processAsync();
+ timer = Components.classes["@mozilla.org/timer;1"]
+ .createInstance(Components.interfaces.nsITimer);
+ timer.initWithCallback(function() {
+ response.write("xml version='1.0'?><root>\u00D0\u00B6</root>\n");
+ response.finish();
+ }, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+}
+
diff --git a/parser/htmlparser/tests/reftest/xml-trickle-6.sjs b/parser/htmlparser/tests/reftest/xml-trickle-6.sjs
new file mode 100644
index 0000000000..9e96687d19
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-trickle-6.sjs
@@ -0,0 +1,21 @@
+var timer; // Place timer in global scope to avoid it getting GC'ed prematurely
+
+function handleRequest(request, response)
+{
+ response.setHeader("Cache-Control", "no-cache", false);
+ response.setHeader("Content-Type", "application/xml", false);
+ response.write("<?");
+ response.bodyOutputStream.flush();
+ response.processAsync();
+ timer = Components.classes["@mozilla.org/timer;1"]
+ .createInstance(Components.interfaces.nsITimer);
+ timer.initWithCallback(function() {
+ response.write("xml");
+ response.bodyOutputStream.flush();
+ timer.initWithCallback(function() {
+ response.write(" version='1.0'?><root>\u00D0\u00B6</root>\n");
+ response.finish();
+ }, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+ }, 10, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
+}
+
diff --git a/parser/htmlparser/tests/reftest/xml-utf-ref.html b/parser/htmlparser/tests/reftest/xml-utf-ref.html
new file mode 100644
index 0000000000..98a3100b24
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-utf-ref.html
@@ -0,0 +1,2 @@
+<html><meta charset="utf-8"><head><meta name="viewport" content="width=device-width"><title></title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span></span><span class="pi">&lt;?xml version='1.0'?&gt;</span><span></span><span>&lt;<span class="start-tag">root</span>&gt;</span><span>ж</span><span>&lt;/<span class="end-tag">root</span>&gt;</span><span>
+<span id="line2"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/xml-without-tags-ref.html b/parser/htmlparser/tests/reftest/xml-without-tags-ref.html
new file mode 100644
index 0000000000..d853e67634
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-without-tags-ref.html
@@ -0,0 +1,2 @@
+<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>xml-without-tags.xml</title><link rel="stylesheet" type="text/css" href="resource://content-accessible/viewsource.css"></head><body id="viewsource" class="highlight" style="tab-size: 4"><pre id="line1"><span>ill-formed
+<span id="line2"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/xml-without-tags.xml b/parser/htmlparser/tests/reftest/xml-without-tags.xml
new file mode 100644
index 0000000000..ddc2f2135d
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/xml-without-tags.xml
@@ -0,0 +1 @@
+ill-formed