OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 testHitTestInDesktop() { |
| 7 var url = 'data:text/html,<!doctype html>' + |
| 8 encodeURI('<button>Click Me</button>'); |
| 9 chrome.automation.getDesktop(function(desktop) { |
| 10 chrome.tabs.create({url: url}); |
| 11 |
| 12 desktop.addEventListener('loadComplete', function(event) { |
| 13 if (event.target.url.indexOf('data:') >= 0) { |
| 14 var button = desktop.find({ attributes: { name: 'Click Me' } }); |
| 15 if (button) { |
| 16 button.addEventListener(EventType.ALERT, function() { |
| 17 chrome.test.succeed(); |
| 18 }, true); |
| 19 var cx = Math.floor( |
| 20 button.location.left + button.location.width / 2); |
| 21 var cy = Math.floor( |
| 22 button.location.top + button.location.height / 2); |
| 23 desktop.hitTest(cx, cy, EventType.ALERT); |
| 24 } |
| 25 } |
| 26 }, false); |
| 27 }); |
| 28 }, |
| 29 ]; |
| 30 |
| 31 chrome.test.runTests(allTests); |
OLD | NEW |