Base: Add a test for [SameObject] behavior in LibWeb

This commit is contained in:
Andreas Kling 2022-11-24 19:16:58 +01:00
parent 2157745093
commit c884aa3f25
Notes: sideshowbarker 2024-07-17 04:07:58 +09:00

View file

@ -0,0 +1,52 @@
<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>