Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: chrome/test/data/extensions/api_test/offscreen_tabs/mouse_events.js

Issue 9234042: Re-land alexbost's experimental offscreenTabs API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: merge / rebase Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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(tab) {
43 assertEq(testTabId, tab.id);
44 assertSimilarTabs(testTab, tab);
45 }));
46 },
47
48 // Scroll the b.html page down 100 px so that the link is at (10,10).
49 function mouseWheel() {
50 var mouseEvent = getBaseMouseEvent();
51 mouseEvent.type = 'mousewheel';
52 mouseEvent.wheelDeltaX = 0;
53 mouseEvent.wheelDeltaY = -100;
54 chrome.experimental.offscreenTabs.sendMouseEvent(
55 testTabId, mouseEvent, 0, 0, pass(function(tab) {
56 assertSimilarTabs(testTab, tab);
57 }));
58 },
59
60 // Now that we scrolled the links into position, sending consecutive
61 // mousedown|up events to the link should navigate the page to c.html.
62 function mouseDownUp() {
63 chrome.test.listenOnce(
64 chrome.experimental.offscreenTabs.onUpdated,
65 function(tabId, changeInfo, tab) {
66 testTab.url = 'c.html';
67 assertEq(testTabId, tabId);
68 assertEq(testTabId, tab.id);
69 assertSimilarTabs(testTab, tab);
70 });
71
72 var mouseEvent = getBaseMouseEvent();
73 mouseEvent.type = 'mousedown';
74 chrome.experimental.offscreenTabs.sendMouseEvent(
75 testTabId, mouseEvent, linkX, linkY, pass(function(tab) {
76 assertSimilarTabs(testTab, tab);
77 }));
78
79 mouseEvent.type = 'mouseup';
80 chrome.experimental.offscreenTabs.sendMouseEvent(
81 testTabId, mouseEvent, linkX, linkY, pass(function(tab) {
82 assertSimilarTabs(testTab, tab);
83 }));
84 }
85
86 // TODO(jstritar): Test event validation and edge cases.
87 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698