Conform ampersand error reporting to HTML spec.
Created by inlining the `AMBIGUOUS_AMPERSAND` state in
https://github.com/validator/htmlparser/pull/30 back into the states
that transitioned to `AMBIGUOUS_AMPERSAND` in that PR by
Michael(tm) Smith.
Differential Revision: https://phabricator.services.mozilla.com/D81992
bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1153920
gecko-commit: f8b2924ea4a38468908d5f243afb1df7a1f99014
gecko-reviewers: smaug
diff --git a/html/syntax/parsing/ambiguous-ampersand.html b/html/syntax/parsing/ambiguous-ampersand.html
new file mode 100644
index 0000000..e6d5a82
--- /dev/null
+++ b/html/syntax/parsing/ambiguous-ampersand.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>Ambiguous ampersand</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div><a href='?a=b&c=d&a0b=c©=1¬i=n¬=in¬in=∉¬&;& &'>Link</a><p>Text: ?a=b&c=d&a0b=c©=1¬i=n¬=in¬in=∉¬&;& &</p></div>
+<script>
+var markup = "<div><a href='?a=b&c=d&a0b=c©=1¬i=n¬=in¬in=∉¬&;& &'>Link</a><p>Text: ?a=b&c=d&a0b=c©=1¬i=n¬=in¬in=∉¬&;& &</p></div>";
+
+for (var i = 0; i < markup.length; ++i) {
+ document.write(markup.charAt(i));
+}
+</script>
+
+<script>
+function checkDiv(div, provenance) {
+ test(function() {
+ assert_equals(div.childNodes.length, 2, "Number of elements " + provenance);
+ let a = div.firstChild;
+ let href = a.href;
+ let question = href.indexOf('?');
+ href = href.substring(question);
+ assert_equals(href, "?a=b&c=d&a0b=c©=1¬i=n¬=in¬in=%E2%88%89%C2%AC&;&%20&", "attribute " + provenance);
+ let p = a.nextSibling;
+ assert_equals(p.textContent, "Text: ?a=b&c=d&a0b=c©=1¬i=n¬=in¬in=∉¬&;& &", "text " + provenance)
+ }, "Check div structure: " + provenance);
+}
+
+
+let divs = document.getElementsByTagName("div");
+test(function() {
+ assert_equals(divs.length, 2);
+}, "Check number of divs");
+checkDiv(divs[0], "network");
+checkDiv(divs[1], "document.write");
+</script>