diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/dom/nodes/Element-insertAdjacentElement.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/Element-insertAdjacentElement.html')
-rw-r--r-- | testing/web-platform/tests/dom/nodes/Element-insertAdjacentElement.html | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/Element-insertAdjacentElement.html b/testing/web-platform/tests/dom/nodes/Element-insertAdjacentElement.html new file mode 100644 index 0000000000..9eafee6a76 --- /dev/null +++ b/testing/web-platform/tests/dom/nodes/Element-insertAdjacentElement.html @@ -0,0 +1,91 @@ +<!doctype html> +<meta charset=utf-8> +<title></title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> + +<div id="target"></div> +<div id="parent"><span id=target2></span></div> +<div id="log" style="visibility:visible"></div> +<span id="test1"></span> +<span id="test2"></span> +<span id="test3"></span> +<span id="test4"></span> +<script> +var target = document.getElementById("target"); +var target2 = document.getElementById("target2"); + +test(function() { + assert_throws_dom("SyntaxError", function() { + target.insertAdjacentElement("test", document.getElementById("test1")) + }); + + assert_throws_dom("SyntaxError", function() { + target2.insertAdjacentElement("test", document.getElementById("test1")) + }); +}, "Inserting to an invalid location should cause a Syntax Error exception") + +test(function() { + var el = target.insertAdjacentElement("beforebegin", document.getElementById("test1")); + assert_equals(target.previousSibling.id, "test1"); + assert_equals(el.id, "test1"); + + el = target2.insertAdjacentElement("beforebegin", document.getElementById("test1")); + assert_equals(target2.previousSibling.id, "test1"); + assert_equals(el.id, "test1"); +}, "Inserted element should be target element's previous sibling for 'beforebegin' case") + +test(function() { + var el = target.insertAdjacentElement("afterbegin", document.getElementById("test2")); + assert_equals(target.firstChild.id, "test2"); + assert_equals(el.id, "test2"); + + el = target2.insertAdjacentElement("afterbegin", document.getElementById("test2")); + assert_equals(target2.firstChild.id, "test2"); + assert_equals(el.id, "test2"); +}, "Inserted element should be target element's first child for 'afterbegin' case") + +test(function() { + var el = target.insertAdjacentElement("beforeend", document.getElementById("test3")); + assert_equals(target.lastChild.id, "test3"); + assert_equals(el.id, "test3"); + + el = target2.insertAdjacentElement("beforeend", document.getElementById("test3")); + assert_equals(target2.lastChild.id, "test3"); + assert_equals(el.id, "test3"); +}, "Inserted element should be target element's last child for 'beforeend' case") + +test(function() { + var el = target.insertAdjacentElement("afterend", document.getElementById("test4")); + assert_equals(target.nextSibling.id, "test4"); + assert_equals(el.id, "test4"); + + el = target2.insertAdjacentElement("afterend", document.getElementById("test4")); + assert_equals(target2.nextSibling.id, "test4"); + assert_equals(el.id, "test4"); +}, "Inserted element should be target element's next sibling for 'afterend' case") + +test(function() { + var docElement = document.documentElement; + docElement.style.visibility="hidden"; + + assert_throws_dom("HierarchyRequestError", function() { + var el = docElement.insertAdjacentElement("beforebegin", document.getElementById("test1")); + assert_equals(el, null); + }); + + var el = docElement.insertAdjacentElement("afterbegin", document.getElementById("test2")); + assert_equals(docElement.firstChild.id, "test2"); + assert_equals(el.id, "test2"); + + el = docElement.insertAdjacentElement("beforeend", document.getElementById("test3")); + assert_equals(docElement.lastChild.id, "test3"); + assert_equals(el.id, "test3"); + + assert_throws_dom("HierarchyRequestError", function() { + var el = docElement.insertAdjacentElement("afterend", document.getElementById("test4")); + assert_equals(el, null); + }); +}, "Adding more than one child to document should cause a HierarchyRequestError exception") + +</script> |