diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/dom/nodes/Element-getElementsByClassName.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/Element-getElementsByClassName.html')
-rw-r--r-- | testing/web-platform/tests/dom/nodes/Element-getElementsByClassName.html | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/Element-getElementsByClassName.html b/testing/web-platform/tests/dom/nodes/Element-getElementsByClassName.html new file mode 100644 index 0000000000..bc87b05d25 --- /dev/null +++ b/testing/web-platform/tests/dom/nodes/Element-getElementsByClassName.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<title>Element.getElementsByClassName</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +test(function() { + var a = document.createElement("a"), b = document.createElement("b") + b.className = "foo" + a.appendChild(b) + var list = a.getElementsByClassName("foo") + assert_array_equals(list, [b]) + var secondList = a.getElementsByClassName("foo") + assert_true(list === secondList || list !== secondList, "Caching is allowed.") +}, "getElementsByClassName should work on disconnected subtrees.") + +test(function() { + var list = document.getElementsByClassName("foo") + assert_false(list instanceof NodeList, "NodeList") + assert_true(list instanceof HTMLCollection, "HTMLCollection") +}, "Interface should be correct.") + +test(function() { + var a = document.createElement("a"); + var b = document.createElement("b"); + var c = document.createElement("c"); + b.className = "foo"; + document.body.appendChild(a); + this.add_cleanup(function() {document.body.removeChild(a)}); + a.appendChild(b); + + var l = a.getElementsByClassName("foo"); + assert_true(l instanceof HTMLCollection); + assert_equals(l.length, 1); + + c.className = "foo"; + a.appendChild(c); + assert_equals(l.length, 2); + + a.removeChild(c); + assert_equals(l.length, 1); +}, "getElementsByClassName() should be a live collection"); +</script> |