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

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

Issue 569803004: Allow "url" to be an array of URL patterns (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tabs.query documentation Created 6 years, 3 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
« no previous file with comments | « chrome/common/extensions/api/tabs.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var testWindowId; 5 var testWindowId;
6 var active_tabs = []; 6 var active_tabs = [];
7 var highlighted_tabs = []; 7 var highlighted_tabs = [];
8 var window_tabs = []; 8 var window_tabs = [];
9 var pinned_tabs = []; 9 var pinned_tabs = [];
10 var active_and_window_tabs = []; 10 var active_and_window_tabs = [];
11 11
12 chrome.test.runTests([ 12 chrome.test.runTests([
13 function setup() { 13 function setup() {
14 var tabs = ['http://example.org/a.html', 'http://google.com']; 14 var tabs = ['http://example.org/a.html', 'http://www.google.com/favicon.ico' ];
15 chrome.windows.create({url: tabs}, pass(function(window) { 15 chrome.windows.create({url: tabs}, pass(function(window) {
16 assertEq(2, window.tabs.length); 16 assertEq(2, window.tabs.length);
17 testWindowId = window.id; 17 testWindowId = window.id;
18 chrome.tabs.create({ 18 chrome.tabs.create({
19 windowId: testWindowId, 19 windowId: testWindowId,
20 url: 'about:blank', 20 url: 'about:blank',
21 pinned: true 21 pinned: true
22 }, pass(function(tab) { 22 }, pass(function(tab) {
23 assertTrue(tab.pinned); 23 assertTrue(tab.pinned);
24 assertEq(testWindowId, tab.windowId); 24 assertEq(testWindowId, tab.windowId);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 })); 118 }));
119 }, 119 },
120 120
121 function queryUrl() { 121 function queryUrl() {
122 chrome.tabs.query({url: "http://*.example.org/*"}, pass(function(tabs) { 122 chrome.tabs.query({url: "http://*.example.org/*"}, pass(function(tabs) {
123 assertEq(1, tabs.length); 123 assertEq(1, tabs.length);
124 assertEq("http://example.org/a.html", tabs[0].url); 124 assertEq("http://example.org/a.html", tabs[0].url);
125 })); 125 }));
126 }, 126 },
127 127
128 function queryUrlAsArray() {
129 chrome.tabs.query({url: ["http://*.example.org/*"]}, pass(function(tabs) {
130 assertEq(1, tabs.length);
131 assertEq("http://example.org/a.html", tabs[0].url);
132 }));
133 },
134
135 function queryUrlAsArray2() {
136 chrome.tabs.query({url: ["http://*.example.org/*", "*://*.google.com/*"]}, p ass(function(tabs) {
137 assertEq(2, tabs.length);
138 assertEq("http://example.org/a.html", tabs[0].url);
139 assertEq("http://www.google.com/favicon.ico", tabs[1].url);
140 }));
141 },
142
128 function queryStatus() { 143 function queryStatus() {
129 chrome.tabs.query({status: "complete"}, pass(function(tabs) { 144 chrome.tabs.query({status: "complete"}, pass(function(tabs) {
130 for (var x = 0; x < tabs.length; x++) 145 for (var x = 0; x < tabs.length; x++)
131 assertEq("complete", tabs[x].status); 146 assertEq("complete", tabs[x].status);
132 })); 147 }));
133 }, 148 },
134 149
135 function queryTitle() { 150 function queryTitle() {
136 chrome.tabs.query({title: "*query.html"}, pass(function(tabs) { 151 chrome.tabs.query({title: "*query.html"}, pass(function(tabs) {
137 assertEq(1, tabs.length); 152 assertEq(1, tabs.length);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 {url: ['http://a.com', 'http://a.com'], incognito: true}, 205 {url: ['http://a.com', 'http://a.com'], incognito: true},
191 pass(function(win) { 206 pass(function(win) {
192 assertEq(null, win); 207 assertEq(null, win);
193 chrome.tabs.query({url: 'http://a.com/'}, pass(function(tabs) { 208 chrome.tabs.query({url: 'http://a.com/'}, pass(function(tabs) {
194 assertEq(0, tabs.length); 209 assertEq(0, tabs.length);
195 })); 210 }));
196 })); 211 }));
197 } 212 }
198 ]); 213 ]);
199 214
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/tabs.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698