Index: chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc |
diff --git a/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc b/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc |
index 8898363f5e3b0cee7efa93741067c056f0a5b00d..79f2497c9b1aa32ce3718ca7afd48c4e0da9d2b6 100644 |
--- a/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc |
+++ b/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc |
@@ -205,9 +205,8 @@ class DownloadsEventsListener : public content::NotificationObserver { |
waiting_for_.reset(new Event(profile, event_name, json_args, base::Time())); |
for (std::deque<Event*>::const_iterator iter = events_.begin(); |
iter != events_.end(); ++iter) { |
- if ((*iter)->Satisfies(*waiting_for_.get())) { |
+ if ((*iter)->Satisfies(*waiting_for_.get())) |
return true; |
- } |
} |
waiting_ = true; |
content::RunMessageLoop(); |
@@ -1686,9 +1685,18 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
EXPECT_STREQ("NETWORK_INVALID_REQUEST", RunFunctionAndReturnError( |
new DownloadsDownloadFunction(), |
"[{\"url\": \"javascript:return false;\"}]").c_str()); |
- EXPECT_STREQ("NETWORK_FAILED", RunFunctionAndReturnError( |
- new DownloadsDownloadFunction(), |
- "[{\"url\": \"ftp://example.com/example.txt\"}]").c_str()); |
+ |
+ std::string url_parameter = "[{\"url\": \"ftp://example.com/example.txt\"}]"; |
+ scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
+ new DownloadsDownloadFunction(), url_parameter)); |
+ ASSERT_TRUE(result.get()); |
+ int result_id = -1; |
+ ASSERT_TRUE(result->GetAsInteger(&result_id)); |
+ DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
+ ASSERT_TRUE(item); |
+ ScopedCancellingItem canceller(item); |
+ ASSERT_TRUE(WaitForInterruption( |
+ item, content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, url_parameter)); |
} |
// TODO(benjhayden): Set up a test ftp server, add ftp://localhost* to |
@@ -1829,10 +1837,10 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
result_id))); |
} |
-// Test that auth-basic-succeed would fail if the resource requires the |
-// Authorization header and chrome fails to propagate it back to the server. |
-// This tests both that testserver.py does not succeed when it should fail as |
-// well as how the downloads extension API exposes the failure to extensions. |
+// Test that auth-basic would fail if the resource requires the Authorization |
+// header and chrome fails to propagate it back to the server. This tests both |
+// that the embedded test server does not succeed when it should fail as well as |
+// how the downloads extension API exposes the failure to extensions. |
IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
DownloadExtensionTest_Download_AuthBasic_Fail) { |
LoadExtension("downloads_split"); |
@@ -1853,16 +1861,16 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
ASSERT_TRUE(item); |
ScopedCancellingItem canceller(item); |
ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
- |
- ASSERT_TRUE(WaitForInterruption( |
- item, |
- content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, |
- base::StringPrintf("[{\"danger\": \"safe\"," |
- " \"incognito\": false," |
- " \"mime\": \"text/html\"," |
- " \"paused\": false," |
- " \"url\": \"%s\"}]", |
- download_url.c_str()))); |
+ ASSERT_TRUE( |
+ WaitForInterruption(item, |
+ content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, |
+ base::StringPrintf( |
+ "[{\"danger\": \"safe\"," |
+ " \"incognito\": false," |
+ " \"mime\": \"\"," |
+ " \"paused\": false," |
+ " \"url\": \"%s\"}]", |
+ download_url.c_str()))); |
} |
// Test that DownloadsDownloadFunction propagates |headers| to the URLRequest. |
@@ -1939,17 +1947,18 @@ IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, |
ScopedCancellingItem canceller(item); |
ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
- ASSERT_TRUE(WaitForInterruption( |
- item, |
- content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, |
- base::StringPrintf("[{\"danger\": \"safe\"," |
- " \"incognito\": false," |
- " \"bytesReceived\": 0.0," |
- " \"fileSize\": 0.0," |
- " \"mime\": \"\"," |
- " \"paused\": false," |
- " \"url\": \"%s\"}]", |
- download_url.c_str()))); |
+ ASSERT_TRUE( |
+ WaitForInterruption(item, |
+ content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT, |
+ base::StringPrintf( |
+ "[{\"danger\": \"safe\"," |
+ " \"incognito\": false," |
+ " \"bytesReceived\": 0.0," |
+ " \"fileSize\": -1.0," |
+ " \"mime\": \"\"," |
+ " \"paused\": false," |
+ " \"url\": \"%s\"}]", |
+ download_url.c_str()))); |
} |
// Test that DownloadsDownloadFunction propagates the Authorization header |