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

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

Issue 8203005: Implement chrome.experimental.downloads.onChanged (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: comments 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 | Annotate | Revision Log
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 // downloads api test 5 // downloads api test
6 // browser_tests.exe --gtest_filter=DownloadsApiTest.Downloads 6 // browser_tests.exe --gtest_filter=DownloadsApiTest.Downloads
7 7
8 var downloads = chrome.experimental.downloads; 8 var downloads = chrome.experimental.downloads;
9 9
10 chrome.test.getConfig(function(testConfig) { 10 chrome.test.getConfig(function(testConfig) {
(...skipping 25 matching lines...) Expand all
36 func.apply(null, args); 36 func.apply(null, args);
37 } catch (exception) { 37 } catch (exception) {
38 chrome.test.assertEq(exceptionMessage, exception.message); 38 chrome.test.assertEq(exceptionMessage, exception.message);
39 chrome.test.succeed(); 39 chrome.test.succeed();
40 } 40 }
41 } 41 }
42 42
43 // The "/slow" handler waits a specified amount of time before returning a 43 // The "/slow" handler waits a specified amount of time before returning a
44 // safe file. Specify zero seconds to return quickly. 44 // safe file. Specify zero seconds to return quickly.
45 var SAFE_FAST_URL = getURL('slow?0'); 45 var SAFE_FAST_URL = getURL('slow?0');
46
46 var NEVER_FINISH_URL = getURL('download-known-size'); 47 var NEVER_FINISH_URL = getURL('download-known-size');
47 var ERROR_GENERIC = downloads.ERROR_GENERIC; 48
48 var ERROR_INVALID_URL = downloads.ERROR_INVALID_URL; 49 // This URL should only work with the POST method and a request body
49 var ERROR_INVALID_OPERATION = downloads.ERROR_INVALID_OPERATION; 50 // containing 'BODY'.
51 var POST_URL = getURL('files/post/downloads/a_zip_file.zip?' +
52 'expected_body=BODY');
53
54 // This URL should only work with headers 'Foo: bar' and 'Qx: yo'.
55 var HEADERS_URL = getURL('files/downloads/a_zip_file.zip?' +
56 'expected_headers=Foo:bar&expected_headers=Qx:yo');
50 57
51 chrome.test.runTests([ 58 chrome.test.runTests([
52 // TODO(benjhayden): Test onErased using remove(). 59 // TODO(benjhayden): Test onErased using remove().
60
61 // TODO(benjhayden): Sub-directories depend on http://crbug.com/109443
62 // TODO(benjhayden): Windows slashes.
63 // function downloadSubDirectoryFilename() {
64 // var downloadId = getNextId();
65 // var callbackCompleted = chrome.test.callbackAdded();
66 // function myListener(delta) {
67 // if ((delta.id != downloadId) ||
68 // !delta.filename ||
69 // (delta.filename.new.indexOf('/foo/slow') == -1))
70 // return;
71 // downloads.onChanged.removeListener(myListener);
72 // callbackCompleted();
73 // }
74 // downloads.onChanged.addListener(myListener);
75 // downloads.download(
76 // {'url': SAFE_FAST_URL, 'filename': 'foo/slow'},
77 // chrome.test.callback(function(id) {
78 // chrome.test.assertEq(downloadId, id);
79 // }));
80 // },
81
82 function downloadSimple() {
83 // Test that we can begin a download.
84 var downloadId = getNextId();
85 downloads.download(
86 {'url': SAFE_FAST_URL},
87 chrome.test.callback(function(id) {
88 chrome.test.assertEq(downloadId, id);
89 }));
90 },
91
92 function downloadPostSuccess() {
93 // Test the |method| download option.
94 var downloadId = getNextId();
95 var changedCompleted = chrome.test.callbackAdded();
96 function changedListener(delta) {
97 // Ignore onChanged events for downloads besides our own, or events that
98 // signal any change besides completion.
99 if ((delta.id != downloadId) ||
100 !delta.state ||
101 (delta.state.new != downloads.STATE_COMPLETE))
102 return;
103 downloads.search({id: downloadId},
104 chrome.test.callback(function(items) {
105 chrome.test.assertEq(1, items.length);
106 chrome.test.assertEq(downloadId, items[0].id);
107 var EXPECTED_SIZE = 164;
108 chrome.test.assertEq(EXPECTED_SIZE, items[0].totalBytes);
109 chrome.test.assertEq(EXPECTED_SIZE, items[0].fileSize);
110 chrome.test.assertEq(EXPECTED_SIZE, items[0].bytesReceived);
111 }));
112 downloads.onChanged.removeListener(changedListener);
113 changedCompleted();
114 }
115 downloads.onChanged.addListener(changedListener);
116
117 downloads.download(
118 {'url': POST_URL,
119 'method': 'POST',
120 'filename': downloadId + '.txt',
121 'body': 'BODY'},
122 chrome.test.callback(function(id) {
123 chrome.test.assertEq(downloadId, id);
124 }));
125 },
126
127 function downloadPostWouldFailWithoutMethod() {
128 // Test that downloadPostSuccess would fail if the resource requires the
129 // POST method, and chrome fails to propagate the |method| parameter back
130 // to the server. This tests both that testserver.py does not succeed when
131 // it should fail, and this tests how the downloads extension api exposes
132 // the failure to extensions.
133 var downloadId = getNextId();
134
135 var changedCompleted = chrome.test.callbackAdded();
136 function changedListener(delta) {
137 // Ignore onChanged events for downloads besides our own, or events that
138 // signal any change besides interruption.
139 if ((delta.id != downloadId) ||
140 !delta.state ||
141 (delta.state.new != downloads.STATE_COMPLETE))
142 return;
143 // TODO(benjhayden): Change COMPLETE to INTERRUPTED after
144 // http://crbug.com/112342
145 downloads.search({id: downloadId},
146 chrome.test.callback(function(items) {
147 chrome.test.assertEq(1, items.length);
148 chrome.test.assertEq(downloadId, items[0].id);
149 chrome.test.assertEq(0, items[0].totalBytes);
150 }));
151 downloads.onChanged.removeListener(changedListener);
152 changedCompleted();
153 }
154 downloads.onChanged.addListener(changedListener);
155
156 downloads.download(
157 {'url': POST_URL,
158 'filename': downloadId + '.txt', // Prevent 'file' danger.
159 'body': 'BODY'},
160 chrome.test.callback(function(id) {
161 chrome.test.assertEq(downloadId, id);
162 }));
163 },
164
165 function downloadPostWouldFailWithoutBody() {
166 // Test that downloadPostSuccess would fail if the resource requires the
167 // POST method and a request body, and chrome fails to propagate the
168 // |body| parameter back to the server. This tests both that testserver.py
169 // does not succeed when it should fail, and this tests how the downloads
170 // extension api exposes the failure to extensions.
171 var downloadId = getNextId();
172
173 var changedCompleted = chrome.test.callbackAdded();
174 function changedListener(delta) {
175 // Ignore onChanged events for downloads besides our own, or events that
176 // signal any change besides interruption.
177 if ((delta.id != downloadId) ||
178 !delta.state ||
179 (delta.state.new != downloads.STATE_COMPLETE))
180 return;
181 // TODO(benjhayden): Change COMPLETE to INTERRUPTED after
182 // http://crbug.com/112342
183 downloads.search({id: downloadId},
184 chrome.test.callback(function(items) {
185 chrome.test.assertEq(1, items.length);
186 chrome.test.assertEq(downloadId, items[0].id);
187 chrome.test.assertEq(0, items[0].totalBytes);
188 }));
189 downloads.onChanged.removeListener(changedListener);
190 changedCompleted();
191 }
192 downloads.onChanged.addListener(changedListener);
193
194 downloads.download(
195 {'url': POST_URL,
196 'filename': downloadId + '.txt', // Prevent 'file' danger.
197 'method': 'POST'},
198 chrome.test.callback(function(id) {
199 chrome.test.assertEq(downloadId, id);
200 }));
201 },
202
203 function downloadHeadersSuccess() {
204 // Test the |header| download option.
205 var downloadId = getNextId();
206 var changedCompleted = chrome.test.callbackAdded();
207 function changedListener(delta) {
208 // Ignore onChanged events for downloads besides our own, or events that
209 // signal any change besides completion.
210 if ((delta.id != downloadId) ||
211 !delta.state ||
212 (delta.state.new != downloads.STATE_COMPLETE))
213 return;
214 downloads.search({id: downloadId},
215 chrome.test.callback(function(items) {
216 chrome.test.assertEq(1, items.length);
217 chrome.test.assertEq(downloadId, items[0].id);
218 var EXPECTED_SIZE = 164;
219 chrome.test.assertEq(EXPECTED_SIZE, items[0].totalBytes);
220 chrome.test.assertEq(EXPECTED_SIZE, items[0].fileSize);
221 chrome.test.assertEq(EXPECTED_SIZE, items[0].bytesReceived);
222 }));
223 downloads.onChanged.removeListener(changedListener);
224 changedCompleted();
225 }
226 downloads.onChanged.addListener(changedListener);
227
228 downloads.download(
229 {'url': HEADERS_URL,
230 'filename': downloadId + '.txt', // Prevent 'file' danger.
231 'headers': [{'name': 'Foo', 'value': 'bar'},
232 {'name': 'Qx', 'value': 'yo'}]},
233 chrome.test.callback(function(id) {
234 chrome.test.assertEq(downloadId, id);
235 }));
236 },
237
238 function downloadHeadersWouldFail() {
239 // Test that downloadHeadersSuccess() would fail if the resource requires
240 // the headers, and chrome fails to propagate them back to the server.
241 // This tests both that testserver.py does not succeed when it should
242 // fail as well as how the downloads extension api exposes the
243 // failure to extensions.
244 var downloadId = getNextId();
245
246 var changedCompleted = chrome.test.callbackAdded();
247 function changedListener(delta) {
248 // Ignore onChanged events for downloads besides our own, or events that
249 // signal any change besides interruption.
250 if ((delta.id != downloadId) ||
251 !delta.state ||
252 (delta.state.new != downloads.STATE_COMPLETE))
253 return;
254 // TODO(benjhayden): Change COMPLETE to INTERRUPTED after
255 // http://crbug.com/112342
256 downloads.search({id: downloadId},
257 chrome.test.callback(function(items) {
258 chrome.test.assertEq(1, items.length);
259 chrome.test.assertEq(downloadId, items[0].id);
260 chrome.test.assertEq(0, items[0].totalBytes);
261 }));
262 downloads.onChanged.removeListener(changedListener);
263 changedCompleted();
264 }
265 downloads.onChanged.addListener(changedListener);
266
267 downloads.download(
268 {'url': HEADERS_URL},
269 chrome.test.callback(function(id) {
270 chrome.test.assertEq(downloadId, id);
271 }));
272 },
273
274 function downloadInterrupted() {
275 // Test that cancel()ing an in-progress download causes its state to
276 // transition to interrupted, and test that that state transition is
277 // detectable by an onChanged event listener.
278 // TODO(benjhayden): Test other sources of interruptions such as server
279 // death.
280 var downloadId = getNextId();
281
282 var createdCompleted = chrome.test.callbackAdded();
283 function createdListener(createdItem) {
284 // Ignore onCreated events for any download besides our own.
285 if (createdItem.id != downloadId)
286 return;
287 // TODO(benjhayden) Move this cancel() into the download() callback
288 // after ensuring that DownloadItems are created before that callback
289 // is fired.
290 downloads.cancel(downloadId, chrome.test.callback(function() {
291 }));
292 downloads.onCreated.removeListener(createdListener);
293 createdCompleted();
294 }
295 downloads.onCreated.addListener(createdListener);
296
297 var changedCompleted = chrome.test.callbackAdded();
298 function changedListener(delta) {
299 // Ignore onChanged events for downloads besides our own, or events that
300 // signal any change besides interruption.
301 if ((delta.id != downloadId) ||
302 !delta.state ||
303 (delta.state.new != downloads.STATE_INTERRUPTED) ||
304 !delta.error ||
305 (delta.error.new != 40))
306 return;
307 downloads.onChanged.removeListener(changedListener);
308 changedCompleted();
309 }
310 downloads.onChanged.addListener(changedListener);
311
312 downloads.download(
313 {'url': NEVER_FINISH_URL},
314 chrome.test.callback(function(id) {
315 chrome.test.assertEq(downloadId, id);
316 }));
317 },
318
319 function downloadOnChanged() {
320 // Test that download completion is detectable by an onChanged event
321 // listener.
322 var downloadId = getNextId();
323 var callbackCompleted = chrome.test.callbackAdded();
324 function myListener(delta) {
325 if ((delta.id != downloadId) ||
326 !delta.state ||
327 (delta.state.new != downloads.STATE_COMPLETE))
328 return;
329 downloads.onChanged.removeListener(myListener);
330 callbackCompleted();
331 }
332 downloads.onChanged.addListener(myListener);
333 downloads.download(
334 {"url": SAFE_FAST_URL},
335 chrome.test.callback(function(id) {
336 chrome.test.assertEq(downloadId, id);
337 }));
338 },
339
53 function downloadFilename() { 340 function downloadFilename() {
54 downloads.download( 341 // Test that we can suggest a filename for a new download, and test that
55 {'url': SAFE_FAST_URL, 'filename': 'foo'}, 342 // we can detect filename changes with an onChanged event listener.
56 chrome.test.callbackPass(function(id) { 343 var FILENAME = 'owiejtoiwjrfoiwjroiwjroiwjroiwjrfi';
57 chrome.test.assertEq(getNextId(), id); 344 var downloadId = getNextId();
58 })); 345 var callbackCompleted = chrome.test.callbackAdded();
59 // TODO(benjhayden): Test the filename using onChanged. 346 function myListener(delta) {
60 }, 347 if ((delta.id != downloadId) ||
348 !delta.filename ||
349 (delta.filename.new.indexOf(FILENAME) == -1))
350 return;
351 downloads.onChanged.removeListener(myListener);
352 callbackCompleted();
353 }
354 downloads.onChanged.addListener(myListener);
355 downloads.download(
356 {'url': SAFE_FAST_URL, 'filename': FILENAME},
357 chrome.test.callback(function(id) {
358 chrome.test.assertEq(downloadId, id);
359 }));
360 },
361
61 function downloadOnCreated() { 362 function downloadOnCreated() {
62 chrome.test.listenOnce(downloads.onCreated, 363 // Test that the onCreated event fires when we start a download.
63 chrome.test.callbackPass(function(item) {})); 364 var downloadId = getNextId();
365 var createdCompleted = chrome.test.callbackAdded();
366 function createdListener(item) {
367 if (item.id == downloadId) {
368 createdCompleted();
369 downloads.onCreated.removeListener(createdListener);
370 }
371 };
372 downloads.onCreated.addListener(createdListener);
64 downloads.download( 373 downloads.download(
65 {'url': SAFE_FAST_URL}, 374 {'url': SAFE_FAST_URL},
66 function(id) { 375 chrome.test.callback(function(id) {
67 chrome.test.assertEq(getNextId(), id); 376 chrome.test.assertEq(downloadId, id);
68 }); 377 }));
69 }, 378 },
70 function downloadSubDirectoryFilename() { 379
71 downloads.download(
72 {'url': SAFE_FAST_URL, 'filename': 'foo/slow'},
73 chrome.test.callbackPass(function(id) {
74 chrome.test.assertEq(getNextId(), id);
75 }));
76 // TODO(benjhayden): Test the filename using onChanged.
77 },
78 function downloadInvalidFilename() { 380 function downloadInvalidFilename() {
381 // Test that we disallow invalid filenames for new downloads.
79 downloads.download( 382 downloads.download(
80 {'url': SAFE_FAST_URL, 'filename': '../../../../../etc/passwd'}, 383 {'url': SAFE_FAST_URL, 'filename': '../../../../../etc/passwd'},
81 chrome.test.callbackFail(ERROR_GENERIC)); 384 chrome.test.callbackFail(downloads.ERROR_GENERIC));
82 // TODO(benjhayden): Give a better error message. 385 },
83 }, 386
84 function downloadEmpty() { 387 function downloadEmpty() {
85 assertThrows(('Invalid value for argument 1. Property \'url\': ' + 388 assertThrows(('Invalid value for argument 1. Property \'url\': ' +
86 'Property is required.'), 389 'Property is required.'),
87 downloads.download, {}); 390 downloads.download, {});
88 }, 391 },
392
89 function downloadInvalidSaveAs() { 393 function downloadInvalidSaveAs() {
90 assertThrows(('Invalid value for argument 1. Property \'saveAs\': ' + 394 assertThrows(('Invalid value for argument 1. Property \'saveAs\': ' +
91 'Expected \'boolean\' but got \'string\'.'), 395 'Expected \'boolean\' but got \'string\'.'),
92 downloads.download, 396 downloads.download,
93 {'url': SAFE_FAST_URL, 'saveAs': 'GOAT'}); 397 {'url': SAFE_FAST_URL, 'saveAs': 'GOAT'});
94 }, 398 },
399
95 function downloadInvalidHeadersOption() { 400 function downloadInvalidHeadersOption() {
96 assertThrows(('Invalid value for argument 1. Property \'headers\': ' + 401 assertThrows(('Invalid value for argument 1. Property \'headers\': ' +
97 'Expected \'array\' but got \'string\'.'), 402 'Expected \'array\' but got \'string\'.'),
98 downloads.download, 403 downloads.download,
99 {'url': SAFE_FAST_URL, 'headers': 'GOAT'}); 404 {'url': SAFE_FAST_URL, 'headers': 'GOAT'});
100 }, 405 },
406
101 function downloadInvalidURL() { 407 function downloadInvalidURL() {
408 // Test that download() requires a valid url.
102 downloads.download( 409 downloads.download(
103 {'url': 'foo bar'}, 410 {'url': 'foo bar'},
104 chrome.test.callbackFail(ERROR_INVALID_URL)); 411 chrome.test.callbackFail(downloads.ERROR_INVALID_URL));
105 }, 412 },
413
106 function downloadInvalidMethod() { 414 function downloadInvalidMethod() {
107 assertThrows(('Invalid value for argument 1. Property \'method\': ' + 415 assertThrows(('Invalid value for argument 1. Property \'method\': ' +
108 'Value must be one of: [GET, POST].'), 416 'Value must be one of: [GET, POST].'),
109 downloads.download, 417 downloads.download,
110 {'url': SAFE_FAST_URL, 'method': 'GOAT'}); 418 {'url': SAFE_FAST_URL, 'method': 'GOAT'});
111 }, 419 },
112 function downloadSimple() { 420
113 downloads.download(
114 {'url': SAFE_FAST_URL},
115 chrome.test.callbackPass(function(id) {
116 chrome.test.assertEq(getNextId(), id);
117 }));
118 },
119 function downloadPost() {
120 downloads.download(
121 {'url': getURL('files/post/downloads/a_zip_file.js'),
122 'method': 'POST',
123 'body': 'WOOHOO'},
124 chrome.test.callbackPass(function(id) {
125 chrome.test.assertEq(getNextId(), id);
126 }));
127 },
128 function downloadHeader() {
129 downloads.download(
130 {'url': SAFE_FAST_URL,
131 'headers': [{'name': 'Foo', 'value': 'bar'}]
132 },
133 chrome.test.callbackPass(function(id) {
134 chrome.test.assertEq(getNextId(), id);
135 }));
136 },
137 function downloadInterrupted() {
138 // TODO(benjhayden): Find a suitable URL and test that this id is
139 // eventually interrupted using onChanged.
140 downloads.download(
141 {'url': SAFE_FAST_URL},
142 chrome.test.callbackPass(function(id) {
143 chrome.test.assertEq(getNextId(), id);
144 }));
145 },
146 function downloadInvalidHeader() { 421 function downloadInvalidHeader() {
422 // Test that download() disallows setting the Cookie header.
147 downloads.download( 423 downloads.download(
148 {'url': SAFE_FAST_URL, 424 {'url': SAFE_FAST_URL,
149 'headers': [{ 'name': 'Cookie', 'value': 'fake'}] 425 'headers': [{ 'name': 'Cookie', 'value': 'fake'}]
150 }, 426 },
151 chrome.test.callbackFail(ERROR_GENERIC)); 427 chrome.test.callbackFail(downloads.ERROR_GENERIC));
152 // TODO(benjhayden): Give a better error message. 428 },
153 }, 429
154 function downloadGetFileIconInvalidOptions() { 430 function downloadGetFileIconInvalidOptions() {
155 assertThrows(('Invalid value for argument 2. Property \'cat\': ' + 431 assertThrows(('Invalid value for argument 2. Property \'cat\': ' +
156 'Unexpected property.'), 432 'Unexpected property.'),
157 downloads.getFileIcon, 433 downloads.getFileIcon,
158 -1, {cat: 'mouse'}); 434 -1, {cat: 'mouse'});
159 }, 435 },
436
160 function downloadGetFileIconInvalidSize() { 437 function downloadGetFileIconInvalidSize() {
161 assertThrows(('Invalid value for argument 2. Property \'size\': ' + 438 assertThrows(('Invalid value for argument 2. Property \'size\': ' +
162 'Value must be one of: [16, 32].'), 439 'Value must be one of: [16, 32].'),
163 downloads.getFileIcon, -1, {size: 31}); 440 downloads.getFileIcon, -1, {size: 31});
164 }, 441 },
442
165 function downloadGetFileIconInvalidId() { 443 function downloadGetFileIconInvalidId() {
166 downloads.getFileIcon(-42, {size: 32}, 444 downloads.getFileIcon(-42, {size: 32},
167 chrome.test.callbackFail(ERROR_INVALID_OPERATION)); 445 chrome.test.callbackFail(downloads.ERROR_INVALID_OPERATION));
168 }, 446 },
169 function downloadNoComplete() { 447
170 // This is used partly to test cleanUp.
171 downloads.download(
172 {'url': NEVER_FINISH_URL},
173 chrome.test.callbackPass(function(id) {
174 chrome.test.assertEq(getNextId(), id);
175 }));
176 },
177 function downloadPauseInvalidId() { 448 function downloadPauseInvalidId() {
178 downloads.pause(-42, chrome.test.callbackFail(ERROR_INVALID_OPERATION)); 449 downloads.pause(-42, chrome.test.callbackFail(
179 }, 450 downloads.ERROR_INVALID_OPERATION));
451 },
452
180 function downloadPauseInvalidType() { 453 function downloadPauseInvalidType() {
181 assertThrows(('Invalid value for argument 1. Expected \'integer\' ' + 454 assertThrows(('Invalid value for argument 1. Expected \'integer\' ' +
182 'but got \'string\'.'), 455 'but got \'string\'.'),
183 downloads.pause, 456 downloads.pause,
184 'foo'); 457 'foo');
185 }, 458 },
459
186 function downloadResumeInvalidId() { 460 function downloadResumeInvalidId() {
187 downloads.resume(-42, chrome.test.callbackFail(ERROR_INVALID_OPERATION)); 461 downloads.resume(-42, chrome.test.callbackFail(
188 }, 462 downloads.ERROR_INVALID_OPERATION));
463 },
464
189 function downloadResumeInvalidType() { 465 function downloadResumeInvalidType() {
190 assertThrows(('Invalid value for argument 1. Expected \'integer\' ' + 466 assertThrows(('Invalid value for argument 1. Expected \'integer\' ' +
191 'but got \'string\'.'), 467 'but got \'string\'.'),
192 downloads.resume, 468 downloads.resume,
193 'foo'); 469 'foo');
194 }, 470 },
471
195 function downloadCancelInvalidId() { 472 function downloadCancelInvalidId() {
196 // Canceling a non-existent download is not considered an error. 473 // Canceling a non-existent download is not considered an error.
197 downloads.cancel(-42, chrome.test.callbackPass(function() {})); 474 downloads.cancel(-42, chrome.test.callback(function() {}));
198 }, 475 },
476
199 function downloadCancelInvalidType() { 477 function downloadCancelInvalidType() {
200 assertThrows(('Invalid value for argument 1. Expected \'integer\' ' + 478 assertThrows(('Invalid value for argument 1. Expected \'integer\' ' +
201 'but got \'string\'.'), 479 'but got \'string\'.'),
202 downloads.cancel, 'foo'); 480 downloads.cancel, 'foo');
203 }, 481 },
482
483 function downloadNoComplete() {
484 // This is used partly to test cleanUp.
485 var downloadId = getNextId();
486 downloads.download(
487 {'url': NEVER_FINISH_URL},
488 chrome.test.callback(function(id) {
489 chrome.test.assertEq(downloadId, id);
490 }));
491 },
492
204 function cleanUp() { 493 function cleanUp() {
205 // cleanUp must come last. It clears out all in-progress downloads 494 // cleanUp must come last. It clears out all in-progress downloads
206 // so the browser can shutdown cleanly. 495 // so the browser can shutdown cleanly.
207 for (var id = 0; id < nextId; ++id) { 496 for (var id = 0; id < nextId; ++id) {
208 downloads.cancel(id, chrome.test.callbackPass(function() {})); 497 downloads.cancel(id, chrome.test.callback(function() {}));
209 } 498 }
210 } 499 }
211 ]); 500 ]);
212 }); 501 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698