summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/syntax/parsing/ambiguous-ampersand.html
blob: e6d5a822159755ede5394ff8df2bbc61f716dbfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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&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></div>
<script>
var markup = "<div><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></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&copy=1&noti=n&not=in&notin=%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>