Commit 90a45529 authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

ChromeVox: Add keyboard command to announce URL behind link.

This change adds a new ChromeVox keyboard command to announce the
url behind the currently selected link. If no link is selected, the
command does nothing. This change also adds a test to verify correct
behavior.

Bug: 690196.
Change-Id: Iecacb0bcf71657be4c1ea17221ad1f031542b273
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1860482Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708233}
parent 35b103e7
......@@ -1042,6 +1042,15 @@
"keyCode": [65, 67]
}
}
},
{
"command": "readLinkURL",
"sequence": {
"cvoxModifier": true,
"keys": {
"keyCode": [65, 76]
}
}
}
]
}
......@@ -2119,3 +2119,21 @@ TEST_F('ChromeVoxBackgroundTest', 'NonModalDialogHeadingJump', function() {
.replay();
});
});
TEST_F('ChromeVoxBackgroundTest', 'ReadLinkURLTest', function() {
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(function() {/*!
<a href="https://www.google.com/">A popular link</a>
<button>Not a link</button>
*/}, function(root) {
mockFeedback.call(doCmd('nextLink'))
.expectSpeech('A popular link', 'Link', 'Press Search+Space to activate.')
.call(doCmd('readLinkURL'))
.expectSpeech('Link URL: https://www.google.com/')
.call(doCmd('nextObject'))
.expectSpeech('Not a link', 'Button', 'Press Search+Space to activate.')
.call(doCmd('readLinkURL'))
.expectSpeech('No URL found')
.replay();
});
});
......@@ -971,6 +971,23 @@ CommandHandler.onCommand = function(command) {
}
}
return false;
case 'readLinkURL':
var node = ChromeVoxState.instance.currentRange.start.node;
var rootNode = node.root;
while (node && !node.url) {
// URL could be an ancestor of current range.
node = node.parent;
}
// Announce node's URL if it's not the root node; we don't want to
// announce the URL of the current page.
var url = (node && node !== rootNode) ? node.url : '';
new Output()
.withString(
url ? Msgs.getMsg('url_behind_link', [url]) :
Msgs.getMsg('no_url_found'))
.withQueueMode(cvox.QueueMode.CATEGORY_FLUSH)
.go();
return false;
default:
return true;
}
......
......@@ -3745,6 +3745,9 @@ If you're done with the tutorial, use ChromeVox to navigate to the Close button
<message desc="Announced when there is no available voice for a language." name="IDS_CHROMEVOX_VOICE_UNAVAILABLE_FOR_LANGUAGE">
No voice available for language: <ph name="language">$1<ex>English</ex></ph>
</message>
<message desc="Used to describe the link behind a url." name="IDS_CHROMEVOX_URL_BEHIND_LINK">
Link URL: <ph name="link_url">$1</ph>
</message>
</messages>
</release>
</grit>
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