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-autofocus.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-autofocus.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus.html b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus.html new file mode 100644 index 0000000000..149a53eacf --- /dev/null +++ b/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus.html @@ -0,0 +1,65 @@ +<!DOCTYPE html> +<html> +<head> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="./resources/common.js"></script> +<script> +promise_test(() => { + return waitUntilLoadedAndAutofocused().then(() => { + assert_equals(document.activeElement, document.getElementById("outer-button")); + + var dialog = document.getElementById('dialog'); + dialog.showModal(); + + autofocusButton = document.getElementById('autofocus-button'); + assert_equals(document.activeElement, autofocusButton); + + anotherButton = document.getElementById('another-button'); + anotherButton.focus(); + assert_equals(document.activeElement, anotherButton); + + // Test that recreating layout does not give focus back to a previously autofocused element. + autofocusButton.style.display = 'none'; + document.body.offsetHeight; + autofocusButton.style.display = 'block'; + document.body.offsetHeight; + assert_equals(document.activeElement, anotherButton); + + // Test that reinserting does not give focus back to a previously autofocused element. + var parentNode = autofocusButton.parentNode; + parentNode.removeChild(autofocusButton); + document.body.offsetHeight; + parentNode.appendChild(autofocusButton); + document.body.offsetHeight; + assert_equals(document.activeElement, anotherButton); + + dialog.close(); + // Test that dialog focusing steps run when a dialog is reopened. + dialog.showModal(); + assert_equals(document.activeElement, autofocusButton); + dialog.close(); + }); +}, "autofocus when a modal dialog is opened"); +</script> +</head> +<body> +<button id="outer-button" autofocus></button> +<dialog id="dialog"> + <button></button> + <!-- Unfocusable elements with [autofocus] should be ignored. --> + <input autofocus disabled> + <textarea autofocus hidden></textarea> + <dialog> + <button autofocus></button> + </dialog> + <div> + <span> + <button id="autofocus-button" autofocus></button> + </span> + </div> + <button id="another-button" autofocus></button> +</dialog> + +</body> +</html> |