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

Side by Side Diff: chrome/test/data/extensions/api_test/tabs/basics/query.html

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
1 <!--
2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 * source code is governed by a BSD-style license that can be found in the
4 * LICENSE file.
5 -->
1 <script src="tabs_util.js"></script> 6 <script src="tabs_util.js"></script>
2 7 <script src="query.js"></script>
3 <script>
4 var testWindowId;
5 var active_tabs = [];
6 var highlighted_tabs = [];
7 var window_tabs = [];
8 var pinned_tabs = [];
9 var active_and_window_tabs = [];
10
11 chrome.test.runTests([
12 function setup() {
13 var tabs = ['http://example.org/a.html', 'http://google.com'];
14 chrome.windows.create({url: tabs}, pass(function(window) {
15 assertEq(2, window.tabs.length);
16 testWindowId = window.id;
17 chrome.tabs.create({
18 windowId: testWindowId,
19 url: 'about:blank',
20 pinned: true
21 }, pass(function(tab) {
22 assertTrue(tab.pinned);
23 assertEq(testWindowId, tab.windowId);
24 }));
25 }));
26 },
27
28 function queryAll() {
29 chrome.tabs.query({}, pass(function(tabs) {
30 assertEq(4, tabs.length);
31 for (var x = 0; x < tabs.length; x++) {
32 if (tabs[x].highlighted)
33 highlighted_tabs.push(tabs[x]);
34 if (tabs[x].active)
35 active_tabs.push(tabs[x]);
36 if (tabs[x].windowId == testWindowId) {
37 window_tabs.push(tabs[x]);
38 if (tabs[x].active)
39 active_and_window_tabs.push(tabs[x]);
40 }
41 if (tabs[x].pinned)
42 pinned_tabs.push(tabs[x]);
43 }
44 }));
45 },
46
47 function queryHighlighted() {
48 chrome.tabs.query({highlighted:true}, pass(function(tabs) {
49 assertEq(highlighted_tabs.length, tabs.length);
50 for (var x = 0; x < tabs.length; x++)
51 assertTrue(tabs[x].highlighted);
52 }));
53 chrome.tabs.query({highlighted:false}, pass(function(tabs) {
54 assertEq(4-highlighted_tabs.length, tabs.length);
55 for (var x = 0; x < tabs.length; x++)
56 assertFalse(tabs[x].highlighted);
57 }));
58 },
59
60 function queryActive() {
61 chrome.tabs.query({active: true}, pass(function(tabs) {
62 assertEq(active_tabs.length, tabs.length);
63 for (var x = 0; x < tabs.length; x++)
64 assertTrue(tabs[x].active);
65 }));
66 chrome.tabs.query({active: false}, pass(function(tabs) {
67 assertEq(4-active_tabs.length, tabs.length);
68 for (var x = 0; x < tabs.length; x++)
69 assertFalse(tabs[x].active);
70 }));
71 },
72
73 function queryWindowID() {
74 chrome.tabs.query({windowId: testWindowId}, pass(function(tabs) {
75 assertEq(window_tabs.length, tabs.length);
76 for (var x = 0; x < tabs.length; x++)
77 assertEq(testWindowId, tabs[x].windowId);
78 }));
79 },
80
81 function queryPinned() {
82 chrome.tabs.query({pinned: true}, pass(function(tabs) {
83 assertEq(pinned_tabs.length, tabs.length);
84 for (var x = 0; x < tabs.length; x++)
85 assertTrue(tabs[x].pinned);
86 }));
87 chrome.tabs.query({pinned: false}, pass(function(tabs) {
88 assertEq(4-pinned_tabs.length, tabs.length);
89 for (var x = 0; x < tabs.length; x++)
90 assertFalse(tabs[x].pinned);
91 }));
92 },
93
94 function queryActiveAndWindowID() {
95 chrome.tabs.query({
96 active: true,
97 windowId: testWindowId
98 }, pass(function(tabs) {
99 assertEq(active_and_window_tabs.length, tabs.length);
100 for (var x = 0; x < tabs.length; x++) {
101 assertTrue(tabs[x].active);
102 assertEq(testWindowId, tabs[x].windowId);
103 }
104 }));
105 },
106
107 function queryUrl() {
108 chrome.tabs.query({url: "http://*.example.org/*"}, pass(function(tabs) {
109 assertEq(1, tabs.length);
110 assertEq("http://example.org/a.html", tabs[0].url);
111 }));
112 },
113
114 function queryStatus() {
115 chrome.tabs.query({status: "complete"}, pass(function(tabs) {
116 for (var x = 0; x < tabs.length; x++)
117 assertEq("complete", tabs[x].status);
118 }));
119 },
120
121 function queryTitle() {
122 chrome.tabs.query({title: "*query.html"}, pass(function(tabs) {
123 assertEq(1, tabs.length);
124 assertEq(chrome.extension.getURL("query.html"), tabs[0].title);
125 }));
126 },
127
128 function queryWindowType() {
129 chrome.tabs.query({windowType: "normal"}, pass(function(tabs) {
130 assertEq(4, tabs.length);
131 for (var x = 0; x < tabs.length; x++) {
132 chrome.windows.get(tabs[x].windowId, pass(function(win) {
133 assertTrue(win.type == "normal");
134 }));
135 }
136 }));
137 chrome.windows.create({
138 url: 'about:blank',
139 type: 'popup'
140 }, pass(function(win) {
141 chrome.windows.create({
142 url: 'about:blank',
143 type: 'popup'
144 }, pass(function(win) {
145 chrome.tabs.query({
146 windowId: win.id,
147 windowType: 'popup'
148 }, pass(function(tabs) {
149 assertEq(1, tabs.length);
150 }));
151 chrome.tabs.query({windowType: 'popup'}, pass(function(tabs) {
152 assertEq(2, tabs.length);
153 }));
154 chrome.tabs.query({
155 windowType: 'popup',
156 url: 'about:*'
157 }, pass(function(tabs) {
158 assertEq(2, tabs.length);
159 }));
160 }));
161 }));
162 }
163 ]);
164
165 </script>
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/tabs/basics/pinned.js ('k') | chrome/test/data/extensions/api_test/tabs/basics/query.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698