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/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-double-nested.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/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-double-nested.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-double-nested.html | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-double-nested.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-double-nested.html new file mode 100644 index 0000000000..2cd63eb796 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-focus-shadow-double-nested.html @@ -0,0 +1,53 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>dialog focusing delegation: with two nested shadow trees</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<body> + +<dialog> + <template class="turn-into-shadow-tree delegates-focus"> + <button disabled>Non-focusable</button> + <template class="turn-into-shadow-tree delegates-focus"> + <button tabindex="-1">Focusable</button> + <button tabindex="-1" autofocus>Focusable</button> + <button tabindex="-1">Focusable</button> + </template> + <button tabindex="-1">Focusable</button> + </template> + <button tabindex="-1">Focusable</button> +</dialog> + +<script> +function turnIntoShadowTree(template) { + for (const subTemplate of template.content.querySelectorAll(".turn-into-shadow-tree")) { + turnIntoShadowTree(subTemplate); + } + + const div = document.createElement("div"); + div.attachShadow({ mode: "open", delegatesFocus: template.classList.contains("delegates-focus") }); + div.shadowRoot.append(template.content); + template.replaceWith(div); +} + +for (const template of document.querySelectorAll(".turn-into-shadow-tree")) { + turnIntoShadowTree(template); +} + +for (const method of ["show", "showModal"]) { + test(t => { + const dialog = document.querySelector("dialog"); + dialog[method](); + t.add_cleanup(() => dialog.close()); + + const shadowHostOuter = dialog.querySelector("div"); + assert_equals(document.activeElement, shadowHostOuter, "document.activeElement"); + + const shadowHostInner = shadowHostOuter.shadowRoot.querySelector("div"); + assert_equals(shadowHostOuter.shadowRoot.activeElement, shadowHostInner, "shadowHostOuter.shadowRoot.activeElement"); + + const button = shadowHostInner.shadowRoot.querySelector("[autofocus]"); + assert_equals(shadowHostInner.shadowRoot.activeElement, button, "shadowHostInner.shadowRoot.activeElement"); + }, `${method}()`); +} +</script> |