Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/automation/tests/desktop/focus_iframe.js |
| diff --git a/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_iframe.js b/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_iframe.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ee69b37a627837d63170739640cf3b39495c5ed5 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/automation/tests/desktop/focus_iframe.js |
| @@ -0,0 +1,37 @@ |
| +// 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 testFocusInIframes() { |
| + chrome.test.getConfig(function(config) { |
| + var url = 'http://a.com:' + config.testServer.port + '/iframe_outer.html'; |
| + chrome.tabs.create({url: url}); |
| + |
| + chrome.automation.getDesktop(function(rootNode) { |
| + // Succeed when the button inside the iframe gets focus. |
| + rootNode.addEventListener('focus', function(event) { |
| + if (event.target.name == 'Inner') |
| + chrome.test.succeed(); |
| + }); |
| + |
| + // Wait for the inner frame to load, then find the button inside it |
| + // and focus it. |
| + rootNode.addEventListener('loadComplete', function(event) { |
| + if (event.target.url.indexOf('iframe_inner.html') >= 0) { |
| + chrome.automation.getFocus(function(focus) { |
| + // Assert that the outer frame has focus. |
| + assertTrue(focus.url.indexOf('iframe_outer') >= 0); |
| + |
| + // Find the inner button and focus it. |
| + var innerButton = focus.find({ attributes: { name: 'Inner' } }); |
| + innerButton.focus(); |
| + }); |
| + } |
| + }); |
| + }); |
| + }); |
| + }, |
| +]; |
|
David Tseng
2016/03/04 16:50:20
Could you also add a test for tree walking (out an
dmazzoni
2016/03/07 23:12:39
Done now. I had to make a change to AutomationPred
|
| + |
| +chrome.test.runTests(allTests); |