diff options
Diffstat (limited to 'testing/web-platform/tests/dom/ranges/Range-in-shadow-after-the-shadow-removed.html')
-rw-r--r-- | testing/web-platform/tests/dom/ranges/Range-in-shadow-after-the-shadow-removed.html | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/ranges/Range-in-shadow-after-the-shadow-removed.html b/testing/web-platform/tests/dom/ranges/Range-in-shadow-after-the-shadow-removed.html new file mode 100644 index 0000000000..54ea8aabea --- /dev/null +++ b/testing/web-platform/tests/dom/ranges/Range-in-shadow-after-the-shadow-removed.html @@ -0,0 +1,47 @@ +<!doctype html> +<html> +<head> +<meta charset="utf-8"> +<meta name="variant" content="?mode=closed"> +<meta name="variant" content="?mode=open"> +<title>Range in shadow after removing the shadow</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> +"use strict"; + +addEventListener("load", () => { + const mode = (new URLSearchParams(document.location.search)).get("mode"); + test(() => { + const host = document.createElement("div"); + host.id = "host"; + const root = host.attachShadow({mode}); + root.innerHTML = '<div id="in-shadow">ABC</div>'; + document.body.appendChild(host); + const range = document.createRange(); + range.setStart(root.firstChild, 1); + host.remove(); + assert_equals(range.startContainer, root.firstChild, "startContainer should not be changed"); + assert_equals(range.startOffset, 1, "startOffset should not be changed"); + }, "Range in shadow should stay in the shadow after the host is removed"); + + test(() => { + const wrapper = document.createElement("div"); + wrapper.id = "wrapper"; + const host = document.createElement("div"); + host.id = "host"; + const root = host.attachShadow({mode}); + root.innerHTML = '<div id="in-shadow">ABC</div>'; + wrapper.appendChild(host); + document.body.appendChild(wrapper); + const range = document.createRange(); + range.setStart(root.firstChild, 1); + wrapper.remove(); + assert_equals(range.startContainer, root.firstChild, "startContainer should not be changed"); + assert_equals(range.startOffset, 1, "startOffset should not be changed"); + }, "Range in shadow should stay in the shadow after the host parent is removed"); +}, {once: true}); +</script> +</head> +<body></body> +</html> |