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