LibWeb/Tests: Port HTMLCollection [[SameObject]] test to a text test

This test was written before we had the facility to write text tests -
port this test to a text test so that we test against it in CI.
This commit is contained in:
Shannon Booth 2023-08-21 21:47:44 +12:00 committed by Andreas Kling
parent e300da4db4
commit 6cee028ecc
Notes: sideshowbarker 2024-07-16 22:34:39 +09:00
3 changed files with 46 additions and 52 deletions

View file

@ -1,52 +0,0 @@
<html>
<style>
.ball {
border-radius: 9999px;
width: 40px;
height: 40px;
display: inline-block;
}
.pass {
background: green;
}
.fail {
background: red;
}
</style>
<p>This test verifies that various HTMLCollection properties have <b>[SameObject]</b> behavior.</p>
<p>You should see a bunch of green balls below this line.</p>
<div id="out"></div>
<form><table><thead><tr><td></td></tr></thead></table></form>
<script>
let out = document.querySelector("#out")
function test(expr) {
let a = eval(expr)
let b = eval(expr)
let e = document.createElement("div")
e.className = "ball " + ((a === b) ? "pass" : "fail")
out.appendChild(e)
}
let table = document.querySelector("table")
let tr = document.querySelector("tr")
let form = document.querySelector("form")
let thead = document.querySelector("thead")
test("table.tBodies")
test("table.rows")
test("thead.rows")
test("tr.cells")
test("form.elements")
test("document.applets")
test("document.anchors")
test("document.images")
test("document.embeds")
test("document.plugins")
test("document.links")
test("document.forms")
test("document.scripts")
</script>
</html>

View file

@ -0,0 +1,13 @@
table.tBodies pass
table.rows pass
thead.rows pass
tr.cells pass
form.elements pass
document.applets pass
document.anchors pass
document.images pass
document.embeds pass
document.plugins pass
document.links pass
document.forms pass
document.scripts pass

View file

@ -0,0 +1,33 @@
<html>
<form><table><thead><tr><td></td></tr></thead></table></form>
<script src="include.js"></script>
<script>
test(() => {
function testElement(expr) {
let a = eval(expr);
let b = eval(expr);
println(`${expr} ${(a === b) ? "pass" : "fail"}`);
}
let table = document.querySelector("table")
let tr = document.querySelector("tr")
let form = document.querySelector("form")
let thead = document.querySelector("thead")
testElement("table.tBodies")
testElement("table.rows")
testElement("thead.rows")
testElement("tr.cells")
testElement("form.elements")
testElement("document.applets")
testElement("document.anchors")
testElement("document.images")
testElement("document.embeds")
testElement("document.plugins")
testElement("document.links")
testElement("document.forms")
testElement("document.scripts")
});
</script>
</html>