diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /accessible/tests/mochitest/focus | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'accessible/tests/mochitest/focus')
-rw-r--r-- | accessible/tests/mochitest/focus/a11y.ini | 9 | ||||
-rw-r--r-- | accessible/tests/mochitest/focus/test_focus_radio.xhtml | 84 | ||||
-rw-r--r-- | accessible/tests/mochitest/focus/test_focusedChild.html | 81 | ||||
-rw-r--r-- | accessible/tests/mochitest/focus/test_takeFocus.html | 109 | ||||
-rw-r--r-- | accessible/tests/mochitest/focus/test_takeFocus.xhtml | 104 |
5 files changed, 387 insertions, 0 deletions
diff --git a/accessible/tests/mochitest/focus/a11y.ini b/accessible/tests/mochitest/focus/a11y.ini new file mode 100644 index 0000000000..905d38882c --- /dev/null +++ b/accessible/tests/mochitest/focus/a11y.ini @@ -0,0 +1,9 @@ +[DEFAULT] +support-files = + !/accessible/tests/mochitest/*.js + +[test_focus_radio.xhtml] +[test_focusedChild.html] +skip-if = (os == 'win' && os_version != '6.1') # bug 845134 +[test_takeFocus.html] +[test_takeFocus.xhtml] diff --git a/accessible/tests/mochitest/focus/test_focus_radio.xhtml b/accessible/tests/mochitest/focus/test_focus_radio.xhtml new file mode 100644 index 0000000000..717d9976b6 --- /dev/null +++ b/accessible/tests/mochitest/focus/test_focus_radio.xhtml @@ -0,0 +1,84 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" + type="text/css"?> + +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + title="Tests for Accessible TakeFocus on Radio Elements"> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> + <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> + + <script type="application/javascript" + src="../common.js" /> + <script type="application/javascript" + src="../role.js" /> + <script type="application/javascript" + src="../states.js" /> + <script type="application/javascript" + src="../promisified-events.js" /> + + <script type="application/javascript"> + <![CDATA[ + async function doTests() { + let radio1 = getAccessible("radio1"); + let focused = waitForEvent(EVENT_FOCUS, radio1); + radio1.takeFocus(); + await focused; + // radio1 wasn't selected. Ensure that takeFocus didn't change that. + testStates(radio1, STATE_FOCUSED, 0, STATE_CHECKED); + + // Test focusing another radio in the group while the group is still + // focused. + let radio2 = getAccessible("radio2"); + focused = waitForEvent(EVENT_FOCUS, radio2); + radio2.takeFocus(); + await focused; + testStates(radio2, STATE_FOCUSED | STATE_CHECKED); + + let groupEl = document.getElementById("radiogroup"); + // Selecting an item also focuses it. + focused = waitForEvent(EVENT_FOCUS, radio1); + groupEl.value = "1"; + await focused; + testStates(radio1, STATE_FOCUSED | STATE_CHECKED); + + // If an item is already selected but not focused, selecting it again + // focuses it. + focused = waitForEvent(EVENT_FOCUS, radio2); + radio2.takeFocus(); + await focused; + testStates(radio2, STATE_FOCUSED, 0, STATE_CHECKED); + // radio1 is selected but not focused. + // Select radio1 again, which should focus it. + focused = waitForEvent(EVENT_FOCUS, radio1); + groupEl.value = "1"; + await focused; + testStates(radio1, STATE_FOCUSED | STATE_CHECKED); + + SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTests); + ]]> + </script> + + <hbox flex="1" style="overflow: auto;"> + <body xmlns="http://www.w3.org/1999/xhtml"> + <p id="display"></p> + <div id="content" style="display: none"></div> + <pre id="test"> + </pre> + </body> + + <vbox flex="1"> + <radiogroup id="radiogroup" value="2"> + <radio id="radio1" value="1"/> + <radio id="radio2" value="2"/> + </radiogroup> + + <vbox id="eventdump"/> + </vbox> + </hbox> +</window> diff --git a/accessible/tests/mochitest/focus/test_focusedChild.html b/accessible/tests/mochitest/focus/test_focusedChild.html new file mode 100644 index 0000000000..d12e229b48 --- /dev/null +++ b/accessible/tests/mochitest/focus/test_focusedChild.html @@ -0,0 +1,81 @@ +<html> + +<head> + <title>nsIAccessible::focusedChild testing</title> + + <link rel="stylesheet" type="text/css" + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + + <script type="application/javascript" + src="../common.js"></script> + <script type="application/javascript" + src="../role.js"></script> + <script type="application/javascript" + src="../states.js"></script> + <script type="application/javascript" + src="../events.js"></script> + + <script type="application/javascript"> + function openWnd() { + this.eventSeq = [ new invokerChecker(EVENT_FOCUS, + getDialogAccessible, + this) ]; + + this.invoke = function openWnd_invoke() { + this.dialog = window.browsingContext.topChromeWindow + .openDialog("about:mozilla", + "AboutMozilla", + "chrome,width=600,height=600"); + }; + + this.finalCheck = function openWnd_finalCheck() { + var app = getApplicationAccessible(); + is(app.focusedChild, getDialogAccessible(this), + "Wrong focused child"); + + this.dialog.close(); + }; + + this.getID = function openWnd_getID() { + return "focusedChild for application accessible"; + }; + + function getDialogAccessible(aInvoker) { + return getAccessible(aInvoker.dialog.document); + } + } + + gA11yEventDumpToConsole = true; + var gQueue = null; + + function doTest() { + enableLogging("focus,doclifecycle"); + gQueue = new eventQueue(); + + gQueue.push(new openWnd()); + + gQueue.onFinish = function() { disableLogging(); }; + gQueue.invoke(); // Will call SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTest); + </script> +</head> + +<body> + + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=677467" + title="focusedChild crashes on application accessible"> + Mozilla Bug 677467 + </a> + <p id="display"></p> + <div id="content" style="display: none"></div> + <pre id="test"> + </pre> + +</body> +</html> diff --git a/accessible/tests/mochitest/focus/test_takeFocus.html b/accessible/tests/mochitest/focus/test_takeFocus.html new file mode 100644 index 0000000000..752ed66b36 --- /dev/null +++ b/accessible/tests/mochitest/focus/test_takeFocus.html @@ -0,0 +1,109 @@ +<html> + +<head> + <title>nsIAccessible::takeFocus testing</title> + + <link rel="stylesheet" type="text/css" + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + + <script type="application/javascript" + src="../common.js"></script> + <script type="application/javascript" + src="../role.js"></script> + <script type="application/javascript" + src="../states.js"></script> + <script type="application/javascript" + src="../events.js"></script> + + <script type="application/javascript"> + // ////////////////////////////////////////////////////////////////////////// + // Invokers + + function takeFocusInvoker(aID) { + this.accessible = getAccessible(aID); + + this.eventSeq = [ new focusChecker(this.accessible) ]; + + this.invoke = function takeFocusInvoker_invoke() { + this.accessible.takeFocus(); + }; + + this.getID = function takeFocusInvoker_getID() { + return "takeFocus for " + prettyName(aID); + }; + } + + // ////////////////////////////////////////////////////////////////////////// + // Test + + // gA11yEventDumpToConsole = true; // debug stuff + + var gQueue = null; + function doTest() { + disableLogging(); // from test_focusedChild + gQueue = new eventQueue(); + + gQueue.push(new takeFocusInvoker("aria-link")); + gQueue.push(new takeFocusInvoker("aria-link2")); + gQueue.push(new takeFocusInvoker("link")); + gQueue.push(new takeFocusInvoker("item2")); + gQueue.push(new takeFocusInvoker(document)); + gQueue.push(new takeFocusInvoker("lb_item2")); + gQueue.push(new takeFocusInvoker(document)); + gQueue.push(new takeFocusInvoker("lb_item3.2")); + gQueue.push(new takeFocusInvoker(document)); + gQueue.push(new takeFocusInvoker("lb_item3.1")); + + gQueue.invoke(); // Will call SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTest); + </script> +</head> + +<body> + + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=429547" + title="Support aria-activedescendant usage in nsIAccesible::TakeFocus()"> + Mozilla Bug 429547 + </a> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=452710" + title="nsIAccessible::takeFocus testing"> + Mozilla Bug 452710 + </a> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=706067" + title="Make takeFocus work on widget items"> + Mozilla Bug 706067 + </a> + <p id="display"></p> + <div id="content" style="display: none"></div> + <pre id="test"> + </pre> + + <span id="aria-link" role="link" tabindex="0">link</span> + <span id="aria-link2" role="link" tabindex="0">link</span> + + <a id="link" href="">link</a> + + <div role="listbox" aria-activedescendant="item1" id="container" tabindex="1"> + <div role="option" id="item1">item1</div> + <div role="option" id="item2">item2</div> + <div role="option" id="item3">item3</div> + </div> + + <select id="listbox" size="5"> + <option id="lb_item1">item1</option> + <option id="lb_item2">item2</option> + <optgroup> + <option id="lb_item3.1">item 3.1</option> + <option id="lb_item3.2">item 3.2</option> + </optgroup> + </select> +</body> +</html> diff --git a/accessible/tests/mochitest/focus/test_takeFocus.xhtml b/accessible/tests/mochitest/focus/test_takeFocus.xhtml new file mode 100644 index 0000000000..127f47d067 --- /dev/null +++ b/accessible/tests/mochitest/focus/test_takeFocus.xhtml @@ -0,0 +1,104 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" + type="text/css"?> + +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + title="Accessible focus testing"> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> + <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> + + <script type="application/javascript" + src="../common.js" /> + <script type="application/javascript" + src="../role.js" /> + <script type="application/javascript" + src="../states.js" /> + <script type="application/javascript" + src="../events.js" /> + + <script type="application/javascript" + src="../treeview.js" /> + + <script type="application/javascript"> + <![CDATA[ + //////////////////////////////////////////////////////////////////////////// + // Invokers + + function takeFocusInvoker(aID, aArgConverterFunc) + { + this.targetFunc = aArgConverterFunc ? aArgConverterFunc : getAccessible; + + this.eventSeq = [ new focusChecker(this.targetFunc, aID) ]; + + this.invoke = function takeFocusInvoker_invoke() + { + this.targetFunc.call(null, aID).takeFocus(); + } + + this.getID = function takeFocusInvoker_getID() + { + return "takeFocus for " + prettyName(aID); + } + } + + function getLastChild(aID) + { + return getAccessible(aID).lastChild; + } + + //////////////////////////////////////////////////////////////////////////// + // Tests + + //gA11yEventDumpID = "eventdump"; // debug stuff + //gA11yEventDumpToConsole = true; // debug stuff + + var gQueue = null; + function doTests() + { + // Test focus events. + gQueue = new eventQueue(); + + gQueue.push(new takeFocusInvoker("tree", getLastChild)); + gQueue.push(new takeFocusInvoker("listitem2")); + + gQueue.invoke(); // Will call SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yXULTreeLoadEvent(doTests, "tree", new nsTableTreeView(5)); + ]]> + </script> + + <hbox flex="1" style="overflow: auto;"> + <body xmlns="http://www.w3.org/1999/xhtml"> + <a target="_blank" + href="https://bugzilla.mozilla.org/show_bug.cgi?id=706067" + title="Make takeFocus work on widget items"> + Mozilla Bug 706067 + </a> + <p id="display"></p> + <div id="content" style="display: none"></div> + <pre id="test"> + </pre> + </body> + + <vbox flex="1"> + <tree id="tree" flex="1"> + <treecols> + <treecol id="col1" flex="1" primary="true" label="column"/> + <treecol id="col2" flex="1" label="column 2"/> + </treecols> + <treechildren id="treechildren"/> + </tree> + + <richlistbox id="listbox"> + <richlistitem id="listitem1"><label value="item1"/></richlistitem> + <richlistitem id="listitem2"><label value="item2"/></richlistitem> + </richlistbox> + + <vbox id="eventdump"/> + </vbox> + </hbox> +</window> |