Bug 1733263 - P4: Promisify the select focus change test. r=Jamie

This will make it easier to work with in a later change.

Differential Revision: https://phabricator.services.mozilla.com/D130297
This commit is contained in:
Eitan Isaacson 2021-11-09 23:17:17 +00:00
Родитель c24895a970
Коммит c96fcc25b5
2 изменённых файлов: 68 добавлений и 22 удалений

Просмотреть файл

@ -12,7 +12,7 @@
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../events.js"></script>
src="../promisified-events.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
@ -24,7 +24,7 @@
var gQueue = null;
function doTests() {
async function doTests() {
// Bug 746534 - File causes crash or hang on OS X
if (MAC) {
todo(false, "Bug 746534 - test file causes crash or hang on OS X");
@ -32,48 +32,93 @@
return;
}
gQueue = new eventQueue();
let p = waitForEvent(EVENT_FOCUS, "orange");
// first item is focused until there's selection
gQueue.push(new synthFocus("list", new focusChecker("orange")));
getNode("list").focus();
await p;
p = waitForEvents({
expected: [[EVENT_SELECTION, "orange"]],
unexpected: [[EVENT_FOCUS]]
});
// item is selected and stays focused
gQueue.push(new synthDownKey("list", new nofocusChecker()));
synthesizeKey("VK_DOWN");
await p;
p = waitForEvent(EVENT_FOCUS, "apple");
// last selected item is focused
gQueue.push(new synthDownKey("list", new focusChecker("apple"), { shiftKey: true }));
synthesizeKey("VK_DOWN", { shiftKey: true });
await p;
p = waitForEvents({
expected: [[EVENT_FOCUS, "orange"]],
unexpected: [[EVENT_FOCUS, "apple"]]
});
// no focus event if nothing is changed
gQueue.push(new synthDownKey("list", new nofocusChecker("apple")));
synthesizeKey("VK_DOWN");
// current item is focused
gQueue.push(new synthUpKey("list", new focusChecker("orange"), { ctrlKey: true }));
synthesizeKey("VK_UP", { ctrlKey: true });
await p;
p = waitForEvent(EVENT_FOCUS, "emptylist");
// focus on empty list (no items to be focused)
gQueue.push(new synthTab("list", new focusChecker("emptylist")));
synthesizeKey("VK_TAB");
await p;
p = waitForEvent(EVENT_FOCUS, "orange");
// current item is focused
gQueue.push(new synthShiftTab("emptylist", new focusChecker("orange")));
synthesizeKey("VK_TAB", { shiftKey: true });
await p;
p = waitForEvent(EVENT_FOCUS, "combobox");
getNode("combobox").focus();
await p;
p = waitForEvents({
expected: [[EVENT_SELECTION, "cb_apple"]],
unexpected: [[EVENT_FOCUS]]
});
// collapsed combobox keeps a focus
gQueue.push(new synthFocus("combobox", new focusChecker("combobox")));
gQueue.push(new synthDownKey("combobox", new nofocusChecker("combobox")));
synthesizeKey("VK_DOWN");
await p;
p = waitForEvent(EVENT_FOCUS, "cb_apple");
// current selected item is focused when combobox is expanded
synthesizeKey("VK_DOWN", { altKey: true });
await p;
p = waitForEvent(EVENT_FOCUS, "cb_orange");
// selected item is focused for expanded combobox
gQueue.push(new synthOpenComboboxKey("combobox", new focusChecker("cb_apple")));
gQueue.push(new synthUpKey("combobox", new focusChecker("cb_orange")));
synthesizeKey("VK_UP");
await p;
p = waitForEvent(EVENT_FOCUS, "combobox");
// collapsed combobx keeps a focus
gQueue.push(new synthEscapeKey("combobox", new focusChecker("combobox")));
synthesizeKey("VK_ESCAPE");
await p;
// no focus events for unfocused list controls when current item is
// changed
gQueue.push(new synthFocus("emptylist"));
gQueue.push(new changeCurrentItem("list", "orange"));
gQueue.push(new changeCurrentItem("combobox", "cb_apple"));
p = waitForEvent(EVENT_FOCUS, "emptylist");
getNode("emptylist").focus();
await p;
gQueue.invoke(); // Will call SimpleTest.finish();
p = waitForEvents({
expected: [[EVENT_SELECTION, "orange"]],
unexpected: [[EVENT_FOCUS]]
});
getNode("list").selectedIndex = getNode("orange").index;
await p;
p = waitForEvents({
expected: [[EVENT_SELECTION, "cb_apple"]],
unexpected: [[EVENT_FOCUS]]
});
getNode("cb_apple").selected = true;
await p;
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();

Просмотреть файл

@ -11,7 +11,7 @@
/* exported EVENT_ANNOUNCEMENT, EVENT_REORDER, EVENT_SCROLLING,
EVENT_SCROLLING_END, EVENT_SHOW, EVENT_TEXT_INSERTED,
EVENT_TEXT_REMOVED, EVENT_DOCUMENT_LOAD_COMPLETE, EVENT_HIDE,
EVENT_TEXT_ATTRIBUTE_CHANGED, EVENT_TEXT_CARET_MOVED,
EVENT_TEXT_ATTRIBUTE_CHANGED, EVENT_TEXT_CARET_MOVED, EVENT_SELECTION,
EVENT_DESCRIPTION_CHANGE, EVENT_NAME_CHANGE, EVENT_STATE_CHANGE,
EVENT_VALUE_CHANGE, EVENT_TEXT_VALUE_CHANGE, EVENT_FOCUS,
EVENT_DOCUMENT_RELOAD, EVENT_VIRTUALCURSOR_CHANGED, EVENT_ALERT,
@ -26,6 +26,7 @@ const EVENT_HIDE = nsIAccessibleEvent.EVENT_HIDE;
const EVENT_REORDER = nsIAccessibleEvent.EVENT_REORDER;
const EVENT_SCROLLING = nsIAccessibleEvent.EVENT_SCROLLING;
const EVENT_SCROLLING_END = nsIAccessibleEvent.EVENT_SCROLLING_END;
const EVENT_SELECTION = nsIAccessibleEvent.EVENT_SELECTION;
const EVENT_SHOW = nsIAccessibleEvent.EVENT_SHOW;
const EVENT_STATE_CHANGE = nsIAccessibleEvent.EVENT_STATE_CHANGE;
const EVENT_TEXT_ATTRIBUTE_CHANGED =