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

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

Issue 1705853002: NOT FOR REVIEW. ax tree focus with debugging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed crash 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. (Enforce this by focusing the WebView
9 // that's the parent of the second window's document, below.)
10 var html1 = '<input title="Input1">';
11 var html2 = '<input title="Input2">';
12 var url1 = 'data:text/html,<!doctype html>' + encodeURI(html1);
13 var url2 = 'data:text/html,<!doctype html>' + encodeURI(html2);
14 chrome.windows.create({url: url1, focused: false});
15 chrome.windows.create({url: url2, focused: true});
16
17 // Wait for the accessibility trees to load and get the accessibility
18 // objects for both text fields.
19 //
20 // Try to focus the first text field (in the unfocused window) and then
21 // the second text field (in the focused window) after a short delay.
22 //
23 // If we get a focus event on the first text field, the test fails,
24 // because that window is in the background. If we get a focus event on
25 // the second text field, the test succeeds.
26 var input1, input2;
27 chrome.automation.getDesktop(function(rootNode) {
28 rootNode.addEventListener('loadComplete', function(event) {
29 if (event.target.url == url1) {
30 input1 = event.target.find({role: 'textField'});
31 }
32 if (event.target.url == url2) {
33 // Focus the WebView that's the parent of the second document.
34 event.target.parent.focus();
35 input2 = event.target.find({role: 'textField'});
36 }
37 if (input1 && input2) {
38 input1.addEventListener('focus', function(event) {
39 chrome.test.fail();
40 }, false);
41 input2.addEventListener('focus', function(event) {
42 chrome.test.succeed();
43 }, false);
44 input1.focus();
45 setTimeout(function() {
46 input2.focus();
47 }, 100);
48 }
49 }, false);
50 });
51 },
52 ];
53
54 chrome.test.runTests(allTests);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698