OLD | NEW |
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 <sstream> | 5 #include <sstream> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "chrome/common/extensions/feature_switch.h" | 52 #include "chrome/common/extensions/feature_switch.h" |
53 #include "chrome/common/pref_names.h" | 53 #include "chrome/common/pref_names.h" |
54 #include "chrome/common/url_constants.h" | 54 #include "chrome/common/url_constants.h" |
55 #include "chrome/test/base/in_process_browser_test.h" | 55 #include "chrome/test/base/in_process_browser_test.h" |
56 #include "chrome/test/base/ui_test_utils.h" | 56 #include "chrome/test/base/ui_test_utils.h" |
57 #include "content/public/browser/download_item.h" | 57 #include "content/public/browser/download_item.h" |
58 #include "content/public/browser/download_manager.h" | 58 #include "content/public/browser/download_manager.h" |
59 #include "content/public/browser/download_save_info.h" | 59 #include "content/public/browser/download_save_info.h" |
60 #include "content/public/browser/download_url_parameters.h" | 60 #include "content/public/browser/download_url_parameters.h" |
61 #include "content/public/browser/notification_source.h" | 61 #include "content/public/browser/notification_source.h" |
| 62 #include "content/public/browser/plugin_service.h" |
62 #include "content/public/browser/render_view_host.h" | 63 #include "content/public/browser/render_view_host.h" |
63 #include "content/public/browser/resource_context.h" | 64 #include "content/public/browser/resource_context.h" |
64 #include "content/public/browser/web_contents.h" | 65 #include "content/public/browser/web_contents.h" |
65 #include "content/public/common/context_menu_params.h" | 66 #include "content/public/common/context_menu_params.h" |
66 #include "content/public/common/page_transition_types.h" | 67 #include "content/public/common/page_transition_types.h" |
67 #include "content/public/test/browser_test_utils.h" | 68 #include "content/public/test/browser_test_utils.h" |
68 #include "content/public/test/download_test_observer.h" | 69 #include "content/public/test/download_test_observer.h" |
69 #include "content/public/test/test_file_error_injector.h" | 70 #include "content/public/test/test_file_error_injector.h" |
70 #include "content/public/test/test_navigation_observer.h" | 71 #include "content/public/test/test_navigation_observer.h" |
71 #include "content/test/net/url_request_mock_http_job.h" | 72 #include "content/test/net/url_request_mock_http_job.h" |
72 #include "content/test/net/url_request_slow_download_job.h" | 73 #include "content/test/net/url_request_slow_download_job.h" |
73 #include "net/base/net_util.h" | 74 #include "net/base/net_util.h" |
74 #include "net/test/test_server.h" | 75 #include "net/test/test_server.h" |
75 #include "testing/gtest/include/gtest/gtest.h" | 76 #include "testing/gtest/include/gtest/gtest.h" |
| 77 #include "webkit/plugins/npapi/mock_plugin_list.h" |
76 | 78 |
77 using content::BrowserContext; | 79 using content::BrowserContext; |
78 using content::BrowserThread; | 80 using content::BrowserThread; |
79 using content::DownloadItem; | 81 using content::DownloadItem; |
80 using content::DownloadManager; | 82 using content::DownloadManager; |
81 using content::DownloadUrlParameters; | 83 using content::DownloadUrlParameters; |
82 using content::URLRequestMockHTTPJob; | 84 using content::URLRequestMockHTTPJob; |
83 using content::URLRequestSlowDownloadJob; | 85 using content::URLRequestSlowDownloadJob; |
84 using content::WebContents; | 86 using content::WebContents; |
85 using extensions::Extension; | 87 using extensions::Extension; |
86 using extensions::FeatureSwitch; | 88 using extensions::FeatureSwitch; |
87 | 89 |
88 namespace { | 90 namespace { |
89 | 91 |
90 // IDs and paths of CRX files used in tests. | 92 // IDs and paths of CRX files used in tests. |
91 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; | 93 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; |
92 const FilePath kGoodCrxPath(FILE_PATH_LITERAL("extensions/good.crx")); | 94 const FilePath kGoodCrxPath(FILE_PATH_LITERAL("extensions/good.crx")); |
93 | 95 |
94 const char kLargeThemeCrxId[] = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; | 96 const char kLargeThemeCrxId[] = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; |
95 const FilePath kLargeThemePath(FILE_PATH_LITERAL("extensions/theme2.crx")); | 97 const FilePath kLargeThemePath(FILE_PATH_LITERAL("extensions/theme2.crx")); |
96 | 98 |
| 99 // Get History Information. |
| 100 class DownloadsHistoryDataCollector { |
| 101 public: |
| 102 explicit DownloadsHistoryDataCollector(Profile* profile) |
| 103 : profile_(profile), result_valid_(false) {} |
| 104 |
| 105 bool WaitForDownloadInfo( |
| 106 scoped_ptr<std::vector<history::DownloadRow> >* results) { |
| 107 HistoryService* hs = HistoryServiceFactory::GetForProfile( |
| 108 profile_, Profile::EXPLICIT_ACCESS); |
| 109 DCHECK(hs); |
| 110 hs->QueryDownloads( |
| 111 base::Bind(&DownloadsHistoryDataCollector::OnQueryDownloadsComplete, |
| 112 base::Unretained(this))); |
| 113 |
| 114 content::RunMessageLoop(); |
| 115 if (result_valid_) { |
| 116 *results = results_.Pass(); |
| 117 } |
| 118 return result_valid_; |
| 119 } |
| 120 |
| 121 private: |
| 122 void OnQueryDownloadsComplete( |
| 123 scoped_ptr<std::vector<history::DownloadRow> > entries) { |
| 124 result_valid_ = true; |
| 125 results_ = entries.Pass(); |
| 126 MessageLoopForUI::current()->Quit(); |
| 127 } |
| 128 |
| 129 Profile* profile_; |
| 130 scoped_ptr<std::vector<history::DownloadRow> > results_; |
| 131 bool result_valid_; |
| 132 CancelableRequestConsumer callback_consumer_; |
| 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(DownloadsHistoryDataCollector); |
| 135 }; |
| 136 |
97 // Mock that simulates a permissions dialog where the user denies | 137 // Mock that simulates a permissions dialog where the user denies |
98 // permission to install. TODO(skerner): This could be shared with | 138 // permission to install. TODO(skerner): This could be shared with |
99 // extensions tests. Find a common place for this class. | 139 // extensions tests. Find a common place for this class. |
100 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { | 140 class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { |
101 public: | 141 public: |
102 MockAbortExtensionInstallPrompt() : | 142 MockAbortExtensionInstallPrompt() : |
103 ExtensionInstallPrompt(NULL) { | 143 ExtensionInstallPrompt(NULL) { |
104 } | 144 } |
105 | 145 |
106 // Simulate a user abort on an extension installation. | 146 // Simulate a user abort on an extension installation. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 198 |
159 bool WasAutoOpened(DownloadItem* item) { | 199 bool WasAutoOpened(DownloadItem* item) { |
160 return item->GetAutoOpened(); | 200 return item->GetAutoOpened(); |
161 } | 201 } |
162 | 202 |
163 // Called when a download starts. Marks the download as hidden. | 203 // Called when a download starts. Marks the download as hidden. |
164 void SetHiddenDownloadCallback(DownloadItem* item, net::Error error) { | 204 void SetHiddenDownloadCallback(DownloadItem* item, net::Error error) { |
165 DownloadItemModel(item).SetShouldShowInShelf(false); | 205 DownloadItemModel(item).SetShouldShowInShelf(false); |
166 } | 206 } |
167 | 207 |
| 208 // Callback for HistoryObserver; used in DownloadHistoryCheck |
| 209 bool HasDataAndName(const history::DownloadRow& row) { |
| 210 return row.received_bytes > 0 && !row.target_path.empty(); |
| 211 } |
| 212 |
168 } // namespace | 213 } // namespace |
169 | 214 |
170 class HistoryObserver : public DownloadHistory::Observer { | 215 class HistoryObserver : public DownloadHistory::Observer { |
171 public: | 216 public: |
| 217 typedef base::Callback<bool(const history::DownloadRow&)> FilterCallback; |
| 218 |
172 explicit HistoryObserver(Profile* profile) | 219 explicit HistoryObserver(Profile* profile) |
173 : profile_(profile), | 220 : profile_(profile), |
174 waiting_(false), | 221 waiting_(false), |
175 seen_stored_(false) { | 222 seen_stored_(false) { |
176 DownloadServiceFactory::GetForProfile(profile_)-> | 223 DownloadServiceFactory::GetForProfile(profile_)-> |
177 GetDownloadHistory()->AddObserver(this); | 224 GetDownloadHistory()->AddObserver(this); |
178 } | 225 } |
179 | 226 |
180 virtual ~HistoryObserver() { | 227 virtual ~HistoryObserver() { |
181 DownloadService* service = DownloadServiceFactory::GetForProfile(profile_); | 228 DownloadService* service = DownloadServiceFactory::GetForProfile(profile_); |
182 if (service && service->GetDownloadHistory()) | 229 if (service && service->GetDownloadHistory()) |
183 service->GetDownloadHistory()->RemoveObserver(this); | 230 service->GetDownloadHistory()->RemoveObserver(this); |
184 } | 231 } |
185 | 232 |
| 233 void SetFilterCallback(const FilterCallback& callback) { |
| 234 callback_ = callback; |
| 235 } |
| 236 |
186 virtual void OnDownloadStored( | 237 virtual void OnDownloadStored( |
187 content::DownloadItem* item, | 238 content::DownloadItem* item, |
188 const history::DownloadRow& info) OVERRIDE { | 239 const history::DownloadRow& info) OVERRIDE { |
| 240 if (!callback_.is_null() && (!callback_.Run(info))) |
| 241 return; |
| 242 |
189 seen_stored_ = true; | 243 seen_stored_ = true; |
190 if (waiting_) | 244 if (waiting_) |
191 MessageLoopForUI::current()->Quit(); | 245 MessageLoopForUI::current()->Quit(); |
192 } | 246 } |
193 | 247 |
194 virtual void OnDownloadHistoryDestroyed() OVERRIDE { | 248 virtual void OnDownloadHistoryDestroyed() OVERRIDE { |
195 DownloadServiceFactory::GetForProfile(profile_)-> | 249 DownloadServiceFactory::GetForProfile(profile_)-> |
196 GetDownloadHistory()->RemoveObserver(this); | 250 GetDownloadHistory()->RemoveObserver(this); |
197 } | 251 } |
198 | 252 |
199 void WaitForStored() { | 253 void WaitForStored() { |
200 if (seen_stored_) | 254 if (seen_stored_) |
201 return; | 255 return; |
202 waiting_ = true; | 256 waiting_ = true; |
203 content::RunMessageLoop(); | 257 content::RunMessageLoop(); |
204 waiting_ = false; | 258 waiting_ = false; |
205 } | 259 } |
206 | 260 |
207 private: | 261 private: |
208 Profile* profile_; | 262 Profile* profile_; |
209 bool waiting_; | 263 bool waiting_; |
210 bool seen_stored_; | 264 bool seen_stored_; |
| 265 FilterCallback callback_; |
211 | 266 |
212 DISALLOW_COPY_AND_ASSIGN(HistoryObserver); | 267 DISALLOW_COPY_AND_ASSIGN(HistoryObserver); |
213 }; | 268 }; |
214 | 269 |
215 class DownloadTest : public InProcessBrowserTest { | 270 class DownloadTest : public InProcessBrowserTest { |
216 public: | 271 public: |
217 // Choice of navigation or direct fetch. Used by |DownloadFileCheckErrors()|. | 272 // Choice of navigation or direct fetch. Used by |DownloadFileCheckErrors()|. |
218 enum DownloadMethod { | 273 enum DownloadMethod { |
219 DOWNLOAD_NAVIGATE, | 274 DOWNLOAD_NAVIGATE, |
220 DOWNLOAD_DIRECT | 275 DOWNLOAD_DIRECT |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 SIZE_TEST_TYPE_UNKNOWN, | 345 SIZE_TEST_TYPE_UNKNOWN, |
291 }; | 346 }; |
292 | 347 |
293 // Location of the file source (the place from which it is downloaded). | 348 // Location of the file source (the place from which it is downloaded). |
294 FilePath OriginFile(FilePath file) { | 349 FilePath OriginFile(FilePath file) { |
295 return test_dir_.Append(file); | 350 return test_dir_.Append(file); |
296 } | 351 } |
297 | 352 |
298 // Location of the file destination (place to which it is downloaded). | 353 // Location of the file destination (place to which it is downloaded). |
299 FilePath DestinationFile(Browser* browser, FilePath file) { | 354 FilePath DestinationFile(Browser* browser, FilePath file) { |
300 return GetDownloadDirectory(browser).Append(file); | 355 return GetDownloadDirectory(browser).Append(file.BaseName()); |
301 } | 356 } |
302 | 357 |
303 // Must be called after browser creation. Creates a temporary | 358 // Must be called after browser creation. Creates a temporary |
304 // directory for downloads that is auto-deleted on destruction. | 359 // directory for downloads that is auto-deleted on destruction. |
305 // Returning false indicates a failure of the function, and should be asserted | 360 // Returning false indicates a failure of the function, and should be asserted |
306 // in the caller. | 361 // in the caller. |
307 bool CreateAndSetDownloadsDirectory(Browser* browser) { | 362 bool CreateAndSetDownloadsDirectory(Browser* browser) { |
308 if (!browser) | 363 if (!browser) |
309 return false; | 364 return false; |
310 | 365 |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 #endif | 1429 #endif |
1375 | 1430 |
1376 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 1431 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
1377 // Download shelf should close. Download panel stays open on ChromeOS. | 1432 // Download shelf should close. Download panel stays open on ChromeOS. |
1378 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 1433 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
1379 | 1434 |
1380 CheckDownload(browser(), file, file); | 1435 CheckDownload(browser(), file, file); |
1381 } | 1436 } |
1382 | 1437 |
1383 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { | 1438 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryCheck) { |
1384 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1439 GURL download_url(URLRequestSlowDownloadJob::kKnownSizeUrl); |
| 1440 FilePath file(net::GenerateFileName(download_url, "", "", "", "", "")); |
| 1441 |
| 1442 // We use the server so that we can get a redirect and test url_chain |
| 1443 // persistence. |
| 1444 ASSERT_TRUE(test_server()->Start()); |
| 1445 GURL redirect_url = test_server()->GetURL( |
| 1446 "server-redirect?" + download_url.spec()); |
| 1447 |
| 1448 // Download the url and wait until the object has been stored. |
| 1449 base::Time start(base::Time::Now()); |
| 1450 HistoryObserver observer(browser()->profile()); |
| 1451 observer.SetFilterCallback(base::Bind(&HasDataAndName)); |
| 1452 ui_test_utils::NavigateToURL(browser(), redirect_url); |
| 1453 observer.WaitForStored(); |
| 1454 |
| 1455 // Get the details on what was stored into the history. |
| 1456 scoped_ptr<std::vector<history::DownloadRow> > downloads_in_database; |
| 1457 ASSERT_TRUE(DownloadsHistoryDataCollector( |
| 1458 browser()->profile()).WaitForDownloadInfo(&downloads_in_database)); |
| 1459 ASSERT_EQ(1u, downloads_in_database->size()); |
| 1460 |
| 1461 // Confirm history storage is what you expect for a partially completed |
| 1462 // slow download job. |
| 1463 history::DownloadRow& row(downloads_in_database->at(0)); |
| 1464 EXPECT_EQ(DestinationFile(browser(), file), row.target_path); |
| 1465 EXPECT_EQ(download_util::GetCrDownloadPath(DestinationFile(browser(), file)), |
| 1466 row.current_path); |
| 1467 ASSERT_EQ(2u, row.url_chain.size()); |
| 1468 EXPECT_EQ(redirect_url.spec(), row.url_chain[0].spec()); |
| 1469 EXPECT_EQ(download_url.spec(), row.url_chain[1].spec()); |
| 1470 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, row.danger_type); |
| 1471 EXPECT_LE(start, row.start_time); |
| 1472 EXPECT_EQ(URLRequestSlowDownloadJob::kFirstDownloadSize, row.received_bytes); |
| 1473 EXPECT_EQ(URLRequestSlowDownloadJob::kFirstDownloadSize |
| 1474 + URLRequestSlowDownloadJob::kSecondDownloadSize, row.total_bytes); |
| 1475 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, row.state); |
| 1476 EXPECT_FALSE(row.opened); |
| 1477 |
| 1478 // Finish the download. We're ok relying on the history to be flushed |
| 1479 // at this point as our queries will be behind the history updates |
| 1480 // invoked by completion. |
| 1481 scoped_ptr<content::DownloadTestObserver> download_observer( |
| 1482 CreateWaiter(browser(), 1)); |
| 1483 ui_test_utils::NavigateToURL(browser(), |
| 1484 GURL(URLRequestSlowDownloadJob::kErrorDownloadUrl)); |
| 1485 download_observer->WaitForFinished(); |
| 1486 EXPECT_EQ(1u, download_observer->NumDownloadsSeenInState( |
| 1487 DownloadItem::INTERRUPTED)); |
| 1488 base::Time end(base::Time::Now()); |
| 1489 |
| 1490 // Get what was stored in the history. |
| 1491 ASSERT_TRUE(DownloadsHistoryDataCollector( |
| 1492 browser()->profile()).WaitForDownloadInfo(&downloads_in_database)); |
| 1493 ASSERT_EQ(1u, downloads_in_database->size()); |
| 1494 |
| 1495 // Confirm history storage is what you expect for a completed |
| 1496 // slow download job. |
| 1497 history::DownloadRow& row1(downloads_in_database->at(0)); |
| 1498 EXPECT_EQ(DestinationFile(browser(), file), row1.target_path); |
| 1499 EXPECT_EQ(download_util::GetCrDownloadPath(DestinationFile(browser(), file)), |
| 1500 row1.current_path); |
| 1501 ASSERT_EQ(2u, row1.url_chain.size()); |
| 1502 EXPECT_EQ(redirect_url.spec(), row1.url_chain[0].spec()); |
| 1503 EXPECT_EQ(download_url.spec(), row1.url_chain[1].spec()); |
| 1504 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, row1.danger_type); |
| 1505 EXPECT_LE(start, row1.start_time); |
| 1506 EXPECT_GE(end, row1.end_time); |
| 1507 EXPECT_EQ(URLRequestSlowDownloadJob::kFirstDownloadSize, |
| 1508 row1.received_bytes); |
| 1509 EXPECT_EQ(URLRequestSlowDownloadJob::kFirstDownloadSize |
| 1510 + URLRequestSlowDownloadJob::kSecondDownloadSize, row1.total_bytes); |
| 1511 EXPECT_EQ(content::DownloadItem::INTERRUPTED, row1.state); |
| 1512 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_NETWORK_FAILED, |
| 1513 row1.interrupt_reason); |
| 1514 EXPECT_FALSE(row1.opened); |
| 1515 } |
| 1516 |
| 1517 // Make sure a dangerous file shows up properly in the history. |
| 1518 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryDangerCheck) { |
| 1519 // .swf file so that it's dangerous on all platforms (including CrOS). |
| 1520 FilePath file(FILE_PATH_LITERAL("downloads/dangerous/dangerous.swf")); |
1385 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1521 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); |
| 1522 |
| 1523 // Null out plugins so that flash plugin won't interfere with testing. |
| 1524 #if defined(ENABLE_PLUGINS) |
| 1525 webkit::npapi::MockPluginList plugin_list; |
| 1526 content::PluginService::GetInstance()->SetPluginListForTesting(&plugin_list); |
| 1527 #endif |
| 1528 |
| 1529 // Download the url and wait until the object has been stored. |
| 1530 scoped_ptr<content::DownloadTestObserver> download_observer( |
| 1531 new content::DownloadTestObserverTerminal( |
| 1532 DownloadManagerForBrowser(browser()), 1, |
| 1533 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE)); |
| 1534 base::Time start(base::Time::Now()); |
1386 HistoryObserver observer(browser()->profile()); | 1535 HistoryObserver observer(browser()->profile()); |
1387 DownloadAndWait(browser(), download_url); | 1536 observer.SetFilterCallback(base::Bind(&HasDataAndName)); |
| 1537 ui_test_utils::NavigateToURL(browser(), download_url); |
1388 observer.WaitForStored(); | 1538 observer.WaitForStored(); |
| 1539 |
| 1540 // Get the details on what was stored into the history. |
| 1541 scoped_ptr<std::vector<history::DownloadRow> > downloads_in_database; |
| 1542 ASSERT_TRUE(DownloadsHistoryDataCollector( |
| 1543 browser()->profile()).WaitForDownloadInfo(&downloads_in_database)); |
| 1544 ASSERT_EQ(1u, downloads_in_database->size()); |
| 1545 |
| 1546 // Confirm history storage is what you expect for an unvalidated |
| 1547 // dangerous file. |
| 1548 history::DownloadRow& row(downloads_in_database->at(0)); |
| 1549 EXPECT_EQ(DestinationFile(browser(), file), row.target_path); |
| 1550 EXPECT_NE(download_util::GetCrDownloadPath(DestinationFile(browser(), file)), |
| 1551 row.current_path); |
| 1552 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE, row.danger_type); |
| 1553 EXPECT_LE(start, row.start_time); |
| 1554 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, row.state); |
| 1555 EXPECT_FALSE(row.opened); |
| 1556 |
| 1557 // Validate the download and wait for it to finish. |
| 1558 std::vector<DownloadItem*> downloads; |
| 1559 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads); |
| 1560 ASSERT_EQ(1u, downloads.size()); |
| 1561 downloads[0]->DangerousDownloadValidated(); |
| 1562 download_observer->WaitForFinished(); |
| 1563 |
| 1564 // Get history details and confirm it's what you expect. |
| 1565 downloads_in_database->clear(); |
| 1566 ASSERT_TRUE(DownloadsHistoryDataCollector( |
| 1567 browser()->profile()).WaitForDownloadInfo(&downloads_in_database)); |
| 1568 ASSERT_EQ(1u, downloads_in_database->size()); |
| 1569 history::DownloadRow& row1(downloads_in_database->at(0)); |
| 1570 EXPECT_EQ(DestinationFile(browser(), file), row1.target_path); |
| 1571 EXPECT_EQ(DestinationFile(browser(), file), row1.current_path); |
| 1572 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED, row1.danger_type); |
| 1573 EXPECT_LE(start, row1.start_time); |
| 1574 EXPECT_EQ(content::DownloadItem::COMPLETE, row1.state); |
| 1575 EXPECT_FALSE(row1.opened); |
| 1576 // Not checking file size--not relevant to the point of the test, and |
| 1577 // the file size is actually different on Windows and other platforms, |
| 1578 // because for source control simplicity it's actually a text file, and |
| 1579 // there are CRLF transformations for those files. |
1389 } | 1580 } |
1390 | 1581 |
1391 // Test for crbug.com/14505. This tests that chrome:// urls are still functional | 1582 // Test for crbug.com/14505. This tests that chrome:// urls are still functional |
1392 // after download of a file while viewing another chrome://. | 1583 // after download of a file while viewing another chrome://. |
1393 IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { | 1584 IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { |
1394 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1585 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1395 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); | 1586 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); |
1396 GURL flags_url(chrome::kChromeUIFlagsURL); | 1587 GURL flags_url(chrome::kChromeUIFlagsURL); |
1397 GURL extensions_url(chrome::kChromeUIExtensionsFrameURL); | 1588 GURL extensions_url(chrome::kChromeUIExtensionsFrameURL); |
1398 | 1589 |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2206 browser()->tab_strip_model()->GetActiveWebContents(); | 2397 browser()->tab_strip_model()->GetActiveWebContents(); |
2207 scoped_ptr<DownloadUrlParameters> params( | 2398 scoped_ptr<DownloadUrlParameters> params( |
2208 DownloadUrlParameters::FromWebContents(web_contents, url)); | 2399 DownloadUrlParameters::FromWebContents(web_contents, url)); |
2209 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); | 2400 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); |
2210 download_manager->DownloadUrl(params.Pass()); | 2401 download_manager->DownloadUrl(params.Pass()); |
2211 observer->WaitForFinished(); | 2402 observer->WaitForFinished(); |
2212 | 2403 |
2213 // Verify that download shelf is not shown. | 2404 // Verify that download shelf is not shown. |
2214 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 2405 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
2215 } | 2406 } |
OLD | NEW |