OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function listenOnce(node, eventType, callback, capture) { | |
6 var innerCallback = function() { | |
7 node.removeEventListener(eventType, innerCallback, capture); | |
8 callback(); | |
9 }; | |
10 node.addEventListener(eventType, innerCallback, capture); | |
11 }; | |
12 | |
13 var allTests = [ | 5 var allTests = [ |
14 function testDoDefault() { | 6 function testDoDefault() { |
15 var firstTextField = findAutomationNode(rootNode, | 7 var firstTextField = findAutomationNode(rootNode, |
16 function(node) { | 8 function(node) { |
17 return node.role == 'textField'; | 9 return node.role == 'textField'; |
18 }); | 10 }); |
19 assertTrue(!!firstTextField); | 11 assertTrue(!!firstTextField); |
20 listenOnce(firstTextField, EventType.focus, function(e) { | 12 listenOnce(firstTextField, EventType.focus, function(e) { |
21 chrome.test.succeed(); | 13 chrome.test.succeed(); |
22 }, true); | 14 }, true); |
(...skipping 24 matching lines...) Expand all Loading... |
47 function testContextMenu() { | 39 function testContextMenu() { |
48 var addressBar = rootNode.find({role: 'textField'}); | 40 var addressBar = rootNode.find({role: 'textField'}); |
49 listenOnce(rootNode, EventType.menuStart, function(e) { | 41 listenOnce(rootNode, EventType.menuStart, function(e) { |
50 addressBar.showContextMenu(); | 42 addressBar.showContextMenu(); |
51 chrome.test.succeed(); | 43 chrome.test.succeed(); |
52 }, true); | 44 }, true); |
53 addressBar.showContextMenu(); | 45 addressBar.showContextMenu(); |
54 } | 46 } |
55 ]; | 47 ]; |
56 | 48 |
57 setupAndRunTests(allTests); | 49 setUpAndRunTests(allTests); |
OLD | NEW |