Text fields should be focused before trying to retrieve their selection

When a selection is made on an <input> or a <textarea> element via
the DOM selection APIs, the APIs do not expose
the selection visually if the text field is not focused.
If a selection is made, while the field is not focused
the selection is cached and made available when
the field gets focus.
This patch ensures that the same constraint is observed
when using chrome.automation.
The new AXSelection code is made to work as closely as possible to how
the DOM selection API works, so this patch will
make it easier to switch to the new code.

For consistency in the same test file, also focuses the combo box before
retrieving its active descendant.
R=dtseng@chromium.org, dmazzoni@chromium.org

Bug: 639340
Change-Id: I9813c7aa4af65991177bafd34f6606303fee2d1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1536147
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644981}
2 files changed