diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/tests/mochitest/chrome/focus_dialog.xhtml | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/tests/mochitest/chrome/focus_dialog.xhtml')
-rw-r--r-- | dom/tests/mochitest/chrome/focus_dialog.xhtml | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dom/tests/mochitest/chrome/focus_dialog.xhtml b/dom/tests/mochitest/chrome/focus_dialog.xhtml new file mode 100644 index 0000000000..24eda7ad1b --- /dev/null +++ b/dom/tests/mochitest/chrome/focus_dialog.xhtml @@ -0,0 +1,71 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> + +<window id="other-document" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> +<dialog buttons="accept"> + +<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> + +<button id="button-1" label="Something"/> +<button id="button-2" label="Something else"/> + +<script> +<![CDATA[ + +window.is = window.arguments[0].is; +window.isnot = window.arguments[0].isnot; +window.ok = window.arguments[0].ok; +window.SimpleTest = window.arguments[0].SimpleTest; + +(async function() { + await new Promise(resolve => { + window.onload = resolve; + }); + + await new Promise(resolve => SimpleTest.waitForFocus(resolve, window)); + + let dialog = document.querySelector("dialog"); + let shadow = dialog.shadowRoot; + + let button = document.getElementById("button-1"); + let button2 = document.getElementById("button-2"); + let forwardSequence = []; + + button.focus(); + + is(document.activeElement, button, "Should've focused the button"); + forwardSequence.push(button); + + synthesizeKey("KEY_Tab"); + + is(document.activeElement, button2, "Should've moved to the second button"); + forwardSequence.push(button2); + + synthesizeKey("KEY_Tab"); + + isnot(shadow.activeElement, null, "Should've focused the shadow root button"); + is(document.activeElement, dialog, "document.focusedElement should be the dialog because retargeting"); + forwardSequence.push(shadow.activeElement); + + synthesizeKey("KEY_Tab"); + + is(document.activeElement, button, "Should properly wrap around going forward"); + + while (forwardSequence.length) { + synthesizeKey("KEY_Tab", { shiftKey: true }); + is( + shadow.activeElement || document.activeElement, + forwardSequence.pop(), + "Should travel backwards correctly: " + forwardSequence.length + ); + } + + window.close(); + SimpleTest.finish(); +}()); + +]]> +</script> +</dialog> +</window> |