OLD | NEW |
---|---|
(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); | |
OLD | NEW |