diff options
author | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-03 01:44:41 +0000 |
---|---|---|
committer | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-03 01:44:41 +0000 |
commit | 4b9a90b937b866d2f1eac86bf00989de383de76f (patch) | |
tree | 0afbbdfe7aef5fe9c1a8f3c44d8dfa43eb7e1322 /chrome | |
parent | 1929803617789ef92dd77f3a8bfd8569f8a76964 (diff) | |
download | chromium_src-4b9a90b937b866d2f1eac86bf00989de383de76f.zip chromium_src-4b9a90b937b866d2f1eac86bf00989de383de76f.tar.gz chromium_src-4b9a90b937b866d2f1eac86bf00989de383de76f.tar.bz2 |
test http auth-basic handling and implement headers.binaryValue for downloads.download()
BUG=115629
Review URL: http://codereview.chromium.org/9460010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124814 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/download/download_extension_api.cc | 42 | ||||
-rw-r--r-- | chrome/test/data/extensions/api_test/downloads/test.js | 420 |
2 files changed, 341 insertions, 121 deletions
diff --git a/chrome/browser/download/download_extension_api.cc b/chrome/browser/download/download_extension_api.cc index 0f92f2b..a80780c 100644 --- a/chrome/browser/download/download_extension_api.cc +++ b/chrome/browser/download/download_extension_api.cc @@ -44,6 +44,7 @@ #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/public/browser/download_item.h" #include "content/public/browser/render_process_host.h" +#include "net/base/load_flags.h" #include "net/http/http_util.h" #include "net/url_request/url_request.h" @@ -89,6 +90,7 @@ const char kFilenameKey[] = "filename"; const char kFilenameRegexKey[] = "filenameRegex"; const char kHeaderNameKey[] = "name"; const char kHeaderValueKey[] = "value"; +const char kHeaderBinaryValueKey[] = "binaryValue"; const char kHeadersKey[] = "headers"; const char kIdKey[] = "id"; const char kLimitKey[] = "limit"; @@ -404,13 +406,25 @@ bool DownloadsDownloadFunction::ParseArgs() { if (iodata_->extra_headers != NULL) { for (size_t index = 0; index < iodata_->extra_headers->GetSize(); ++index) { base::DictionaryValue* header = NULL; - std::string name, value; + std::string name; EXTENSION_FUNCTION_VALIDATE(iodata_->extra_headers->GetDictionary( index, &header)); EXTENSION_FUNCTION_VALIDATE(header->GetString( kHeaderNameKey, &name)); - EXTENSION_FUNCTION_VALIDATE(header->GetString( - kHeaderValueKey, &value)); + if (header->HasKey(kHeaderBinaryValueKey)) { + base::ListValue* binary_value = NULL; + EXTENSION_FUNCTION_VALIDATE(header->GetList( + kHeaderBinaryValueKey, &binary_value)); + for (size_t char_i = 0; char_i < binary_value->GetSize(); ++char_i) { + int char_value = 0; + EXTENSION_FUNCTION_VALIDATE(binary_value->GetInteger( + char_i, &char_value)); + } + } else if (header->HasKey(kHeaderValueKey)) { + std::string value; + EXTENSION_FUNCTION_VALIDATE(header->GetString( + kHeaderValueKey, &value)); + } if (!net::HttpUtil::IsSafeHeader(name)) { error_ = download_extension_errors::kGenericError; return false; @@ -451,8 +465,21 @@ void DownloadsDownloadFunction::BeginDownloadOnIOThread() { base::DictionaryValue* header = NULL; std::string name, value; CHECK(iodata_->extra_headers->GetDictionary(index, &header)); - CHECK(header->GetString("name", &name)); - CHECK(header->GetString("value", &value)); + CHECK(header->GetString(kHeaderNameKey, &name)); + if (header->HasKey(kHeaderBinaryValueKey)) { + base::ListValue* binary_value = NULL; + CHECK(header->GetList(kHeaderBinaryValueKey, &binary_value)); + for (size_t char_i = 0; char_i < binary_value->GetSize(); ++char_i) { + int char_value = 0; + CHECK(binary_value->GetInteger(char_i, &char_value)); + if ((0 <= char_value) && + (char_value <= 0xff)) { + value.push_back(char_value); + } + } + } else if (header->HasKey(kHeaderValueKey)) { + CHECK(header->GetString(kHeaderValueKey, &value)); + } request->SetExtraRequestHeaderByName(name, value, false/*overwrite*/); } } @@ -460,6 +487,11 @@ void DownloadsDownloadFunction::BeginDownloadOnIOThread() { request->AppendBytesToUpload(iodata_->post_body.data(), iodata_->post_body.size()); } + + // Prevent login prompts for 401/407 responses. + request->set_load_flags(request->load_flags() | + net::LOAD_DO_NOT_PROMPT_FOR_LOGIN); + net::Error error = iodata_->rdh->BeginDownload( request.Pass(), false, // prefer_cache diff --git a/chrome/test/data/extensions/api_test/downloads/test.js b/chrome/test/data/extensions/api_test/downloads/test.js index ba9224d9..dc13489 100644 --- a/chrome/test/data/extensions/api_test/downloads/test.js +++ b/chrome/test/data/extensions/api_test/downloads/test.js @@ -5,6 +5,15 @@ // downloads api test // browser_tests.exe --gtest_filter=DownloadsApiTest.Downloads +// Uncomment this when the apitest is re-enabled. +// console.debug = function() {}; + +function debugObject(obj) { + for (var property in obj) { + console.debug(property + ': ' + obj[property]); + } +} + var downloads = chrome.experimental.downloads; chrome.test.getConfig(function(testConfig) { @@ -55,6 +64,12 @@ chrome.test.getConfig(function(testConfig) { var HEADERS_URL = getURL('files/downloads/a_zip_file.zip?' + 'expected_headers=Foo:bar&expected_headers=Qx:yo'); + // A simple handler that requires http auth basic. + var AUTH_BASIC_URL = getURL('auth-basic'); + + // This is just base64 of 'username:secret'. + var AUTHORIZATION = 'dXNlcm5hbWU6c2VjcmV0'; + chrome.test.runTests([ // TODO(benjhayden): Test onErased using remove(). @@ -82,7 +97,7 @@ chrome.test.getConfig(function(testConfig) { function downloadSimple() { // Test that we can begin a download. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); downloads.download( {'url': SAFE_FAST_URL}, chrome.test.callback(function(id) { @@ -90,28 +105,136 @@ chrome.test.getConfig(function(testConfig) { })); }, + function downloadOnChanged() { + // Test that download completion is detectable by an onChanged event + // listener. + var downloadId = getNextId(); + console.debug(downloadId); + var callbackCompleted = chrome.test.callbackAdded(); + function myListener(delta) { + console.debug(delta.id); + if ((delta.id != downloadId) || + !delta.state) + return; + chrome.test.assertEq(downloads.STATE_COMPLETE, delta.state.new); + console.debug(downloadId); + downloads.onChanged.removeListener(myListener); + callbackCompleted(); + } + downloads.onChanged.addListener(myListener); + downloads.download( + {"url": SAFE_FAST_URL}, + chrome.test.callback(function(id) { + console.debug(downloadId); + chrome.test.assertEq(downloadId, id); + })); + }, + + function downloadAuthBasicFail() { + var downloadId = getNextId(); + console.debug(downloadId); + + var changedCompleted = chrome.test.callbackAdded(); + function changedListener(delta) { + console.debug(delta.id); + // Ignore onChanged events for downloads besides our own, or events that + // signal any change besides completion. + if ((delta.id != downloadId) || + !delta.state || + !delta.error) + return; + console.debug(downloadId); + chrome.test.assertEq(downloads.STATE_INTERRUPTED, delta.state.new); + chrome.test.assertEq(30, delta.error.new); + downloads.onChanged.removeListener(changedListener); + if (changedCompleted) { + changedCompleted(); + changedCompleted = null; + } + } + downloads.onChanged.addListener(changedListener); + + // Sometimes the DownloadsEventRouter detects the item for the first time + // after the item has already been interrupted. In this case, the + // onChanged event never fires, so run the changedListener manually. If + // the DownloadsEventRouter detects the item before it's interrupted, then + // the onChanged event should fire correctly. + var createdCompleted = chrome.test.callbackAdded(); + function createdListener(createdItem) { + console.debug(createdItem.id); + // Ignore events for any download besides our own. + if (createdItem.id != downloadId) + return; + console.debug(downloadId); + downloads.onCreated.removeListener(createdListener); + createdCompleted(); + if (createdItem.state == downloads.STATE_INTERRUPTED) { + changedListener({id: downloadId, state: {new: createdItem.state}, + error: {new: createdItem.error}}); + } + } + downloads.onCreated.addListener(createdListener); + + downloads.download( + {'url': AUTH_BASIC_URL, + 'filename': downloadId + '.txt'}, + chrome.test.callback(function(id) { + console.debug(downloadId); + chrome.test.assertEq(downloadId, id); + })); + }, + + function downloadAuthBasicSucceed() { + var downloadId = getNextId(); + console.debug(downloadId); + + var changedCompleted = chrome.test.callbackAdded(); + function changedListener(delta) { + console.debug(delta.id); + // Ignore onChanged events for downloads besides our own, or events that + // signal any change besides completion. + if ((delta.id != downloadId) || + !delta.state) + return; + chrome.test.assertEq(downloads.STATE_COMPLETE, delta.state.new); + console.debug(downloadId); + downloads.onChanged.removeListener(changedListener); + changedCompleted(); + } + downloads.onChanged.addListener(changedListener); + + downloads.download( + {'url': AUTH_BASIC_URL, + 'headers': [{'name': 'Authorization', + 'value': 'Basic ' + AUTHORIZATION}], + 'filename': downloadId + '.txt'}, + chrome.test.callback(function(id) { + console.debug(downloadId); + chrome.test.assertEq(downloadId, id); + })); + }, + function downloadPostSuccess() { // Test the |method| download option. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); var changedCompleted = chrome.test.callbackAdded(); function changedListener(delta) { - console.log(delta.id); + console.debug(delta.id); // Ignore onChanged events for downloads besides our own, or events that // signal any change besides completion. if ((delta.id != downloadId) || - !delta.state || - (delta.state.new != downloads.STATE_COMPLETE)) + !delta.state) return; - console.log(downloadId); + chrome.test.assertEq(downloads.STATE_COMPLETE, delta.state.new); + console.debug(downloadId); downloads.search({id: downloadId}, chrome.test.callback(function(items) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(1, items.length); chrome.test.assertEq(downloadId, items[0].id); + debugObject(items[0]); var EXPECTED_SIZE = 164; - chrome.test.assertEq(EXPECTED_SIZE, items[0].totalBytes); - chrome.test.assertEq(EXPECTED_SIZE, items[0].fileSize); chrome.test.assertEq(EXPECTED_SIZE, items[0].bytesReceived); })); downloads.onChanged.removeListener(changedListener); @@ -125,7 +248,7 @@ chrome.test.getConfig(function(testConfig) { 'filename': downloadId + '.txt', 'body': 'BODY'}, chrome.test.callback(function(id) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(downloadId, id); })); }, @@ -137,38 +260,55 @@ chrome.test.getConfig(function(testConfig) { // it should fail, and this tests how the downloads extension api exposes // the failure to extensions. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); var changedCompleted = chrome.test.callbackAdded(); function changedListener(delta) { - console.log(delta.id); + console.debug(delta.id); // Ignore onChanged events for downloads besides our own, or events that // signal any change besides interruption. if ((delta.id != downloadId) || !delta.state || - (delta.state.new != downloads.STATE_COMPLETE)) + !delta.error) return; - console.log(downloadId); - // TODO(benjhayden): Change COMPLETE to INTERRUPTED after - // http://crbug.com/112342 - downloads.search({id: downloadId}, - chrome.test.callback(function(items) { - console.log(downloadId); - chrome.test.assertEq(1, items.length); - chrome.test.assertEq(downloadId, items[0].id); - chrome.test.assertEq(0, items[0].totalBytes); - })); + chrome.test.assertEq(downloads.STATE_INTERRUPTED, delta.state.new); + chrome.test.assertEq(33, delta.error.new); + console.debug(downloadId); downloads.onChanged.removeListener(changedListener); - changedCompleted(); + if (changedCompleted) { + changedCompleted(); + changedCompleted = null; + } } downloads.onChanged.addListener(changedListener); + // Sometimes the DownloadsEventRouter detects the item for the first time + // after the item has already been interrupted. In this case, the + // onChanged event never fires, so run the changedListener manually. If + // the DownloadsEventRouter detects the item before it's interrupted, then + // the onChanged event should fire correctly. + var createdCompleted = chrome.test.callbackAdded(); + function createdListener(createdItem) { + console.debug(createdItem.id); + // Ignore events for any download besides our own. + if (createdItem.id != downloadId) + return; + console.debug(downloadId); + downloads.onCreated.removeListener(createdListener); + createdCompleted(); + if (createdItem.state == downloads.STATE_INTERRUPTED) { + changedListener({id: downloadId, state: {new: createdItem.state}, + error: {new: createdItem.error}}); + } + } + downloads.onCreated.addListener(createdListener); + downloads.download( {'url': POST_URL, 'filename': downloadId + '.txt', // Prevent 'file' danger. 'body': 'BODY'}, chrome.test.callback(function(id) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(downloadId, id); })); }, @@ -180,26 +320,82 @@ chrome.test.getConfig(function(testConfig) { // does not succeed when it should fail, and this tests how the downloads // extension api exposes the failure to extensions. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); var changedCompleted = chrome.test.callbackAdded(); function changedListener(delta) { - console.log(delta.id); + console.debug(delta.id); // Ignore onChanged events for downloads besides our own, or events that // signal any change besides interruption. if ((delta.id != downloadId) || !delta.state || - (delta.state.new != downloads.STATE_COMPLETE)) + !delta.error) + return; + chrome.test.assertEq(downloads.STATE_INTERRUPTED, delta.state.new); + chrome.test.assertEq(33, delta.error.new); + if (delta.error) console.debug(delta.error.new); + console.debug(downloadId); + downloads.onChanged.removeListener(changedListener); + if (changedCompleted) { + changedCompleted(); + changedCompleted = null; + } + } + downloads.onChanged.addListener(changedListener); + + // Sometimes the DownloadsEventRouter detects the item for the first time + // after the item has already been interrupted. In this case, the + // onChanged event never fires, so run the changedListener manually. If + // the DownloadsEventRouter detects the item before it's interrupted, then + // the onChanged event should fire correctly. + var createdCompleted = chrome.test.callbackAdded(); + function createdListener(createdItem) { + console.debug(createdItem.id); + // Ignore events for any download besides our own. + if (createdItem.id != downloadId) return; - console.log(downloadId); - // TODO(benjhayden): Change COMPLETE to INTERRUPTED after - // http://crbug.com/112342 + console.debug(downloadId); + downloads.onCreated.removeListener(createdListener); + createdCompleted(); + if (createdItem.state == downloads.STATE_INTERRUPTED) { + changedListener({id: downloadId, state: {new: createdItem.state}, + error: {new: createdItem.error}}); + } + } + downloads.onCreated.addListener(createdListener); + + downloads.download( + {'url': POST_URL, + 'filename': downloadId + '.txt', // Prevent 'file' danger. + 'method': 'POST'}, + chrome.test.callback(function(id) { + console.debug(downloadId); + chrome.test.assertEq(downloadId, id); + })); + }, + + function downloadHeadersSuccess() { + // Test the |header| download option. + var downloadId = getNextId(); + console.debug(downloadId); + var changedCompleted = chrome.test.callbackAdded(); + function changedListener(delta) { + console.debug(delta.id); + // Ignore onChanged events for downloads besides our own, or events that + // signal any change besides completion. + if ((delta.id != downloadId) || + !delta.state) + return; + chrome.test.assertEq(downloads.STATE_COMPLETE, delta.state.new); + console.debug(downloadId); downloads.search({id: downloadId}, chrome.test.callback(function(items) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(1, items.length); chrome.test.assertEq(downloadId, items[0].id); - chrome.test.assertEq(0, items[0].totalBytes); + debugObject(items[0]); + var EXPECTED_SIZE = 164; + chrome.test.assertEq(EXPECTED_SIZE, items[0].bytesReceived); })); downloads.onChanged.removeListener(changedListener); changedCompleted(); @@ -207,37 +403,37 @@ chrome.test.getConfig(function(testConfig) { downloads.onChanged.addListener(changedListener); downloads.download( - {'url': POST_URL, + {'url': HEADERS_URL, 'filename': downloadId + '.txt', // Prevent 'file' danger. - 'method': 'POST'}, + 'headers': [{'name': 'Foo', 'value': 'bar'}, + {'name': 'Qx', 'value': 'yo'}]}, chrome.test.callback(function(id) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(downloadId, id); })); }, - function downloadHeadersSuccess() { + function downloadHeadersBinarySuccess() { // Test the |header| download option. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); var changedCompleted = chrome.test.callbackAdded(); function changedListener(delta) { - console.log(delta.id); + console.debug(delta.id); // Ignore onChanged events for downloads besides our own, or events that // signal any change besides completion. if ((delta.id != downloadId) || - !delta.state || - (delta.state.new != downloads.STATE_COMPLETE)) + !delta.state) return; - console.log(downloadId); + chrome.test.assertEq(downloads.STATE_COMPLETE, delta.state.new); + console.debug(downloadId); downloads.search({id: downloadId}, chrome.test.callback(function(items) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(1, items.length); chrome.test.assertEq(downloadId, items[0].id); + debugObject(items[0]); var EXPECTED_SIZE = 164; - chrome.test.assertEq(EXPECTED_SIZE, items[0].totalBytes); - chrome.test.assertEq(EXPECTED_SIZE, items[0].fileSize); chrome.test.assertEq(EXPECTED_SIZE, items[0].bytesReceived); })); downloads.onChanged.removeListener(changedListener); @@ -248,10 +444,10 @@ chrome.test.getConfig(function(testConfig) { downloads.download( {'url': HEADERS_URL, 'filename': downloadId + '.txt', // Prevent 'file' danger. - 'headers': [{'name': 'Foo', 'value': 'bar'}, - {'name': 'Qx', 'value': 'yo'}]}, + 'headers': [{'name': 'Foo', 'binaryValue': [98, 97, 114]}, + {'name': 'Qx', 'binaryValue': [121, 111]}]}, chrome.test.callback(function(id) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(downloadId, id); })); }, @@ -263,36 +459,53 @@ chrome.test.getConfig(function(testConfig) { // fail as well as how the downloads extension api exposes the // failure to extensions. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); var changedCompleted = chrome.test.callbackAdded(); function changedListener(delta) { - console.log(delta.id); + console.debug(delta.id); // Ignore onChanged events for downloads besides our own, or events that // signal any change besides interruption. if ((delta.id != downloadId) || !delta.state || - (delta.state.new != downloads.STATE_COMPLETE)) + !delta.error) return; - console.log(downloadId); - // TODO(benjhayden): Change COMPLETE to INTERRUPTED after - // http://crbug.com/112342 - downloads.search({id: downloadId}, - chrome.test.callback(function(items) { - console.log(downloadId); - chrome.test.assertEq(1, items.length); - chrome.test.assertEq(downloadId, items[0].id); - chrome.test.assertEq(0, items[0].totalBytes); - })); + chrome.test.assertEq(downloads.STATE_INTERRUPTED, delta.state.new); + chrome.test.assertEq(33, delta.error.new); + console.debug(downloadId); downloads.onChanged.removeListener(changedListener); - changedCompleted(); + if (changedCompleted) { + changedCompleted(); + changedCompleted = null; + } } downloads.onChanged.addListener(changedListener); + // Sometimes the DownloadsEventRouter detects the item for the first time + // after the item has already been interrupted. In this case, the + // onChanged event never fires, so run the changedListener manually. If + // the DownloadsEventRouter detects the item before it's interrupted, then + // the onChanged event should fire correctly. + var createdCompleted = chrome.test.callbackAdded(); + function createdListener(createdItem) { + console.debug(createdItem.id); + // Ignore events for any download besides our own. + if (createdItem.id != downloadId) + return; + console.debug(downloadId); + downloads.onCreated.removeListener(createdListener); + createdCompleted(); + if (createdItem.state == downloads.STATE_INTERRUPTED) { + changedListener({id: downloadId, state: {new: createdItem.state}, + error: {new: createdItem.error}}); + } + } + downloads.onCreated.addListener(createdListener); + downloads.download( {'url': HEADERS_URL}, chrome.test.callback(function(id) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(downloadId, id); })); }, @@ -304,20 +517,20 @@ chrome.test.getConfig(function(testConfig) { // TODO(benjhayden): Test other sources of interruptions such as server // death. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); var createdCompleted = chrome.test.callbackAdded(); function createdListener(createdItem) { - console.log(createdItem.id); + console.debug(createdItem.id); // Ignore onCreated events for any download besides our own. if (createdItem.id != downloadId) return; - console.log(downloadId); + console.debug(downloadId); // TODO(benjhayden) Move this cancel() into the download() callback // after ensuring that DownloadItems are created before that callback // is fired. downloads.cancel(downloadId, chrome.test.callback(function() { - console.log(downloadId); + console.debug(downloadId); })); downloads.onCreated.removeListener(createdListener); createdCompleted(); @@ -326,16 +539,16 @@ chrome.test.getConfig(function(testConfig) { var changedCompleted = chrome.test.callbackAdded(); function changedListener(delta) { - console.log(delta.id); + console.debug(delta.id); // Ignore onChanged events for downloads besides our own, or events that // signal any change besides interruption. if ((delta.id != downloadId) || !delta.state || - (delta.state.new != downloads.STATE_INTERRUPTED) || - !delta.error || - (delta.error.new != 40)) + !delta.error) return; - console.log(downloadId); + chrome.test.assertEq(downloads.STATE_INTERRUPTED, delta.state.new); + chrome.test.assertEq(40, delta.error.new); + console.debug(downloadId); downloads.onChanged.removeListener(changedListener); changedCompleted(); } @@ -344,50 +557,25 @@ chrome.test.getConfig(function(testConfig) { downloads.download( {'url': NEVER_FINISH_URL}, chrome.test.callback(function(id) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(downloadId, id); })); }, - function downloadOnChanged() { - // Test that download completion is detectable by an onChanged event - // listener. - var downloadId = getNextId(); - console.log(downloadId); - var callbackCompleted = chrome.test.callbackAdded(); - function myListener(delta) { - console.log(delta.id); - if ((delta.id != downloadId) || - !delta.state || - (delta.state.new != downloads.STATE_COMPLETE)) - return; - console.log(downloadId); - downloads.onChanged.removeListener(myListener); - callbackCompleted(); - } - downloads.onChanged.addListener(myListener); - downloads.download( - {"url": SAFE_FAST_URL}, - chrome.test.callback(function(id) { - console.log(downloadId); - chrome.test.assertEq(downloadId, id); - })); - }, - function downloadFilename() { // Test that we can suggest a filename for a new download, and test that // we can detect filename changes with an onChanged event listener. var FILENAME = 'owiejtoiwjrfoiwjroiwjroiwjroiwjrfi'; var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); var callbackCompleted = chrome.test.callbackAdded(); function myListener(delta) { - console.log(delta.id); + console.debug(delta.id); if ((delta.id != downloadId) || !delta.filename || (delta.filename.new.indexOf(FILENAME) == -1)) return; - console.log(downloadId); + console.debug(downloadId); downloads.onChanged.removeListener(myListener); callbackCompleted(); } @@ -395,7 +583,7 @@ chrome.test.getConfig(function(testConfig) { downloads.download( {'url': SAFE_FAST_URL, 'filename': FILENAME}, chrome.test.callback(function(id) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(downloadId, id); })); }, @@ -403,13 +591,13 @@ chrome.test.getConfig(function(testConfig) { function downloadOnCreated() { // Test that the onCreated event fires when we start a download. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); var createdCompleted = chrome.test.callbackAdded(); function createdListener(item) { - console.log(item.id); + console.debug(item.id); if (item.id != downloadId) return; - console.log(downloadId); + console.debug(downloadId); createdCompleted(); downloads.onCreated.removeListener(createdListener); }; @@ -417,7 +605,7 @@ chrome.test.getConfig(function(testConfig) { downloads.download( {'url': SAFE_FAST_URL}, chrome.test.callback(function(id) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(downloadId, id); })); }, @@ -506,7 +694,7 @@ chrome.test.getConfig(function(testConfig) { function downloadAllowFragments() { // Valid URLs plus fragments are still valid URLs. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); downloads.download( {'url': SAFE_FAST_URL + '#frag'}, chrome.test.callback(function(id) { @@ -517,7 +705,7 @@ chrome.test.getConfig(function(testConfig) { function downloadAllowDataURLs() { // Valid data URLs are valid URLs. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); downloads.download( {'url': 'data:text/plain,hello'}, chrome.test.callback(function(id) { @@ -528,7 +716,7 @@ chrome.test.getConfig(function(testConfig) { function downloadAllowFileURLs() { // Valid file URLs are valid URLs. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); downloads.download( {'url': 'file:///'}, chrome.test.callback(function(id) { @@ -540,7 +728,7 @@ chrome.test.getConfig(function(testConfig) { // function downloadAllowFTPURLs() { // // Valid ftp URLs are valid URLs. // var downloadId = getNextId(); - // console.log(downloadId); + // console.debug(downloadId); // downloads.download( // {'url': 'ftp://localhost:' + testConfig.testServer.port + '/'}, // chrome.test.callback(function(id) { @@ -623,7 +811,7 @@ chrome.test.getConfig(function(testConfig) { function downloadCancelInvalidId() { // Canceling a non-existent download is not considered an error. downloads.cancel(-42, chrome.test.callback(function() { - console.log(''); + console.debug(''); })); }, @@ -636,11 +824,11 @@ chrome.test.getConfig(function(testConfig) { function downloadNoComplete() { // This is used partly to test cleanUp. var downloadId = getNextId(); - console.log(downloadId); + console.debug(downloadId); downloads.download( {'url': NEVER_FINISH_URL}, chrome.test.callback(function(id) { - console.log(downloadId); + console.debug(downloadId); chrome.test.assertEq(downloadId, id); })); }, @@ -648,10 +836,10 @@ chrome.test.getConfig(function(testConfig) { function cleanUp() { // cleanUp must come last. It clears out all in-progress downloads // so the browser can shutdown cleanly. - console.log(nextId); + console.debug(nextId); function makeCallback(id) { return function() { - console.log(id); + console.debug(id); } } for (var id = 0; id < nextId; ++id) { @@ -662,7 +850,7 @@ chrome.test.getConfig(function(testConfig) { function callNotifyPass() { chrome.test.notifyPass(); setTimeout(chrome.test.callback(function() { - console.log(''); + console.debug(''); }), 0); } ]); |