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

Side by Side Diff: chrome/test/data/extensions/api_test/tabs/basics/events.js

Issue 8762014: Move another set of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 testTabId;
6 var otherTabId;
7 var firstWindowId;
8 var secondWindowId;
9
10 chrome.test.runTests([
11 function init() {
12 chrome.tabs.getSelected(null, pass(function(tab) {
13 testTabId = tab.id;
14 firstWindowId = tab.windowId;
15 }));
16 },
17
18 function tabsOnCreated() {
19 chrome.test.listenOnce(chrome.tabs.onCreated, function(tab) {
20 assertEq(pageUrl("f"), tab.url);
21 otherTabId = tab.id;
22 assertEq(true, tab.selected);
23 });
24
25 chrome.tabs.create({"windowId": firstWindowId, "url": pageUrl("f"),
26 "selected": true}, pass(function(tab) {}));
27 },
28
29 function tabsOnUpdatedIgnoreTabArg() {
30 // A third argument was added to the onUpdated event callback.
31 // Test that an event handler which ignores this argument works.
32 var onUpdatedCompleted = chrome.test.listenForever(chrome.tabs.onUpdated,
33 function(tabid, changeInfo) {
34 if (tabid == otherTabId && changeInfo.status == "complete") {
35 onUpdatedCompleted();
36 }
37 }
38 );
39
40 chrome.tabs.update(otherTabId, {"url": pageUrl("f")}, pass());
41 },
42
43 function tabsOnUpdated() {
44 var onUpdatedCompleted = chrome.test.listenForever(
45 chrome.tabs.onUpdated,
46 function(tabid, changeInfo, tab) {
47 // |tab| contains the id of the tab it describes.
48 // Test that |tabid| matches this id.
49 assertEq(tabid, tab.id);
50
51 // If |changeInfo| has a status property, than
52 // it should match the status of the tab in |tab|.
53 if (changeInfo.status) {
54 assertEq(changeInfo.status, tab.status);
55 }
56
57 if (tabid == otherTabId && changeInfo.status == "complete") {
58 onUpdatedCompleted();
59 }
60 }
61 );
62
63 chrome.tabs.update(otherTabId, {"url": pageUrl("f")}, pass());
64 },
65
66 function tabsOnMoved() {
67 chrome.test.listenOnce(chrome.tabs.onMoved, function(tabid, info) {
68 assertEq(otherTabId, tabid);
69 });
70
71 chrome.tabs.move(otherTabId, {"index": 0}, pass());
72 },
73
74 function tabsOnSelectionChanged() {
75 chrome.test.listenOnce(chrome.tabs.onSelectionChanged,
76 function(tabid, info) {
77 assertEq(testTabId, tabid);
78 }
79 );
80
81 chrome.tabs.update(testTabId, {"selected": true}, pass());
82 },
83
84 function setupTabsOnAttachDetach() {
85 createWindow([""], {}, pass(function(winId, tabIds) {
86 secondWindowId = winId;
87 }));
88 },
89
90 function tabsOnAttached() {
91 function moveAndListen(tabId, properties, callback) {
92 chrome.test.listenOnce(chrome.tabs.onAttached,
93 function(testTabId, info) {
94 // Ensure notification is correct.
95 assertEq(testTabId, tabId);
96 assertEq(properties.windowId, info.newWindowId);
97 assertEq(properties.index, info.newPosition);
98 if (callback)
99 callback();
100 });
101 chrome.tabs.move(tabId, properties);
102 };
103
104 // Move tab to second window, then back to first.
105 // The original tab/window configuration should be restored.
106 // tabsOnDetached() depends on it.
107 moveAndListen(testTabId, {"windowId": secondWindowId, "index": 0},
108 pass(function() {
109 moveAndListen(testTabId, {"windowId": firstWindowId, "index": 1});
110 }));
111 },
112
113 function tabsOnDetached() {
114 function moveAndListen(tabId, oldWindowId, oldIndex, properties,
115 callback) {
116 chrome.test.listenOnce(chrome.tabs.onDetached,
117 function(detachedTabId, info) {
118 // Ensure notification is correct.
119 assertEq(detachedTabId, tabId);
120 assertEq(oldWindowId, info.oldWindowId);
121 assertEq(oldIndex, info.oldPosition);
122 if (callback)
123 callback();
124 });
125 chrome.tabs.move(tabId, properties);
126 };
127
128 // Move tab to second window, then back to first.
129 moveAndListen(testTabId, firstWindowId, 1,
130 {"windowId": secondWindowId, "index": 0}, pass(function() {
131 moveAndListen(testTabId, secondWindowId, 0,
132 {"windowId": firstWindowId, "index": 1});
133 }));
134 },
135
136 function windowsOnCreated() {
137 chrome.test.listenOnce(chrome.windows.onCreated, function(window) {
138 assertTrue(window.width > 0);
139 assertTrue(window.height > 0);
140 assertEq("normal", window.type);
141 assertTrue(!window.incognito);
142 windowEventsWindow = window;
143 chrome.tabs.getAllInWindow(window.id, pass(function(tabs) {
144 assertEq(pageUrl("a"), tabs[0].url);
145 }));
146 });
147
148 chrome.windows.create({"url": pageUrl("a")}, pass(function(tab) {}));
149 },
150
151 /*
152 This test doesn't work on mac because the Chromium app never gets
153 brought to the front. See: crbug.com/60963.
154 It also doesn't work on Chrome OS for unknown reasons.
155 It also times out on the full XP builder for unknown reasons.
156 See: crbug.com/61035.
157
158 function windowsOnFocusChanged() {
159 chrome.windows.getCurrent(pass(function(windowA) {
160 chrome.windows.create({}, pass(function(windowB) {
161 chrome.windows.update(windowA.id, {focused: true}, pass(function() {
162 chrome.windows.update(windowB.id, {focused: true}, pass(function() {
163 chrome.test.listenOnce(chrome.windows.onFocusChanged,
164 function(changedWindowId) {
165 assertEq(windowEventsWindow.id, changedWindowId);
166 });
167 chrome.windows.remove(windowB.id);
168 }));
169 }));
170 }));
171 }));
172 }
173 */
174 ]);
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/tabs/basics/events.html ('k') | chrome/test/data/extensions/api_test/tabs/basics/f.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698