1 // Copyright 2014 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.
5 function listenOnce(node, eventType, callback, capture) {
6 var innerCallback = function() {
7 node.removeEventListener(eventType, innerCallback, capture);
10 node.addEventListener(eventType, innerCallback, capture);
14 function testDoDefault() {
15 var firstTextField = findAutomationNode(rootNode,
17 return node.role == 'textField';
19 assertTrue(!!firstTextField);
20 listenOnce(firstTextField, EventType.focus, function(e) {
21 chrome.test.succeed();
23 firstTextField.doDefault();
26 function testFocus() {
27 var firstFocusableNode = findAutomationNode(rootNode,
29 return node.role == 'button' && node.state.focusable;
31 assertTrue(!!firstFocusableNode);
32 listenOnce(firstFocusableNode, EventType.focus, function(e) {
33 chrome.test.succeed();
35 firstFocusableNode.focus();
38 function testDoDefaultViews() {
39 listenOnce(rootNode, 'focus', function(node) {
40 chrome.test.succeed();
42 var button = rootNode.find(
43 {role: 'button', attributes: {name: 'Bookmark this page'}});
47 function testContextMenu() {
48 var addressBar = rootNode.find({role: 'textField'});
49 listenOnce(rootNode, EventType.menuStart, function(e) {
50 addressBar.showContextMenu();
51 chrome.test.succeed();
53 addressBar.showContextMenu();
57 setupAndRunTests(allTests);