Commit 9bca119b authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Make ChromeVox respond to all in-page link navigations.

Previously ChromeVox handled in-page links if you force-click on
them. This change makes it so that it also handles it if the user
presses Enter or mouse-clicks on a link, by responding to the
scrolledToAnchor event.

Testing this required enabling the test server because the browser
doesn't follow same-page links in data urls. Some of the work to
make use of the test server in ChromeVox tests was already done
for portals, but I had to fix a tiny bug in js2gtest.

how they're activated.

Bug: 1130786
AX-Relnotes: ChromeVox now properly handles in-page links no matter
Change-Id: I9e56f6c88fdbce35c14e692411cb7bb4a2e46db2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2422704
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809223}
parent 4a08f89b
...@@ -136,6 +136,16 @@ ChromeVoxBackgroundTest = class extends ChromeVoxNextE2ETest { ...@@ -136,6 +136,16 @@ ChromeVoxBackgroundTest = class extends ChromeVoxNextE2ETest {
} }
}; };
/**
* Specific test fixture for tests that need a test server running.
*/
ChromeVoxBackgroundTestWithTestServer = class extends ChromeVoxBackgroundTest {
get testServer() {
return true;
}
};
/** Tests that ChromeVox classic is in this context. */ /** Tests that ChromeVox classic is in this context. */
SYNC_TEST_F('ChromeVoxBackgroundTest', 'ClassicNamespaces', function() { SYNC_TEST_F('ChromeVoxBackgroundTest', 'ClassicNamespaces', function() {
...@@ -1230,7 +1240,9 @@ TEST_F('ChromeVoxBackgroundTest', 'BrailleCaretNavigation', function() { ...@@ -1230,7 +1240,9 @@ TEST_F('ChromeVoxBackgroundTest', 'BrailleCaretNavigation', function() {
}); });
}); });
TEST_F('ChromeVoxBackgroundTest', 'InPageLinks', function() { // This tests ChromeVox's special support for following an in-page link
// if you force-click on it. Compare with InPageLinks, below.
TEST_F('ChromeVoxBackgroundTest', 'ForceClickInPageLinks', function() {
const mockFeedback = this.createMockFeedback(); const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree( this.runWithLoadedTree(
` `
...@@ -1245,6 +1257,29 @@ TEST_F('ChromeVoxBackgroundTest', 'InPageLinks', function() { ...@@ -1245,6 +1257,29 @@ TEST_F('ChromeVoxBackgroundTest', 'InPageLinks', function() {
}); });
}); });
// This tests ChromeVox's handling of the scrolledToAnchor event, which is
// fired when the users follows an in-page link or the document otherwise
// gets navigated to an in-page link target by the url fragment changing,
// not necessarily due to directly clicking on the link via ChromeVox.
//
// Note: this test needs the test server running because the browser
// does not follow same-page links on data urls (because it modifies the
// url fragment, and any change to the url is disallowed for a data url).
TEST_F('ChromeVoxBackgroundTestWithTestServer', 'InPageLinks', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(undefined, function(root) {
mockFeedback.call(doCmd('nextObject'))
.expectSpeech('Jump', 'Internal link')
.call(press(KeyCode.RETURN))
.expectSpeech('Found It')
.call(doCmd('nextHeading'))
.expectSpeech('Continue Here', 'Heading 2')
.replay();
}.bind(this), {
url: `${testRunnerParams.testServerBaseUrl}accessibility/in_page_links.html`
});
});
TEST_F('ChromeVoxBackgroundTest', 'ListItem', function() { TEST_F('ChromeVoxBackgroundTest', 'ListItem', function() {
this.resetContextualOutput(); this.resetContextualOutput();
const mockFeedback = this.createMockFeedback(); const mockFeedback = this.createMockFeedback();
......
...@@ -76,6 +76,8 @@ DesktopAutomationHandler = class extends BaseAutomationHandler { ...@@ -76,6 +76,8 @@ DesktopAutomationHandler = class extends BaseAutomationHandler {
this.addListener_(EventType.MENU_START, this.onMenuStart); this.addListener_(EventType.MENU_START, this.onMenuStart);
this.addListener_( this.addListener_(
EventType.SCROLL_POSITION_CHANGED, this.onScrollPositionChanged); EventType.SCROLL_POSITION_CHANGED, this.onScrollPositionChanged);
// Called when a same-page link is followed or the url fragment changes.
this.addListener_(EventType.SCROLLED_TO_ANCHOR, this.onEventDefault);
this.addListener_(EventType.SELECTION, this.onSelection); this.addListener_(EventType.SELECTION, this.onSelection);
this.addListener_(EventType.TEXT_CHANGED, this.onEditableChanged_); this.addListener_(EventType.TEXT_CHANGED, this.onEditableChanged_);
this.addListener_( this.addListener_(
......
...@@ -404,8 +404,8 @@ function TEST_F(testFixture, testFunction, testBody, opt_preamble) { ...@@ -404,8 +404,8 @@ function TEST_F(testFixture, testFunction, testBody, opt_preamble) {
const featureList = this[testFixture].prototype.featureList; const featureList = this[testFixture].prototype.featureList;
const featuresWithParameters = const featuresWithParameters =
this[testFixture].prototype.featuresWithParameters; this[testFixture].prototype.featuresWithParameters;
if ((!hasSwitches && !featureList && !featuresWithParameters) || if ((!hasSwitches && !featureList && !featuresWithParameters &&
typedefCppFixture == 'V8UnitTest') { !testServer) || typedefCppFixture == 'V8UnitTest') {
output(` output(`
typedef ${typedefCppFixture} ${testFixture}; typedef ${typedefCppFixture} ${testFixture};
`); `);
......
<div><button>Initial button</button>
<div><a href="#there">Jump</a></div>
<h2>Skip Me</h2>
<h2>Skip Me Too</h2>
<h2><span id="there">Found It</span></h2>
<h2>Continue Here</h2>
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