Chromium Code Reviews| 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 ba9224d9de6d16d67a962a74ac6e924974e67a67..c4aac9ddd045f778632455fa5916d31ab9135158 100644 |
| --- a/chrome/test/data/extensions/api_test/downloads/test.js |
| +++ b/chrome/test/data/extensions/api_test/downloads/test.js |
| @@ -55,6 +55,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(). |
| @@ -79,6 +85,82 @@ chrome.test.getConfig(function(testConfig) { |
| // })); |
| // }, |
| + function downloadAuthBasicFail() { |
|
cbentzel
2012/02/24 22:36:07
What happens in this case? Do you see an auth prom
benjhayden
2012/02/27 14:09:55
Nope, no prompt. The test succeeds. It detects the
cbentzel
2012/02/28 20:23:22
I'm still not entirely sure why you wouldn't get a
benjhayden
2012/03/01 18:43:18
Done.
cbentzel
2012/03/01 22:16:26
Done meaning the hole in my brain has been resolve
benjhayden
2012/03/02 14:43:47
Done meaning I don't see anything that I need to d
|
| + var downloadId = getNextId(); |
| + console.log(downloadId); |
|
cbentzel
2012/02/28 20:23:22
Remove console.log
Or you could add a debugLog()
benjhayden
2012/03/01 18:43:18
Done.
Also, this test is still DISABLED.
|
| + |
| + var changedCompleted = chrome.test.callbackAdded(); |
| + function changedListener(delta) { |
| + console.log(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)) |
| + return; |
| + // TODO(benjhayden): Change COMPLETE to INTERRUPTED after |
|
cbentzel
2012/02/28 20:23:22
This may be fixed - see the most recent CL on http
benjhayden
2012/03/01 18:43:18
Done.
|
| + // http://crbug.com/112342 |
| + console.log(downloadId); |
| + 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(427, items[0].bytesReceived); |
| + chrome.test.assertEq(0, items[0].totalBytes); |
| + chrome.test.assertEq(0, items[0].fileSize); |
| + })); |
| + downloads.onChanged.removeListener(changedListener); |
| + changedCompleted(); |
| + } |
| + downloads.onChanged.addListener(changedListener); |
| + |
| + downloads.download( |
| + {'url': AUTH_BASIC_URL, |
| + 'filename': downloadId + '.txt'}, |
| + chrome.test.callback(function(id) { |
| + console.log(downloadId); |
| + chrome.test.assertEq(downloadId, id); |
| + })); |
| + }, |
| + |
| + function downloadAuthBasicSucceed() { |
| + var downloadId = getNextId(); |
| + console.log(downloadId); |
| + |
| + var changedCompleted = chrome.test.callbackAdded(); |
| + function changedListener(delta) { |
| + console.log(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)) |
| + return; |
| + console.log(downloadId); |
| + 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(443, items[0].bytesReceived); |
| + })); |
| + 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.log(downloadId); |
| + chrome.test.assertEq(downloadId, id); |
| + })); |
| + }, |
| + |
| function downloadSimple() { |
| // Test that we can begin a download. |
| var downloadId = getNextId(); |