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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api_unittest.cc

Issue 16924017: A few minor changes to the chrome.downloads extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r211135 Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 const content::NotificationDetails& details) OVERRIDE { 175 const content::NotificationDetails& details) OVERRIDE {
176 switch (type) { 176 switch (type) {
177 case chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT: 177 case chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT:
178 { 178 {
179 DownloadsNotificationSource* dns = 179 DownloadsNotificationSource* dns =
180 content::Source<DownloadsNotificationSource>(source).ptr(); 180 content::Source<DownloadsNotificationSource>(source).ptr();
181 Event* new_event = new Event( 181 Event* new_event = new Event(
182 dns->profile, 182 dns->profile,
183 dns->event_name, 183 dns->event_name,
184 *content::Details<std::string>(details).ptr(), base::Time::Now()); 184 *content::Details<std::string>(details).ptr(), base::Time::Now());
185 LOG(INFO) << "occam caught " << new_event->Debug();
asanka 2013/07/16 19:57:52 to be removed?
benjhayden 2013/07/19 15:53:55 Done.
185 events_.push_back(new_event); 186 events_.push_back(new_event);
186 if (waiting_ && 187 if (waiting_ &&
187 waiting_for_.get() && 188 waiting_for_.get() &&
188 new_event->Satisfies(*waiting_for_)) { 189 new_event->Satisfies(*waiting_for_)) {
189 waiting_ = false; 190 waiting_ = false;
190 base::MessageLoopForUI::current()->Quit(); 191 base::MessageLoopForUI::current()->Quit();
191 } 192 }
192 break; 193 break;
193 } 194 }
194 default: 195 default:
195 NOTREACHED(); 196 NOTREACHED();
196 } 197 }
197 } 198 }
198 199
199 bool WaitFor(Profile* profile, 200 bool WaitFor(Profile* profile,
200 const std::string& event_name, 201 const std::string& event_name,
201 const std::string& json_args) { 202 const std::string& json_args) {
202 waiting_for_.reset(new Event(profile, event_name, json_args, base::Time())); 203 waiting_for_.reset(new Event(profile, event_name, json_args, base::Time()));
203 for (std::deque<Event*>::const_iterator iter = events_.begin(); 204 for (std::deque<Event*>::const_iterator iter = events_.begin();
204 iter != events_.end(); ++iter) { 205 iter != events_.end(); ++iter) {
205 if ((*iter)->Satisfies(*waiting_for_.get())) { 206 if ((*iter)->Satisfies(*waiting_for_.get())) {
206 return true; 207 return true;
207 } 208 }
208 } 209 }
210 LOG(INFO) << "occam waiting " << waiting_for_->Debug();
209 waiting_ = true; 211 waiting_ = true;
210 content::RunMessageLoop(); 212 content::RunMessageLoop();
211 bool success = !waiting_; 213 bool success = !waiting_;
212 if (waiting_) { 214 if (waiting_) {
213 // Print the events that were caught since the last WaitFor() call to help 215 // Print the events that were caught since the last WaitFor() call to help
214 // find the erroneous event. 216 // find the erroneous event.
215 // TODO(benjhayden) Fuzzy-match and highlight the erroneous event. 217 // TODO(benjhayden) Fuzzy-match and highlight the erroneous event.
216 for (std::deque<Event*>::const_iterator iter = events_.begin(); 218 for (std::deque<Event*>::const_iterator iter = events_.begin();
217 iter != events_.end(); ++iter) { 219 iter != events_.end(); ++iter) {
218 if ((*iter)->caught() > last_wait_) { 220 if ((*iter)->caught() > last_wait_) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 observer.EnableFileChooser(false); 344 observer.EnableFileChooser(false);
343 } 345 }
344 current_browser_ = incognito_browser_; 346 current_browser_ = incognito_browser_;
345 } 347 }
346 348
347 bool WaitFor(const std::string& event_name, const std::string& json_args) { 349 bool WaitFor(const std::string& event_name, const std::string& json_args) {
348 return events_listener_->WaitFor( 350 return events_listener_->WaitFor(
349 current_browser()->profile(), event_name, json_args); 351 current_browser()->profile(), event_name, json_args);
350 } 352 }
351 353
352 bool WaitForInterruption(DownloadItem* item, int expected_error, 354 bool WaitForInterruption(
353 const std::string& on_created_event) { 355 DownloadItem* item,
356 content::DownloadInterruptReason expected_error,
357 const std::string& on_created_event) {
354 if (!WaitFor(events::kOnDownloadCreated, on_created_event)) 358 if (!WaitFor(events::kOnDownloadCreated, on_created_event))
355 return false; 359 return false;
356 // Now, onCreated is always fired before interruption. 360 // Now, onCreated is always fired before interruption.
357 return WaitFor(events::kOnDownloadChanged, 361 return WaitFor(events::kOnDownloadChanged,
358 base::StringPrintf("[{\"id\": %d," 362 base::StringPrintf("[{\"id\": %d,"
359 " \"error\": {\"current\": %d}," 363 " \"error\": {\"current\": \"%s\"},"
360 " \"state\": {" 364 " \"state\": {"
361 " \"previous\": \"in_progress\"," 365 " \"previous\": \"in_progress\","
362 " \"current\": \"interrupted\"}}]", 366 " \"current\": \"interrupted\"}}]",
363 item->GetId(), 367 item->GetId(),
364 expected_error)); 368 content::InterruptReasonDebugString(
369 expected_error).c_str()));
365 } 370 }
366 371
367 void ClearEvents() { 372 void ClearEvents() {
368 events_listener_->ClearEvents(); 373 events_listener_->ClearEvents();
369 } 374 }
370 375
371 std::string GetExtensionURL() { 376 std::string GetExtensionURL() {
372 return extension_->url().spec(); 377 return extension_->url().spec();
373 } 378 }
374 std::string GetExtensionId() { 379 std::string GetExtensionId() {
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS }, 1240 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS },
1236 { FILE_PATH_LITERAL("baz"), 1241 { FILE_PATH_LITERAL("baz"),
1237 DownloadItem::COMPLETE, 1242 DownloadItem::COMPLETE,
1238 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS } 1243 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS }
1239 }; 1244 };
1240 DownloadManager::DownloadVector items; 1245 DownloadManager::DownloadVector items;
1241 ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo), 1246 ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
1242 &items)); 1247 &items));
1243 1248
1244 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( 1249 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(
1245 new DownloadsSearchFunction(), "[{\"orderBy\": \"filename\"}]")); 1250 new DownloadsSearchFunction(), "[{\"orderBy\": [\"filename\"]}]"));
1246 ASSERT_TRUE(result.get()); 1251 ASSERT_TRUE(result.get());
1247 base::ListValue* result_list = NULL; 1252 base::ListValue* result_list = NULL;
1248 ASSERT_TRUE(result->GetAsList(&result_list)); 1253 ASSERT_TRUE(result->GetAsList(&result_list));
1249 ASSERT_EQ(2UL, result_list->GetSize()); 1254 ASSERT_EQ(2UL, result_list->GetSize());
1250 base::DictionaryValue* item0_value = NULL; 1255 base::DictionaryValue* item0_value = NULL;
1251 base::DictionaryValue* item1_value = NULL; 1256 base::DictionaryValue* item1_value = NULL;
1252 ASSERT_TRUE(result_list->GetDictionary(0, &item0_value)); 1257 ASSERT_TRUE(result_list->GetDictionary(0, &item0_value));
1253 ASSERT_TRUE(result_list->GetDictionary(1, &item1_value)); 1258 ASSERT_TRUE(result_list->GetDictionary(1, &item1_value));
1254 std::string item0_name, item1_name; 1259 std::string item0_name, item1_name;
1255 ASSERT_TRUE(item0_value->GetString("filename", &item0_name)); 1260 ASSERT_TRUE(item0_value->GetString("filename", &item0_name));
(...skipping 12 matching lines...) Expand all
1268 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS }, 1273 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS },
1269 { FILE_PATH_LITERAL("baz"), 1274 { FILE_PATH_LITERAL("baz"),
1270 DownloadItem::COMPLETE, 1275 DownloadItem::COMPLETE,
1271 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS } 1276 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS }
1272 }; 1277 };
1273 DownloadManager::DownloadVector items; 1278 DownloadManager::DownloadVector items;
1274 ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo), 1279 ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
1275 &items)); 1280 &items));
1276 1281
1277 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( 1282 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(
1278 new DownloadsSearchFunction(), "[{\"orderBy\": \"\"}]")); 1283 new DownloadsSearchFunction(), "[{\"orderBy\": []}]"));
1279 ASSERT_TRUE(result.get()); 1284 ASSERT_TRUE(result.get());
1280 base::ListValue* result_list = NULL; 1285 base::ListValue* result_list = NULL;
1281 ASSERT_TRUE(result->GetAsList(&result_list)); 1286 ASSERT_TRUE(result->GetAsList(&result_list));
1282 ASSERT_EQ(2UL, result_list->GetSize()); 1287 ASSERT_EQ(2UL, result_list->GetSize());
1283 base::DictionaryValue* item0_value = NULL; 1288 base::DictionaryValue* item0_value = NULL;
1284 base::DictionaryValue* item1_value = NULL; 1289 base::DictionaryValue* item1_value = NULL;
1285 ASSERT_TRUE(result_list->GetDictionary(0, &item0_value)); 1290 ASSERT_TRUE(result_list->GetDictionary(0, &item0_value));
1286 ASSERT_TRUE(result_list->GetDictionary(1, &item1_value)); 1291 ASSERT_TRUE(result_list->GetDictionary(1, &item1_value));
1287 std::string item0_name, item1_name; 1292 std::string item0_name, item1_name;
1288 ASSERT_TRUE(item0_value->GetString("filename", &item0_name)); 1293 ASSERT_TRUE(item0_value->GetString("filename", &item0_name));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 } 1353 }
1349 1354
1350 // Test invalid search parameters. 1355 // Test invalid search parameters.
1351 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 1356 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
1352 DownloadExtensionTest_SearchInvalid) { 1357 DownloadExtensionTest_SearchInvalid) {
1353 std::string error = RunFunctionAndReturnError( 1358 std::string error = RunFunctionAndReturnError(
1354 new DownloadsSearchFunction(), "[{\"filenameRegex\": \"(\"}]"); 1359 new DownloadsSearchFunction(), "[{\"filenameRegex\": \"(\"}]");
1355 EXPECT_STREQ(download_extension_errors::kInvalidFilterError, 1360 EXPECT_STREQ(download_extension_errors::kInvalidFilterError,
1356 error.c_str()); 1361 error.c_str());
1357 error = RunFunctionAndReturnError( 1362 error = RunFunctionAndReturnError(
1358 new DownloadsSearchFunction(), "[{\"orderBy\": \"goat\"}]"); 1363 new DownloadsSearchFunction(), "[{\"orderBy\": [\"goat\"]}]");
1359 EXPECT_STREQ(download_extension_errors::kInvalidOrderByError, 1364 EXPECT_STREQ(download_extension_errors::kInvalidOrderByError,
1360 error.c_str()); 1365 error.c_str());
1361 error = RunFunctionAndReturnError( 1366 error = RunFunctionAndReturnError(
1362 new DownloadsSearchFunction(), "[{\"limit\": -1}]"); 1367 new DownloadsSearchFunction(), "[{\"limit\": -1}]");
1363 EXPECT_STREQ(download_extension_errors::kInvalidQueryLimit, 1368 EXPECT_STREQ(download_extension_errors::kInvalidQueryLimit,
1364 error.c_str()); 1369 error.c_str());
1365 } 1370 }
1366 1371
1367 // Test searching using multiple conditions through multiple downloads. 1372 // Test searching using multiple conditions through multiple downloads.
1368 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 1373 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
(...skipping 10 matching lines...) Expand all
1379 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT }, 1384 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT },
1380 }; 1385 };
1381 DownloadManager::DownloadVector items; 1386 DownloadManager::DownloadVector items;
1382 ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo), 1387 ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
1383 &items)); 1388 &items));
1384 1389
1385 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( 1390 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(
1386 new DownloadsSearchFunction(), "[{" 1391 new DownloadsSearchFunction(), "[{"
1387 "\"state\": \"complete\", " 1392 "\"state\": \"complete\", "
1388 "\"danger\": \"content\", " 1393 "\"danger\": \"content\", "
1389 "\"orderBy\": \"filename\", " 1394 "\"orderBy\": [\"filename\"], "
1390 "\"limit\": 1}]")); 1395 "\"limit\": 1}]"));
1391 ASSERT_TRUE(result.get()); 1396 ASSERT_TRUE(result.get());
1392 base::ListValue* result_list = NULL; 1397 base::ListValue* result_list = NULL;
1393 ASSERT_TRUE(result->GetAsList(&result_list)); 1398 ASSERT_TRUE(result->GetAsList(&result_list));
1394 ASSERT_EQ(1UL, result_list->GetSize()); 1399 ASSERT_EQ(1UL, result_list->GetSize());
1395 base::DictionaryValue* item_value = NULL; 1400 base::DictionaryValue* item_value = NULL;
1396 ASSERT_TRUE(result_list->GetDictionary(0, &item_value)); 1401 ASSERT_TRUE(result_list->GetDictionary(0, &item_value));
1397 base::FilePath::StringType item_name; 1402 base::FilePath::StringType item_name;
1398 ASSERT_TRUE(item_value->GetString("filename", &item_name)); 1403 ASSERT_TRUE(item_value->GetString("filename", &item_name));
1399 ASSERT_EQ(items[2]->GetTargetFilePath().value(), item_name); 1404 ASSERT_EQ(items[2]->GetTargetFilePath().value(), item_name);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 "sEc-", 1669 "sEc-",
1665 "pRoxY-probably-not-evil", 1670 "pRoxY-probably-not-evil",
1666 "sEc-probably-not-evil", 1671 "sEc-probably-not-evil",
1667 "oRiGiN", 1672 "oRiGiN",
1668 "Access-Control-Request-Headers", 1673 "Access-Control-Request-Headers",
1669 "Access-Control-Request-Method", 1674 "Access-Control-Request-Method",
1670 }; 1675 };
1671 1676
1672 for (size_t index = 0; index < arraysize(kUnsafeHeaders); ++index) { 1677 for (size_t index = 0; index < arraysize(kUnsafeHeaders); ++index) {
1673 std::string download_url = test_server()->GetURL("slow?0").spec(); 1678 std::string download_url = test_server()->GetURL("slow?0").spec();
1674 EXPECT_STREQ(download_extension_errors::kGenericError, 1679 EXPECT_STREQ(download_extension_errors::kInvalidHeaderError,
1675 RunFunctionAndReturnError(new DownloadsDownloadFunction(), 1680 RunFunctionAndReturnError(new DownloadsDownloadFunction(),
1676 base::StringPrintf( 1681 base::StringPrintf(
1677 "[{\"url\": \"%s\"," 1682 "[{\"url\": \"%s\","
1678 " \"filename\": \"unsafe-header-%d.txt\"," 1683 " \"filename\": \"unsafe-header-%d.txt\","
1679 " \"headers\": [{" 1684 " \"headers\": [{"
1680 " \"name\": \"%s\"," 1685 " \"name\": \"%s\","
1681 " \"value\": \"unsafe\"}]}]", 1686 " \"value\": \"unsafe\"}]}]",
1682 download_url.c_str(), 1687 download_url.c_str(),
1683 static_cast<int>(index), 1688 static_cast<int>(index),
1684 kUnsafeHeaders[index])).c_str()); 1689 kUnsafeHeaders[index])).c_str());
1685 } 1690 }
1686 } 1691 }
1687 1692
1688 // Test that subdirectories (slashes) are disallowed in filenames.
1689 // TODO(benjhayden) Update this when subdirectories are supported.
1690 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 1693 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
1691 DownloadExtensionTest_Download_Subdirectory) { 1694 DownloadExtensionTest_Download_Subdirectory) {
1692 LoadExtension("downloads_split"); 1695 LoadExtension("downloads_split");
1693 ASSERT_TRUE(StartEmbeddedTestServer()); 1696 ASSERT_TRUE(StartEmbeddedTestServer());
1694 ASSERT_TRUE(test_server()->Start()); 1697 ASSERT_TRUE(test_server()->Start());
1695 std::string download_url = test_server()->GetURL("slow?0").spec(); 1698 std::string download_url = test_server()->GetURL("slow?0").spec();
1696 GoOnTheRecord(); 1699 GoOnTheRecord();
1697 1700
1698 EXPECT_STREQ(download_extension_errors::kInvalidFilenameError, 1701 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(
1699 RunFunctionAndReturnError(new DownloadsDownloadFunction(), 1702 new DownloadsDownloadFunction(), base::StringPrintf(
1700 base::StringPrintf( 1703 "[{\"url\": \"%s\","
1701 "[{\"url\": \"%s\"," 1704 " \"filename\": \"sub/dir/ect/ory.txt\"}]",
1702 " \"filename\": \"sub/dir/ect/ory.txt\"}]", 1705 download_url.c_str())));
1703 download_url.c_str())).c_str()); 1706 ASSERT_TRUE(result.get());
1707 int result_id = -1;
1708 ASSERT_TRUE(result->GetAsInteger(&result_id));
1709 DownloadItem* item = GetCurrentManager()->GetDownload(result_id);
1710 ASSERT_TRUE(item);
1711 ScopedCancellingItem canceller(item);
1712 ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
1713
1714 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
1715 base::StringPrintf("[{\"danger\": \"safe\","
1716 " \"incognito\": false,"
1717 " \"mime\": \"text/plain\","
1718 " \"paused\": false,"
1719 " \"url\": \"%s\"}]",
1720 download_url.c_str())));
1721 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
1722 base::StringPrintf("[{\"id\": %d,"
1723 " \"filename\": {"
1724 " \"previous\": \"\","
1725 " \"current\": \"%s\"}}]",
1726 result_id,
1727 GetFilename("sub/dir/ect/ory.txt").c_str())));
1728 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
1729 base::StringPrintf("[{\"id\": %d,"
1730 " \"state\": {"
1731 " \"previous\": \"in_progress\","
1732 " \"current\": \"complete\"}}]",
1733 result_id)));
1704 } 1734 }
1705 1735
1706 // Test that invalid filenames are disallowed. 1736 // Test that invalid filenames are disallowed.
1707 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 1737 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
1708 DownloadExtensionTest_Download_InvalidFilename) { 1738 DownloadExtensionTest_Download_InvalidFilename) {
1709 LoadExtension("downloads_split"); 1739 LoadExtension("downloads_split");
1710 ASSERT_TRUE(StartEmbeddedTestServer()); 1740 ASSERT_TRUE(StartEmbeddedTestServer());
1711 ASSERT_TRUE(test_server()->Start()); 1741 ASSERT_TRUE(test_server()->Start());
1712 std::string download_url = test_server()->GetURL("slow?0").spec(); 1742 std::string download_url = test_server()->GetURL("slow?0").spec();
1713 GoOnTheRecord(); 1743 GoOnTheRecord();
1714 1744
1715 EXPECT_STREQ(download_extension_errors::kInvalidFilenameError, 1745 EXPECT_STREQ(download_extension_errors::kInvalidFilenameError,
1716 RunFunctionAndReturnError(new DownloadsDownloadFunction(), 1746 RunFunctionAndReturnError(new DownloadsDownloadFunction(),
1717 base::StringPrintf( 1747 base::StringPrintf(
1718 "[{\"url\": \"%s\"," 1748 "[{\"url\": \"%s\","
1719 " \"filename\": \"../../../../../etc/passwd\"}]", 1749 " \"filename\": \"../../../../../etc/passwd\"}]",
1720 download_url.c_str())).c_str()); 1750 download_url.c_str())).c_str());
1721 } 1751 }
1722 1752
1723 // Test that downloading invalid URLs immediately returns kInvalidURLError. 1753 // Test that downloading invalid URLs immediately returns kInvalidURLError.
1724 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 1754 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
1725 DownloadExtensionTest_Download_InvalidURLs) { 1755 DownloadExtensionTest_Download_InvalidURLs) {
1726 LoadExtension("downloads_split"); 1756 LoadExtension("downloads_split");
1727 GoOnTheRecord(); 1757 GoOnTheRecord();
1728 1758
1729 static const char* kInvalidURLs[] = { 1759 static const char* kInvalidURLs[] = {
1730 "foo bar", 1760 "foo bar",
1731 "../hello", 1761 "../hello",
1732 "/hello", 1762 "/hello",
1733 "google.com/",
1734 "http://", 1763 "http://",
1735 "#frag", 1764 "#frag",
1736 "foo/bar.html#frag", 1765 "foo/bar.html#frag",
1737 "javascript:document.write(\\\"hello\\\");", 1766 "google.com/",
1738 "javascript:return false;",
1739 "ftp://example.com/example.txt",
1740 }; 1767 };
1741 1768
1742 for (size_t index = 0; index < arraysize(kInvalidURLs); ++index) { 1769 for (size_t index = 0; index < arraysize(kInvalidURLs); ++index) {
1743 EXPECT_STREQ(download_extension_errors::kInvalidURLError, 1770 EXPECT_STREQ(download_extension_errors::kInvalidURLError,
1744 RunFunctionAndReturnError(new DownloadsDownloadFunction(), 1771 RunFunctionAndReturnError(new DownloadsDownloadFunction(),
1745 base::StringPrintf( 1772 base::StringPrintf(
1746 "[{\"url\": \"%s\"}]", kInvalidURLs[index])).c_str()); 1773 "[{\"url\": \"%s\"}]", kInvalidURLs[index])).c_str())
1774 << kInvalidURLs[index];
1775 }
1776
1777 static const char* kNotPermittedURLs[] = {
1778 "javascript:document.write(\\\"hello\\\");",
1779 "javascript:return false;",
1780 "ftp://example.com/example.txt",
1781 };
1782
1783 for (size_t index = 0; index < arraysize(kNotPermittedURLs); ++index) {
1784 EXPECT_STREQ(download_extension_errors::kNotPermittedURLError,
1785 RunFunctionAndReturnError(new DownloadsDownloadFunction(),
1786 base::StringPrintf(
1787 "[{\"url\": \"%s\"}]", kNotPermittedURLs[index])).c_str())
1788 << kNotPermittedURLs[index];
1747 } 1789 }
1748 } 1790 }
1749 1791
1750 // TODO(benjhayden): Set up a test ftp server, add ftp://localhost* to 1792 // TODO(benjhayden): Set up a test ftp server, add ftp://localhost* to
1751 // permissions, test downloading from ftp. 1793 // permissions, test downloading from ftp.
1752 1794
1753 // Valid URLs plus fragments are still valid URLs. 1795 // Valid URLs plus fragments are still valid URLs.
1754 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 1796 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
1755 DownloadExtensionTest_Download_URLFragment) { 1797 DownloadExtensionTest_Download_URLFragment) {
1756 LoadExtension("downloads_split"); 1798 LoadExtension("downloads_split");
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 " \"filename\": \"auth-basic-fail.txt\"}]", 1945 " \"filename\": \"auth-basic-fail.txt\"}]",
1904 download_url.c_str()))); 1946 download_url.c_str())));
1905 ASSERT_TRUE(result.get()); 1947 ASSERT_TRUE(result.get());
1906 int result_id = -1; 1948 int result_id = -1;
1907 ASSERT_TRUE(result->GetAsInteger(&result_id)); 1949 ASSERT_TRUE(result->GetAsInteger(&result_id));
1908 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); 1950 DownloadItem* item = GetCurrentManager()->GetDownload(result_id);
1909 ASSERT_TRUE(item); 1951 ASSERT_TRUE(item);
1910 ScopedCancellingItem canceller(item); 1952 ScopedCancellingItem canceller(item);
1911 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); 1953 ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
1912 1954
1913 ASSERT_TRUE(WaitForInterruption(item, 30, base::StringPrintf( 1955 ASSERT_TRUE(WaitForInterruption(
1914 "[{\"danger\": \"safe\"," 1956 item,
1915 " \"incognito\": false," 1957 content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED,
1916 " \"mime\": \"text/html\"," 1958 base::StringPrintf("[{\"danger\": \"safe\","
1917 " \"paused\": false," 1959 " \"incognito\": false,"
1918 " \"url\": \"%s\"}]", 1960 " \"mime\": \"text/html\","
1919 download_url.c_str()))); 1961 " \"paused\": false,"
1962 " \"url\": \"%s\"}]",
1963 download_url.c_str())));
1920 } 1964 }
1921 1965
1922 // Test that DownloadsDownloadFunction propagates |headers| to the URLRequest. 1966 // Test that DownloadsDownloadFunction propagates |headers| to the URLRequest.
1923 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 1967 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
1924 DownloadExtensionTest_Download_Headers) { 1968 DownloadExtensionTest_Download_Headers) {
1925 LoadExtension("downloads_split"); 1969 LoadExtension("downloads_split");
1926 ASSERT_TRUE(StartEmbeddedTestServer()); 1970 ASSERT_TRUE(StartEmbeddedTestServer());
1927 ASSERT_TRUE(test_server()->Start()); 1971 ASSERT_TRUE(test_server()->Start());
1928 std::string download_url = test_server()->GetURL("files/downloads/" 1972 std::string download_url = test_server()->GetURL("files/downloads/"
1929 "a_zip_file.zip?expected_headers=Foo:bar&expected_headers=Qx:yo").spec(); 1973 "a_zip_file.zip?expected_headers=Foo:bar&expected_headers=Qx:yo").spec();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 " \"filename\": \"headers-fail.txt\"}]", 2030 " \"filename\": \"headers-fail.txt\"}]",
1987 download_url.c_str()))); 2031 download_url.c_str())));
1988 ASSERT_TRUE(result.get()); 2032 ASSERT_TRUE(result.get());
1989 int result_id = -1; 2033 int result_id = -1;
1990 ASSERT_TRUE(result->GetAsInteger(&result_id)); 2034 ASSERT_TRUE(result->GetAsInteger(&result_id));
1991 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); 2035 DownloadItem* item = GetCurrentManager()->GetDownload(result_id);
1992 ASSERT_TRUE(item); 2036 ASSERT_TRUE(item);
1993 ScopedCancellingItem canceller(item); 2037 ScopedCancellingItem canceller(item);
1994 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); 2038 ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
1995 2039
1996 ASSERT_TRUE(WaitForInterruption(item, 33, base::StringPrintf( 2040 ASSERT_TRUE(WaitForInterruption(
1997 "[{\"danger\": \"safe\"," 2041 item,
1998 " \"incognito\": false," 2042 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT,
1999 " \"bytesReceived\": 0," 2043 base::StringPrintf("[{\"danger\": \"safe\","
2000 " \"mime\": \"\"," 2044 " \"incognito\": false,"
2001 " \"paused\": false," 2045 " \"bytesReceived\": 0,"
2002 " \"url\": \"%s\"}]", 2046 " \"mime\": \"\","
2003 download_url.c_str()))); 2047 " \"paused\": false,"
2048 " \"url\": \"%s\"}]",
2049 download_url.c_str())));
2004 } 2050 }
2005 2051
2006 // Test that DownloadsDownloadFunction propagates the Authorization header 2052 // Test that DownloadsDownloadFunction propagates the Authorization header
2007 // correctly. 2053 // correctly.
2008 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 2054 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
2009 DownloadExtensionTest_Download_AuthBasic) { 2055 DownloadExtensionTest_Download_AuthBasic) {
2010 LoadExtension("downloads_split"); 2056 LoadExtension("downloads_split");
2011 ASSERT_TRUE(StartEmbeddedTestServer()); 2057 ASSERT_TRUE(StartEmbeddedTestServer());
2012 ASSERT_TRUE(test_server()->Start()); 2058 ASSERT_TRUE(test_server()->Start());
2013 std::string download_url = test_server()->GetURL("auth-basic").spec(); 2059 std::string download_url = test_server()->GetURL("auth-basic").spec();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 " \"filename\": \"post-get.txt\"}]", 2158 " \"filename\": \"post-get.txt\"}]",
2113 download_url.c_str()))); 2159 download_url.c_str())));
2114 ASSERT_TRUE(result.get()); 2160 ASSERT_TRUE(result.get());
2115 int result_id = -1; 2161 int result_id = -1;
2116 ASSERT_TRUE(result->GetAsInteger(&result_id)); 2162 ASSERT_TRUE(result->GetAsInteger(&result_id));
2117 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); 2163 DownloadItem* item = GetCurrentManager()->GetDownload(result_id);
2118 ASSERT_TRUE(item); 2164 ASSERT_TRUE(item);
2119 ScopedCancellingItem canceller(item); 2165 ScopedCancellingItem canceller(item);
2120 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); 2166 ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
2121 2167
2122 ASSERT_TRUE(WaitForInterruption(item, 33, base::StringPrintf( 2168 ASSERT_TRUE(WaitForInterruption(
2123 "[{\"danger\": \"safe\"," 2169 item,
2124 " \"incognito\": false," 2170 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT,
2125 " \"mime\": \"\"," 2171 base::StringPrintf("[{\"danger\": \"safe\","
2126 " \"paused\": false," 2172 " \"incognito\": false,"
2127 " \"id\": %d," 2173 " \"mime\": \"\","
2128 " \"url\": \"%s\"}]", 2174 " \"paused\": false,"
2129 result_id, 2175 " \"id\": %d,"
2130 download_url.c_str()))); 2176 " \"url\": \"%s\"}]",
2177 result_id,
2178 download_url.c_str())));
2131 } 2179 }
2132 2180
2133 // Test that downloadPostSuccess would fail if the resource requires the POST 2181 // Test that downloadPostSuccess would fail if the resource requires the POST
2134 // method, and chrome fails to propagate the |body| parameter back to the 2182 // method, and chrome fails to propagate the |body| parameter back to the
2135 // server. This tests both that testserver.py does not succeed when it should 2183 // server. This tests both that testserver.py does not succeed when it should
2136 // fail, and this tests how the downloads extension api exposes the failure to 2184 // fail, and this tests how the downloads extension api exposes the failure to
2137 // extensions. 2185 // extensions.
2138 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 2186 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
2139 DownloadExtensionTest_Download_Post_NoBody) { 2187 DownloadExtensionTest_Download_Post_NoBody) {
2140 LoadExtension("downloads_split"); 2188 LoadExtension("downloads_split");
(...skipping 10 matching lines...) Expand all
2151 " \"filename\": \"post-nobody.txt\"}]", 2199 " \"filename\": \"post-nobody.txt\"}]",
2152 download_url.c_str()))); 2200 download_url.c_str())));
2153 ASSERT_TRUE(result.get()); 2201 ASSERT_TRUE(result.get());
2154 int result_id = -1; 2202 int result_id = -1;
2155 ASSERT_TRUE(result->GetAsInteger(&result_id)); 2203 ASSERT_TRUE(result->GetAsInteger(&result_id));
2156 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); 2204 DownloadItem* item = GetCurrentManager()->GetDownload(result_id);
2157 ASSERT_TRUE(item); 2205 ASSERT_TRUE(item);
2158 ScopedCancellingItem canceller(item); 2206 ScopedCancellingItem canceller(item);
2159 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); 2207 ASSERT_EQ(download_url, item->GetOriginalUrl().spec());
2160 2208
2161 ASSERT_TRUE(WaitForInterruption(item, 33, base::StringPrintf( 2209 ASSERT_TRUE(WaitForInterruption(
2162 "[{\"danger\": \"safe\"," 2210 item,
2163 " \"incognito\": false," 2211 content::DOWNLOAD_INTERRUPT_REASON_SERVER_BAD_CONTENT,
2164 " \"mime\": \"\"," 2212 base::StringPrintf("[{\"danger\": \"safe\","
2165 " \"paused\": false," 2213 " \"incognito\": false,"
2166 " \"id\": %d," 2214 " \"mime\": \"\","
2167 " \"url\": \"%s\"}]", 2215 " \"paused\": false,"
2168 result_id, 2216 " \"id\": %d,"
2169 download_url.c_str()))); 2217 " \"url\": \"%s\"}]",
2218 result_id,
2219 download_url.c_str())));
2170 } 2220 }
2171 2221
2172 // Test that cancel()ing an in-progress download causes its state to transition 2222 // Test that cancel()ing an in-progress download causes its state to transition
2173 // to interrupted, and test that that state transition is detectable by an 2223 // to interrupted, and test that that state transition is detectable by an
2174 // onChanged event listener. TODO(benjhayden): Test other sources of 2224 // onChanged event listener. TODO(benjhayden): Test other sources of
2175 // interruptions such as server death. 2225 // interruptions such as server death.
2176 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 2226 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
2177 DownloadExtensionTest_Download_Cancel) { 2227 DownloadExtensionTest_Download_Cancel) {
2178 LoadExtension("downloads_split"); 2228 LoadExtension("downloads_split");
2179 ASSERT_TRUE(StartEmbeddedTestServer()); 2229 ASSERT_TRUE(StartEmbeddedTestServer());
(...skipping 18 matching lines...) Expand all
2198 " \"incognito\": false," 2248 " \"incognito\": false,"
2199 " \"mime\": \"application/octet-stream\"," 2249 " \"mime\": \"application/octet-stream\","
2200 " \"paused\": false," 2250 " \"paused\": false,"
2201 " \"id\": %d," 2251 " \"id\": %d,"
2202 " \"url\": \"%s\"}]", 2252 " \"url\": \"%s\"}]",
2203 result_id, 2253 result_id,
2204 download_url.c_str()))); 2254 download_url.c_str())));
2205 item->Cancel(true); 2255 item->Cancel(true);
2206 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, 2256 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
2207 base::StringPrintf("[{\"id\": %d," 2257 base::StringPrintf("[{\"id\": %d,"
2208 " \"error\": {\"current\": 40}," 2258 " \"error\": {\"current\":\"USER_CANCELED\"},"
2209 " \"state\": {" 2259 " \"state\": {"
2210 " \"previous\": \"in_progress\"," 2260 " \"previous\": \"in_progress\","
2211 " \"current\": \"interrupted\"}}]", 2261 " \"current\": \"interrupted\"}}]",
2212 result_id))); 2262 result_id)));
2213 } 2263 }
2214 2264
2215 // Test downloading filesystem: URLs. 2265 // Test downloading filesystem: URLs.
2216 // NOTE: chrome disallows creating HTML5 FileSystem Files in incognito. 2266 // NOTE: chrome disallows creating HTML5 FileSystem Files in incognito.
2217 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest, 2267 IN_PROC_BROWSER_TEST_F(DownloadExtensionTest,
2218 DownloadExtensionTest_Download_FileSystemURL) { 2268 DownloadExtensionTest_Download_FileSystemURL) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
2358 2408
2359 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, 2409 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated,
2360 base::StringPrintf("[{\"danger\": \"safe\"," 2410 base::StringPrintf("[{\"danger\": \"safe\","
2361 " \"incognito\": false," 2411 " \"incognito\": false,"
2362 " \"id\": %d," 2412 " \"id\": %d,"
2363 " \"mime\": \"text/plain\"," 2413 " \"mime\": \"text/plain\","
2364 " \"paused\": false," 2414 " \"paused\": false,"
2365 " \"url\": \"%s\"}]", 2415 " \"url\": \"%s\"}]",
2366 result_id, 2416 result_id,
2367 download_url.c_str()))); 2417 download_url.c_str())));
2418 LOG(INFO) << "occam";
2368 ASSERT_TRUE(WaitFor( 2419 ASSERT_TRUE(WaitFor(
2369 events::kOnDownloadDeterminingFilename, 2420 events::kOnDownloadDeterminingFilename,
2370 base::StringPrintf("[{\"id\": %d," 2421 base::StringPrintf("[{\"id\": %d,"
2371 " \"filename\":\"slow.txt\"}]", 2422 " \"filename\":\"slow.txt\"}]",
2372 result_id))); 2423 result_id)));
2424 LOG(INFO) << "occam";
2373 ASSERT_TRUE(item->GetTargetFilePath().empty()); 2425 ASSERT_TRUE(item->GetTargetFilePath().empty());
2374 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState()); 2426 ASSERT_EQ(DownloadItem::IN_PROGRESS, item->GetState());
2375 2427
2376 // Respond to the onDeterminingFilename. 2428 // Respond to the onDeterminingFilename.
2377 std::string error; 2429 std::string error;
2378 ASSERT_TRUE(ExtensionDownloadsEventRouter::DetermineFilename( 2430 ASSERT_TRUE(ExtensionDownloadsEventRouter::DetermineFilename(
2379 browser()->profile(), 2431 browser()->profile(),
2380 false, 2432 false,
2381 GetExtensionId(), 2433 GetExtensionId(),
2382 result_id, 2434 result_id,
2383 base::FilePath(FILE_PATH_LITERAL("overridden.swf")), 2435 base::FilePath(FILE_PATH_LITERAL("overridden.swf")),
2384 extensions::api::downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY, 2436 extensions::api::downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY,
2385 &error)); 2437 &error));
2386 EXPECT_EQ("", error); 2438 EXPECT_EQ("", error);
2387 2439
2388 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, 2440 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
2389 base::StringPrintf("[{\"id\": %d," 2441 base::StringPrintf("[{\"id\": %d,"
2390 " \"danger\": {" 2442 " \"danger\": {"
2391 " \"previous\":\"safe\"," 2443 " \"previous\":\"safe\","
2392 " \"current\":\"file\"}," 2444 " \"current\":\"file\"}}]",
2393 " \"dangerAccepted\": {"
2394 " \"current\":false}}]",
2395 result_id))); 2445 result_id)));
2446 LOG(INFO) << "occam";
2396 2447
2397 item->ValidateDangerousDownload(); 2448 item->ValidateDangerousDownload();
2398 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, 2449 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
2399 base::StringPrintf("[{\"id\": %d," 2450 base::StringPrintf("[{\"id\": %d,"
2400 " \"dangerAccepted\": {" 2451 " \"danger\": {"
2401 " \"previous\":false," 2452 " \"previous\":\"file\","
2402 " \"current\":true}}]", 2453 " \"current\":\"accepted\"}}]",
2403 result_id))); 2454 result_id)));
2455 LOG(INFO) << "occam";
2404 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, 2456 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
2405 base::StringPrintf("[{\"id\": %d," 2457 base::StringPrintf("[{\"id\": %d,"
2406 " \"state\": {" 2458 " \"state\": {"
2407 " \"previous\": \"in_progress\"," 2459 " \"previous\": \"in_progress\","
2408 " \"current\": \"complete\"}}]", 2460 " \"current\": \"complete\"}}]",
2409 result_id))); 2461 result_id)));
2462 LOG(INFO) << "occam";
2410 EXPECT_EQ(downloads_directory().AppendASCII("overridden.swf"), 2463 EXPECT_EQ(downloads_directory().AppendASCII("overridden.swf"),
2411 item->GetTargetFilePath()); 2464 item->GetTargetFilePath());
2412 } 2465 }
2413 2466
2414 IN_PROC_BROWSER_TEST_F( 2467 IN_PROC_BROWSER_TEST_F(
2415 DownloadExtensionTest, 2468 DownloadExtensionTest,
2416 DownloadExtensionTest_OnDeterminingFilename_ReferencesParentInvalid) { 2469 DownloadExtensionTest_OnDeterminingFilename_ReferencesParentInvalid) {
2417 GoOnTheRecord(); 2470 GoOnTheRecord();
2418 LoadExtension("downloads_split"); 2471 LoadExtension("downloads_split");
2419 AddFilenameDeterminer(); 2472 AddFilenameDeterminer();
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 " \"previous\": \"\"," 3523 " \"previous\": \"\","
3471 " \"current\": \"%s\"}}]", 3524 " \"current\": \"%s\"}}]",
3472 item->GetId(), 3525 item->GetId(),
3473 GetFilename("42.txt").c_str()))); 3526 GetFilename("42.txt").c_str())));
3474 3527
3475 content::DownloadUpdatedObserver interrupted(item, base::Bind( 3528 content::DownloadUpdatedObserver interrupted(item, base::Bind(
3476 ItemIsInterrupted)); 3529 ItemIsInterrupted));
3477 ASSERT_TRUE(interrupted.WaitForEvent()); 3530 ASSERT_TRUE(interrupted.WaitForEvent());
3478 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, 3531 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
3479 base::StringPrintf("[{\"id\": %d," 3532 base::StringPrintf("[{\"id\": %d,"
3480 " \"error\":{\"current\":20}," 3533 " \"error\":{\"current\":\"NETWORK_FAILED\"},"
3481 " \"state\":{" 3534 " \"state\":{"
3482 " \"previous\":\"in_progress\"," 3535 " \"previous\":\"in_progress\","
3483 " \"current\":\"interrupted\"}}]", 3536 " \"current\":\"interrupted\"}}]",
3484 item->GetId()))); 3537 item->GetId())));
3485 3538
3486 ClearEvents(); 3539 ClearEvents();
3487 // Downloads that are restarted on resumption trigger another download target 3540 // Downloads that are restarted on resumption trigger another download target
3488 // determination. 3541 // determination.
3489 RemoveFilenameDeterminer(host); 3542 RemoveFilenameDeterminer(host);
3490 item->Resume(); 3543 item->Resume();
3491 3544
3492 // Errors caught before filename determination is complete are delayed until 3545 // Errors caught before filename determination is complete are delayed until
3493 // after filename determination so that, on resumption, filename determination 3546 // after filename determination so that, on resumption, filename determination
3494 // does not need to be re-done. So, there will not be a second 3547 // does not need to be re-done. So, there will not be a second
3495 // onDeterminingFilename event. 3548 // onDeterminingFilename event.
3496 3549
3497 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, 3550 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
3498 base::StringPrintf("[{\"id\": %d," 3551 base::StringPrintf("[{\"id\": %d,"
3499 " \"error\":{\"previous\":20}," 3552 " \"error\":{\"previous\":\"NETWORK_FAILED\"},"
3500 " \"state\":{" 3553 " \"state\":{"
3501 " \"previous\":\"interrupted\"," 3554 " \"previous\":\"interrupted\","
3502 " \"current\":\"in_progress\"}}]", 3555 " \"current\":\"in_progress\"}}]",
3503 item->GetId()))); 3556 item->GetId())));
3504 3557
3505 ClearEvents(); 3558 ClearEvents();
3506 FinishPendingSlowDownloads(); 3559 FinishPendingSlowDownloads();
3507 3560
3508 // The download should complete successfully. 3561 // The download should complete successfully.
3509 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, 3562 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged,
(...skipping 15 matching lines...) Expand all
3525 DownloadsApiTest() {} 3578 DownloadsApiTest() {}
3526 virtual ~DownloadsApiTest() {} 3579 virtual ~DownloadsApiTest() {}
3527 private: 3580 private:
3528 DISALLOW_COPY_AND_ASSIGN(DownloadsApiTest); 3581 DISALLOW_COPY_AND_ASSIGN(DownloadsApiTest);
3529 }; 3582 };
3530 3583
3531 3584
3532 IN_PROC_BROWSER_TEST_F(DownloadsApiTest, DownloadsApiTest) { 3585 IN_PROC_BROWSER_TEST_F(DownloadsApiTest, DownloadsApiTest) {
3533 ASSERT_TRUE(RunExtensionTest("downloads")) << message_; 3586 ASSERT_TRUE(RunExtensionTest("downloads")) << message_;
3534 } 3587 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698