Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: chrome/test/data/extensions/api_test/automation/tests/desktop/focus_web.js

Issue 1589623002: Keep track of accessibility focus across windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var allTests = [
6 function testFocusAcrossWindows() {
7 // Create two windows with focusable text fields in them.
8 // Let window2 have focus.
9 var html1 = '<input title="Input1">';
10 var html2 = '<input title="Input2">';
11 var url1 = 'data:text/html,<!doctype html>' + encodeURI(html1);
12 var url2 = 'data:text/html,<!doctype html>' + encodeURI(html2);
13 chrome.windows.create({url: url1, focused: false});
14 chrome.windows.create({url: url2, focused: true});
15
16 // Wait for the accessibility trees to load and get the accessibility
17 // objects for both text fields.
18 //
19 // Try to focus the first text field (in the unfocused window) and then
20 // the second text field (in the focused window) after a short delay.
21 //
22 // If we get a focus event on the first text field, the test fails,
23 // because that window is in the background. If we get a focus event on
24 // the second text field, the test succeeds.
25 var input1, input2;
26 chrome.automation.getDesktop(function(rootNode) {
27 rootNode.addEventListener('loadComplete', function(event) {
28 if (event.target.url == url1) {
29 input1 = event.target.find({role: 'textField'});
30 }
31 if (event.target.url == url2) {
32 event.target.parent.focus();
David Tseng 2016/01/28 02:00:56 Why is this call made?
dmazzoni 2016/01/30 00:02:41 This focuses the webview that contains the second
33 input2 = event.target.find({role: 'textField'});
34 }
35 if (input1 && input2) {
36 input1.addEventListener('focus', function(event) {
37 chrome.test.fail();
38 }, false);
39 input2.addEventListener('focus', function(event) {
40 chrome.test.succeed();
41 }, false);
42 input1.focus();
43 setTimeout(function() {
44 input2.focus();
45 }, 100);
46 }
47 }, false);
48 });
49 },
50 ];
51
52 chrome.test.runTests(allTests);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698