Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/automation/tests/desktop/focus_web.js |
| diff --git a/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_web.js b/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_web.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a30ab032af56b00b23d02f8d365aa9feaefcb407 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_web.js |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +var allTests = [ |
| + function testFocusAcrossWindows() { |
| + // Create two windows with focusable text fields in them. |
| + // Let window2 have focus. |
| + var html1 = '<input title="Input1">'; |
| + var html2 = '<input title="Input2">'; |
| + var url1 = 'data:text/html,<!doctype html>' + encodeURI(html1); |
| + var url2 = 'data:text/html,<!doctype html>' + encodeURI(html2); |
| + chrome.windows.create({url: url1, focused: false}); |
| + chrome.windows.create({url: url2, focused: true}); |
| + |
| + // Wait for the accessibility trees to load and get the accessibility |
| + // objects for both text fields. |
| + // |
| + // Try to focus the first text field (in the unfocused window) and then |
| + // the second text field (in the focused window) after a short delay. |
| + // |
| + // If we get a focus event on the first text field, the test fails, |
| + // because that window is in the background. If we get a focus event on |
| + // the second text field, the test succeeds. |
| + var input1, input2; |
| + chrome.automation.getDesktop(function(rootNode) { |
| + rootNode.addEventListener('loadComplete', function(event) { |
| + if (event.target.url == url1) { |
| + input1 = event.target.find({role: 'textField'}); |
| + } |
| + if (event.target.url == url2) { |
| + 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
|
| + input2 = event.target.find({role: 'textField'}); |
| + } |
| + if (input1 && input2) { |
| + input1.addEventListener('focus', function(event) { |
| + chrome.test.fail(); |
| + }, false); |
| + input2.addEventListener('focus', function(event) { |
| + chrome.test.succeed(); |
| + }, false); |
| + input1.focus(); |
| + setTimeout(function() { |
| + input2.focus(); |
| + }, 100); |
| + } |
| + }, false); |
| + }); |
| + }, |
| +]; |
| + |
| +chrome.test.runTests(allTests); |