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

Unified Diff: chrome/test/data/extensions/api_test/downloads/test.js

Issue 8060042: Add downloads.onCreated apitest and fix a few bugs (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merge Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/download/download_request_handle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/downloads/test.js
diff --git a/chrome/test/data/extensions/api_test/downloads/test.js b/chrome/test/data/extensions/api_test/downloads/test.js
index c227f3277cd8b2c3e0c0830f05fd32d9a2e01ea7..dd04343f738a4068cf4157c933b76237ae9f4b3d 100644
--- a/chrome/test/data/extensions/api_test/downloads/test.js
+++ b/chrome/test/data/extensions/api_test/downloads/test.js
@@ -9,6 +9,7 @@ chrome.test.getConfig(function(testConfig) {
function getURL(path) {
return "http://localhost:" + testConfig.testServer.port + "/" + path;
}
+
var nextId = 0;
function getNextId() {
return nextId++;
@@ -29,18 +30,33 @@ chrome.test.getConfig(function(testConfig) {
}
}
+ // The "/slow" handler waits a specified amount of time before returning a
+ // safe file. Specify zero seconds to return quickly.
+ var SAFE_FAST_URL = getURL("slow?0");
+
chrome.test.runTests([
+ // TODO(benjhayden): Test onErased using remove().
function downloadFilename() {
chrome.experimental.downloads.download(
- {"url": getURL("pass"), "filename": "pass"},
+ {"url": SAFE_FAST_URL, "filename": "foo"},
chrome.test.callbackPass(function(id) {
chrome.test.assertEq(getNextId(), id);
}));
// TODO(benjhayden): Test the filename using onChanged.
},
+ function downloadOnCreated() {
+ chrome.test.listenOnce(chrome.experimental.downloads.onCreated,
+ chrome.test.callbackPass(function(item) {
+ }));
+ chrome.experimental.downloads.download(
+ {"url": SAFE_FAST_URL},
+ function(id) {
+ chrome.test.assertEq(getNextId(), id);
+ });
+ },
function downloadSubDirectoryFilename() {
chrome.experimental.downloads.download(
- {"url": getURL("pass"), "filename": "foo/pass"},
+ {"url": SAFE_FAST_URL, "filename": "foo/slow"},
chrome.test.callbackPass(function(id) {
chrome.test.assertEq(getNextId(), id);
}));
@@ -48,7 +64,7 @@ chrome.test.getConfig(function(testConfig) {
},
function downloadInvalidFilename() {
chrome.experimental.downloads.download(
- {"url": getURL("pass"), "filename": "../../../../../etc/passwd"},
+ {"url": SAFE_FAST_URL, "filename": "../../../../../etc/passwd"},
chrome.test.callbackFail("I'm afraid I can't do that."));
// TODO(benjhayden): Give a better error message.
},
@@ -59,13 +75,13 @@ chrome.test.getConfig(function(testConfig) {
},
function downloadInvalidSaveAs() {
assertThrows(chrome.experimental.downloads.download,
- {"url": getURL("pass"), "saveAs": "GOAT"},
+ {"url": SAFE_FAST_URL, "saveAs": "GOAT"},
("Invalid value for argument 1. Property 'saveAs': " +
"Expected 'boolean' but got 'string'."));
},
function downloadInvalidHeadersOption() {
assertThrows(chrome.experimental.downloads.download,
- {"url": getURL("pass"), "headers": "GOAT"},
+ {"url": SAFE_FAST_URL, "headers": "GOAT"},
("Invalid value for argument 1. Property 'headers': " +
"Expected 'array' but got 'string'."));
},
@@ -76,37 +92,37 @@ chrome.test.getConfig(function(testConfig) {
},
function downloadInvalidMethod() {
assertThrows(chrome.experimental.downloads.download,
- {"url": getURL("pass"), "method": "GOAT"},
+ {"url": SAFE_FAST_URL, "method": "GOAT"},
("Invalid value for argument 1. Property 'method': " +
"Value must be one of: [GET, POST]."));
},
function downloadSimple() {
chrome.experimental.downloads.download(
- {"url": getURL("pass")},
+ {"url": SAFE_FAST_URL},
chrome.test.callbackPass(function(id) {
chrome.test.assertEq(getNextId(), id);
}));
},
function downloadHeader() {
chrome.experimental.downloads.download(
- {"url": getURL("pass"),
+ {"url": SAFE_FAST_URL,
"headers": [{"name": "Foo", "value": "bar"}]},
chrome.test.callbackPass(function(id) {
chrome.test.assertEq(getNextId(), id);
}));
},
function downloadInterrupted() {
+ // TODO(benjhayden): Find a suitable URL and test that this id is
+ // eventually interrupted using onChanged.
chrome.experimental.downloads.download(
- {"url": getURL("compressedfiles/Picture_1.doc?L")},
+ {"url": SAFE_FAST_URL},
chrome.test.callbackPass(function(id) {
chrome.test.assertEq(getNextId(), id);
- // TODO(benjhayden): Test that this id is eventually interrupted using
- // onChanged.
}));
},
function downloadInvalidHeader() {
chrome.experimental.downloads.download(
- {"url": getURL("pass"),
+ {"url": SAFE_FAST_URL,
"headers": [{"name": "Cookie", "value": "fake"}]},
chrome.test.callbackFail("I'm afraid I can't do that."));
// TODO(benjhayden): Give a better error message.
« no previous file with comments | « no previous file | content/browser/download/download_request_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698