Commit 8d0e11cc authored by Katie D's avatar Katie D Committed by Commit Bot

Read URL from omnibox if present.

This updates the way STS handles text areas that have a 'value'
and no children, i.e. text areas that are in the native UI.

Bug: 820184
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Id8d9d7609812209920273c8ca1a29ee332532dfc
Reviewed-on: https://chromium-review.googlesource.com/956351Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Katie Dektar <katie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542147}
parent dcc571a7
......@@ -161,7 +161,15 @@ function buildNodeGroup(nodes, index) {
newNode = new NodeGroupItem(node, result.text.length, false);
}
if (newNode) {
result.text += newNode.node.name + ' ';
if (newNode.node.role == RoleType.TEXT_FIELD &&
newNode.node.children.length == 0 && newNode.node.value) {
// A text field with no children should use its value instead of
// the name element, this is the contents of the text field.
// This occurs in native UI such as the omnibox.
result.text += newNode.node.value + ' ';
} else {
result.text += newNode.node.name + ' ';
}
result.nodes.push(newNode);
}
}
......
......@@ -150,4 +150,19 @@ TEST_F('SelectToSpeakParagraphUnitTest', 'BuildNodeGroupIncludesLinks',
assertEquals(6, result.nodes[1].startChar);
assertEquals(linkText, result.nodes[1].node);
assertEquals(paragraph1, result.blockParent);
});
TEST_F('SelectToSpeakParagraphUnitTest', 'BuildNodeGroupNativeTextBox',
function() {
let root = {role: 'desktop'};
let parent = {role: 'pane', parent: root, root: root};
let searchBar = {role: 'textField', name: 'Address and search bar',
value: 'http://www.google.com', children: []};
let result = buildNodeGroup([searchBar], 0);
assertEquals('http://www.google.com ', result.text);
// If there is no value, it should use the name.
searchBar.value = '';
result = buildNodeGroup([searchBar], 0);
assertEquals('Address and search bar ', result.text);
});
\ No newline at end of file
......@@ -22,7 +22,8 @@ chrome.automation.RoleType = {
ROOT_WEB_AREA: 'rootWebArea',
STATIC_TEXT: 'staticText',
INLINE_TEXT_BOX: 'inlineTextBox',
PARAGRAPH: 'paragraph'
PARAGRAPH: 'paragraph',
TEXT_FIELD: 'textField',
};
chrome.automation.StateType = {
......
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