Tests: Add XHTML tests for CDATA, PIs and Comment nodes in the DOM

This commit is contained in:
Andrew Kaster 2025-07-18 13:21:33 -06:00 committed by Ali Mohammad Pur
commit 50422eb563
Notes: github-actions[bot] 2025-07-19 12:57:25 +00:00
10 changed files with 132 additions and 0 deletions

View file

@ -0,0 +1,4 @@
elem.childNodes.length: 5
child node 0: [object CDATASection], 4
child node 1 [object ProcessingInstruction], 7
child node 2: [object Comment], 8

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass xml-stylesheet processing instruction in doctype internal subset

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Fail
Fail XML: Comment in doctype internal subset

View file

@ -0,0 +1,16 @@
Harness status: OK
Found 11 tests
11 Pass
Pass Node.lookupPrefix
Pass Node.lookupPrefix 1
Pass Node.lookupPrefix 2
Pass Node.lookupPrefix 3
Pass Node.lookupPrefix 4
Pass Node.lookupPrefix 5
Pass Node.lookupPrefix 6
Pass Node.lookupPrefix 7
Pass Node.lookupPrefix 8
Pass Node.lookupPrefix 9
Pass Node.lookupPrefix 10

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass XML: Processing instruction in doctype internal subset

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<body>
<div id="elem"><![CDATA[beep]]><?test test?><!-- I am a comment --><p>Hello</p><p>World</p></div>
<script src="../include.js"></script>
<script>
test(() => {
const elem = document.getElementById("elem");
println(`elem.childNodes.length: ${elem.childNodes.length}`);
println(`child node 0: ${elem.childNodes[0].toString()}, ${elem.childNodes[0].nodeType}`);
println(`child node 1 ${elem.childNodes[1].toString()}, ${elem.childNodes[1].nodeType}`);
println(`child node 2: ${elem.childNodes[2].toString()}, ${elem.childNodes[2].nodeType}`);
});
</script>
</body>
</html>

View file

@ -0,0 +1,17 @@
<!DOCTYPE html [<?xml-stylesheet href="data:text/css,html{z-index: 1}"?>]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>xml-stylesheet processing instruction in doctype internal subset</title>
<link rel="help" href="https://drafts.csswg.org/cssom/#prolog"/>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
promise_test(async () => {
await new Promise(resolve => window.onload = resolve);
assert_equals(getComputedStyle(document.documentElement).zIndex, "auto");
});
</script>
</body>
</html>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html [<!--x-->]><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML: Comment in doctype internal subset</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(() => {
assert_equals(document.documentElement.previousSibling, document.firstChild);
assert_equals(document.firstChild.nodeType, Node.DOCUMENT_TYPE_NODE);
});
</script>
</body>
</html>

View file

@ -0,0 +1,31 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:x="test">
<head>
<title>Node.lookupPrefix</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body xmlns:s="test">
<div id="log"/>
<x xmlns:t="test"><!--comment--><?test test?>TEST<x/></x>
<script>
function lookupPrefix(node, ns, prefix) {
test(function() {
assert_equals(node.lookupPrefix(ns), prefix)
})
}
var x = document.getElementsByTagName("x")[0];
lookupPrefix(document, "test", "x") // XXX add test for when there is no documentElement
lookupPrefix(document, null, null)
lookupPrefix(x, "http://www.w3.org/1999/xhtml", null)
lookupPrefix(x, "something", null)
lookupPrefix(x, null, null)
lookupPrefix(x, "test", "t")
lookupPrefix(x.parentNode, "test", "s")
lookupPrefix(x.firstChild, "test", "t")
lookupPrefix(x.childNodes[1], "test", "t")
lookupPrefix(x.childNodes[2], "test", "t")
lookupPrefix(x.lastChild, "test", "t")
x.parentNode.removeChild(x)
</script>
</body>
</html>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html [<?x y?>]><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML: Processing instruction in doctype internal subset</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(() => {
assert_equals(document.documentElement.previousSibling, document.firstChild);
assert_equals(document.firstChild.nodeType, Node.DOCUMENT_TYPE_NODE);
});
</script>
</body>
</html>