Commit daa41c37 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Fixes ChromeVox Panel tests

- fixes one regression where the form controls list shortcut command no longer works
- found root cause of panel test flakes. The panel does not immediately get focus, especially on slower builds, so we need to wait for focus prior to performing panel construction and menu bar/menu item focusing
- added additional test as well as fixing / rebaselining current tests
- simplified logic that sets the active item for node menus on ChromeVox's current range (see test)
- simplify places where we set active item; caused a lot of focus events to be sent unnecessarily

Fixed: 990229, 795840
RELNOTES: makes Search+Ctrl+F work again in ChromeVox (show form controls list)
Change-Id: I7ed10a70b524da48b4d55f2a4e086dae09a9629d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124246
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754936}
parent 837af2f6
......@@ -672,7 +672,9 @@ CommandHandler.onCommand = function(command) {
(new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_heading')).send();
return false;
case 'showFormsList':
(new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_form')).send();
(new PanelCommand(
PanelCommandType.OPEN_MENUS, 'panel_menu_form_controls'))
.send();
return false;
case 'showLandmarksList':
(new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_landmark')).send();
......
......@@ -340,16 +340,17 @@ PanelNodeMenu = class extends PanelMenu {
this.walker_;
/** @private {number} */
this.nodeCount_ = 0;
/** @private {boolean} */
this.selectNext_ = false;
this.populate_();
}
/** @override */
activate(activateFirstItem) {
PanelMenu.prototype.activate.call(this, activateFirstItem);
super.activate(false);
if (activateFirstItem) {
this.activateItem(this.activeIndex_);
// The active index might have been set prior to this call in
// |findMoreNodes|. We want to start the menu there.
const index = this.activeIndex_ == -1 ? 0 : this.activeIndex_;
this.activateItem(index);
}
}
......@@ -376,7 +377,6 @@ PanelNodeMenu = class extends PanelMenu {
}
});
this.nodeCount_ = 0;
this.selectNext_ = false;
this.findMoreNodes_();
}
......@@ -393,9 +393,6 @@ PanelNodeMenu = class extends PanelMenu {
findMoreNodes_() {
while (this.walker_.next().node) {
const node = this.walker_.node;
if (node == this.node_) {
this.selectNext_ = true;
}
if (this.pred_(node)) {
const output = new Output();
const range = cursors.Range.fromNode(node);
......@@ -411,9 +408,8 @@ PanelNodeMenu = class extends PanelMenu {
};
}()));
if (this.selectNext_) {
this.activateItem(this.items_.length - 1);
this.selectNext_ = false;
if (node == this.node_ && !this.async_) {
this.activeIndex_ = this.items_.length - 1;
}
}
......@@ -438,7 +434,6 @@ PanelNodeMenu = class extends PanelMenu {
if (!this.items_.length) {
this.addMenuItem(
Msgs.getMsg('panel_menu_item_none'), '', '', '', function() {});
this.activateItem(0);
}
}
};
......
......@@ -69,33 +69,28 @@ ChromeVoxPanelTest = class extends ChromeVoxNextE2ETest {
}
};
// TODO: Flaky timeouts. https://crbug.com/795840 and https://crbug.com/990229
TEST_F('ChromeVoxPanelTest', 'DISABLED_ActivateMenu', function() {
TEST_F('ChromeVoxPanelTest', 'ActivateMenu', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.linksDoc, function(root) {
const openMenus = new PanelCommand(PanelCommandType.OPEN_MENUS);
mockFeedback.call(openMenus.send.bind(openMenus))
.expectSpeech(
'Jump', 'Menu',
'Go To Beginning Of Table ChromeVox+Alt+Shift+Left arrow',
'Go To Beginning Of Table Search+Alt+Shift+Left arrow',
/ 1 of [0-9]{2} /)
.call(this.fireMockEvent('ArrowRight'))
.expectSpeech(
'Speech', 'Menu',
'Announce The Title Of The Current Page ChromeVox+A>W', 'Menu item',
'Announce Current Battery Status Search+O, then B',
/ 1 of [0-9]{2} /)
.replay();
});
});
// TODO: Flaky timeouts. https://crbug.com/795840 and https://crbug.com/990229
TEST_F('ChromeVoxPanelTest', 'DISABLED_LinkMenu', function() {
TEST_F('ChromeVoxPanelTest', 'LinkMenu', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(this.linksDoc, function(root) {
const openMenus =
new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_link');
mockFeedback.call(openMenus.send.bind(openMenus))
mockFeedback.call(() => CommandHandler.onCommand('showLinksList'))
.expectSpeech(
'Link',
'Menu',
......@@ -104,7 +99,7 @@ TEST_F('ChromeVoxPanelTest', 'DISABLED_LinkMenu', function() {
' 1 of 3 ',
)
.call(this.fireMockEvent('ArrowLeft'))
.expectSpeech('Landmark', 'Menu', 'No items.', 'Menu item', ' 1 of 1 ')
.expectSpeech('Landmark', 'Menu', 'No items', 'Menu item', ' 1 of 1 ')
.call(this.fireMockEvent('ArrowRight'))
.expectSpeech('Link', 'Menu', 'apple Link', 'Menu item', ' 1 of 3 ')
.call(this.fireMockEvent('ArrowUp'))
......@@ -115,3 +110,23 @@ TEST_F('ChromeVoxPanelTest', 'DISABLED_LinkMenu', function() {
.replay();
});
});
TEST_F('ChromeVoxPanelTest', 'FormControlsMenu', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(
`<button>Cancel</button><button>OK</button>`, function(root) {
mockFeedback.call(() => CommandHandler.onCommand('nextObject'))
.expectSpeech('OK', 'Button')
.call(() => CommandHandler.onCommand('showFormsList'))
.expectSpeech(
'Form Controls',
'Menu',
'OK Button',
'Menu item',
/2 of /,
)
.call(this.fireMockEvent('ArrowUp'))
.expectSpeech('Cancel Button', 'Menu item', /1 of/)
.replay();
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment