| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 testTab = { url: 'a.html', width: 200, height: 200 }; | |
| 6 var testTabId; | |
| 7 | |
| 8 var linkX = 11; | |
| 9 var linkY = 11; | |
| 10 | |
| 11 chrome.test.runTests([ | |
| 12 function init() { | |
| 13 chrome.test.listenOnce( | |
| 14 chrome.experimental.offscreenTabs.onUpdated, | |
| 15 function(tabId, changeInfo, tab) { | |
| 16 assertSimilarTabs(testTab, tab); | |
| 17 }); | |
| 18 | |
| 19 chrome.experimental.offscreenTabs.create(testTab, pass(function(tab) { | |
| 20 assertSimilarTabs(testTab, tab); | |
| 21 testTabId = tab.id; | |
| 22 })); | |
| 23 }, | |
| 24 | |
| 25 // Test that mouse click events work by watching the tab navigate to b.html | |
| 26 // after clicking the link on a.html. | |
| 27 function mouseClick() { | |
| 28 chrome.test.listenOnce( | |
| 29 chrome.experimental.offscreenTabs.onUpdated, | |
| 30 function(tabId, changeInfo, tab) { | |
| 31 testTab.url = 'b.html'; | |
| 32 assertEq(maybeExpandURL('b.html'), changeInfo.url); | |
| 33 assertEq(testTabId, tabId); | |
| 34 assertEq(testTabId, tab.id); | |
| 35 assertSimilarTabs(testTab, tab); | |
| 36 }); | |
| 37 | |
| 38 var mouseEvent = getBaseMouseEvent(); | |
| 39 mouseEvent.type = 'click'; | |
| 40 | |
| 41 chrome.experimental.offscreenTabs.sendMouseEvent( | |
| 42 testTabId, mouseEvent, linkX, linkY, pass(function() { | |
| 43 chrome.experimental.offscreenTabs.get(testTabId, pass(function(tab) { | |
| 44 assertEq(testTabId, tab.id); | |
| 45 assertSimilarTabs(testTab, tab); | |
| 46 })); | |
| 47 })); | |
| 48 }, | |
| 49 | |
| 50 // Scroll the b.html page down 100 px so that the link is at (10,10). | |
| 51 function mouseWheel() { | |
| 52 var mouseEvent = getBaseMouseEvent(); | |
| 53 mouseEvent.type = 'mousewheel'; | |
| 54 mouseEvent.wheelDeltaX = 0; | |
| 55 mouseEvent.wheelDeltaY = -100; | |
| 56 chrome.experimental.offscreenTabs.sendMouseEvent( | |
| 57 testTabId, mouseEvent, 0, 0, pass(function() { | |
| 58 chrome.experimental.offscreenTabs.get(testTabId, pass(function(tab) { | |
| 59 assertSimilarTabs(testTab, tab); | |
| 60 })); | |
| 61 })); | |
| 62 }, | |
| 63 | |
| 64 // Now that we scrolled the links into position, sending consecutive | |
| 65 // mousedown|up events to the link should navigate the page to c.html. | |
| 66 function mouseDownUp() { | |
| 67 chrome.test.listenOnce( | |
| 68 chrome.experimental.offscreenTabs.onUpdated, | |
| 69 function(tabId, changeInfo, tab) { | |
| 70 testTab.url = 'c.html'; | |
| 71 assertEq(testTabId, tabId); | |
| 72 assertEq(testTabId, tab.id); | |
| 73 assertSimilarTabs(testTab, tab); | |
| 74 }); | |
| 75 | |
| 76 var mouseEvent = getBaseMouseEvent(); | |
| 77 mouseEvent.type = 'mousedown'; | |
| 78 chrome.experimental.offscreenTabs.sendMouseEvent( | |
| 79 testTabId, mouseEvent, linkX, linkY, pass(function() { | |
| 80 chrome.experimental.offscreenTabs.get(testTabId, pass(function(tab) { | |
| 81 assertSimilarTabs(testTab, tab); | |
| 82 })); | |
| 83 })); | |
| 84 | |
| 85 mouseEvent.type = 'mouseup'; | |
| 86 chrome.experimental.offscreenTabs.sendMouseEvent( | |
| 87 testTabId, mouseEvent, linkX, linkY, pass(function() { | |
| 88 chrome.experimental.offscreenTabs.get(testTabId, pass(function(tab) { | |
| 89 assertSimilarTabs(testTab, tab); | |
| 90 })); | |
| 91 })); | |
| 92 } | |
| 93 | |
| 94 // TODO(jstritar): Test event validation and edge cases. | |
| 95 ]); | |
| OLD | NEW |