فهرست منبع

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

Andreas Kling 2 سال پیش
والد
کامیت
c884aa3f25
1فایلهای تغییر یافته به همراه52 افزوده شده و 0 حذف شده
  1. 52 0
      Base/res/html/tests/sameobject-behavior-for-htmlcollection-properties.html

+ 52 - 0
Base/res/html/tests/sameobject-behavior-for-htmlcollection-properties.html

@@ -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>