summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-23 21:22:34 +0000
committerbenjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-23 21:22:34 +0000
commitb8fe4c57d9b2f796d05011e280a91012d46a0f2a (patch)
treef121abfb181b7ac4121c883cf6d147f2c77cd776
parent7077cb86cf428da435b32ba8fa7ba417322f636d (diff)
downloadchromium_src-b8fe4c57d9b2f796d05011e280a91012d46a0f2a.zip
chromium_src-b8fe4c57d9b2f796d05011e280a91012d46a0f2a.tar.gz
chromium_src-b8fe4c57d9b2f796d05011e280a91012d46a0f2a.tar.bz2
Extend downloadInvalidURL tests to test that the following strings are considered invalid URLs. The apitest is still disabled.
'foo bar' '../hello' '/hello' 'google.com/' 'http://' BUG=115342 Review URL: http://codereview.chromium.org/9454018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123333 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/test/data/extensions/api_test/downloads/test.js108
1 files changed, 107 insertions, 1 deletions
diff --git a/chrome/test/data/extensions/api_test/downloads/test.js b/chrome/test/data/extensions/api_test/downloads/test.js
index 39c1049..ba9224d9 100644
--- a/chrome/test/data/extensions/api_test/downloads/test.js
+++ b/chrome/test/data/extensions/api_test/downloads/test.js
@@ -449,13 +449,119 @@ chrome.test.getConfig(function(testConfig) {
{'url': SAFE_FAST_URL, 'headers': 'GOAT'});
},
- function downloadInvalidURL() {
+ function downloadInvalidURL0() {
// Test that download() requires a valid url.
downloads.download(
{'url': 'foo bar'},
chrome.test.callbackFail(downloads.ERROR_INVALID_URL));
},
+ function downloadInvalidURL1() {
+ // Test that download() requires a valid url, including protocol and
+ // hostname.
+ downloads.download(
+ {'url': '../hello'},
+ chrome.test.callbackFail(downloads.ERROR_INVALID_URL));
+ },
+
+ function downloadInvalidURL2() {
+ // Test that download() requires a valid url, including protocol and
+ // hostname.
+ downloads.download(
+ {'url': '/hello'},
+ chrome.test.callbackFail(downloads.ERROR_INVALID_URL));
+ },
+
+ function downloadInvalidURL3() {
+ // Test that download() requires a valid url, including protocol.
+ downloads.download(
+ {'url': 'google.com/'},
+ chrome.test.callbackFail(downloads.ERROR_INVALID_URL));
+ },
+
+ function downloadInvalidURL4() {
+ // Test that download() requires a valid url, including protocol and
+ // hostname.
+ downloads.download(
+ {'url': 'http://'},
+ chrome.test.callbackFail(downloads.ERROR_INVALID_URL));
+ },
+
+ function downloadInvalidURL5() {
+ // Test that download() requires a valid url, including protocol and
+ // hostname.
+ downloads.download(
+ {'url': '#frag'},
+ chrome.test.callbackFail(downloads.ERROR_INVALID_URL));
+ },
+
+ function downloadInvalidURL6() {
+ // Test that download() requires a valid url, including protocol and
+ // hostname.
+ downloads.download(
+ {'url': 'foo/bar.html#frag'},
+ chrome.test.callbackFail(downloads.ERROR_INVALID_URL));
+ },
+
+ function downloadAllowFragments() {
+ // Valid URLs plus fragments are still valid URLs.
+ var downloadId = getNextId();
+ console.log(downloadId);
+ downloads.download(
+ {'url': SAFE_FAST_URL + '#frag'},
+ chrome.test.callback(function(id) {
+ chrome.test.assertEq(downloadId, id);
+ }));
+ },
+
+ function downloadAllowDataURLs() {
+ // Valid data URLs are valid URLs.
+ var downloadId = getNextId();
+ console.log(downloadId);
+ downloads.download(
+ {'url': 'data:text/plain,hello'},
+ chrome.test.callback(function(id) {
+ chrome.test.assertEq(downloadId, id);
+ }));
+ },
+
+ function downloadAllowFileURLs() {
+ // Valid file URLs are valid URLs.
+ var downloadId = getNextId();
+ console.log(downloadId);
+ downloads.download(
+ {'url': 'file:///'},
+ chrome.test.callback(function(id) {
+ chrome.test.assertEq(downloadId, id);
+ }));
+ },
+
+ // TODO(benjhayden): Set up a test ftp server.
+ // function downloadAllowFTPURLs() {
+ // // Valid ftp URLs are valid URLs.
+ // var downloadId = getNextId();
+ // console.log(downloadId);
+ // downloads.download(
+ // {'url': 'ftp://localhost:' + testConfig.testServer.port + '/'},
+ // chrome.test.callback(function(id) {
+ // chrome.test.assertEq(downloadId, id);
+ // }));
+ // },
+
+ function downloadInvalidURL7() {
+ // Test that download() rejects javascript urls.
+ downloads.download(
+ {'url': 'javascript:document.write("hello");'},
+ chrome.test.callbackFail('net::ERR_ACCESS_DENIED'));
+ },
+
+ function downloadInvalidURL8() {
+ // Test that download() rejects javascript urls.
+ downloads.download(
+ {'url': 'javascript:return false;'},
+ chrome.test.callbackFail('net::ERR_ACCESS_DENIED'));
+ },
+
function downloadInvalidMethod() {
assertThrows(('Invalid value for argument 1. Property \'method\': ' +
'Value must be one of: [GET, POST].'),