| Index: content/browser/download/download_browsertest.cc
|
| diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc
|
| index 73a21c408207a271a21ceab8136128c8b34484cc..c6eb959ff887b3d53ed134c06e0d638f105bf715 100644
|
| --- a/content/browser/download/download_browsertest.cc
|
| +++ b/content/browser/download/download_browsertest.cc
|
| @@ -1517,7 +1517,7 @@ IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest, CancelResumingDownload) {
|
| ASSERT_FALSE(intermediate_path.empty());
|
| EXPECT_TRUE(base::PathExists(intermediate_path));
|
|
|
| - // Resume and remove download. We expect only a single OnDownloadCreated()
|
| + // Resume and cancel download. We expect only a single OnDownloadCreated()
|
| // call, and that's for the second download created below.
|
| MockDownloadManagerObserver dm_observer(
|
| DownloadManagerForShell(initiator_shell_for_resumption()));
|
| @@ -1556,6 +1556,76 @@ IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest, CancelResumingDownload) {
|
| EXPECT_TRUE(EnsureNoPendingDownloads());
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest, RemoveResumedDownload) {
|
| + TestDownloadRequestHandler::Parameters parameters =
|
| + TestDownloadRequestHandler::Parameters::WithSingleInterruption();
|
| + TestDownloadRequestHandler request_handler;
|
| + request_handler.StartServing(parameters);
|
| +
|
| + DownloadItem* download = StartDownloadAndReturnItem(
|
| + initiator_shell_for_resumption(), request_handler.url());
|
| + WaitForInterrupt(download);
|
| +
|
| + base::FilePath intermediate_path(download->GetFullPath());
|
| + base::FilePath target_path(download->GetTargetFilePath());
|
| + ASSERT_FALSE(intermediate_path.empty());
|
| + EXPECT_TRUE(base::PathExists(intermediate_path));
|
| + EXPECT_FALSE(base::PathExists(target_path));
|
| +
|
| + // Resume and remove download. We don't expect OnDownloadCreated() calls.
|
| + MockDownloadManagerObserver dm_observer(
|
| + DownloadManagerForShell(initiator_shell_for_resumption()));
|
| + EXPECT_CALL(dm_observer, OnDownloadCreated(_, _)).Times(0);
|
| +
|
| + PrepareToResume();
|
| + download->Resume();
|
| + WaitForInProgress(download);
|
| +
|
| + download->Remove();
|
| +
|
| + // The intermediate file should now be gone.
|
| + RunAllPendingInMessageLoop(BrowserThread::FILE);
|
| + RunAllPendingInMessageLoop();
|
| + EXPECT_FALSE(base::PathExists(intermediate_path));
|
| + EXPECT_FALSE(base::PathExists(target_path));
|
| + EXPECT_TRUE(EnsureNoPendingDownloads());
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_P(DownloadResumptionContentTest, CancelResumedDownload) {
|
| + TestDownloadRequestHandler::Parameters parameters =
|
| + TestDownloadRequestHandler::Parameters::WithSingleInterruption();
|
| + TestDownloadRequestHandler request_handler;
|
| + request_handler.StartServing(parameters);
|
| +
|
| + DownloadItem* download = StartDownloadAndReturnItem(
|
| + initiator_shell_for_resumption(), request_handler.url());
|
| + WaitForInterrupt(download);
|
| +
|
| + base::FilePath intermediate_path(download->GetFullPath());
|
| + base::FilePath target_path(download->GetTargetFilePath());
|
| + ASSERT_FALSE(intermediate_path.empty());
|
| + EXPECT_TRUE(base::PathExists(intermediate_path));
|
| + EXPECT_FALSE(base::PathExists(target_path));
|
| +
|
| + // Resume and remove download. We don't expect OnDownloadCreated() calls.
|
| + MockDownloadManagerObserver dm_observer(
|
| + DownloadManagerForShell(initiator_shell_for_resumption()));
|
| + EXPECT_CALL(dm_observer, OnDownloadCreated(_, _)).Times(0);
|
| +
|
| + PrepareToResume();
|
| + download->Resume();
|
| + WaitForInProgress(download);
|
| +
|
| + download->Cancel(true);
|
| +
|
| + // The intermediate file should now be gone.
|
| + RunAllPendingInMessageLoop(BrowserThread::FILE);
|
| + RunAllPendingInMessageLoop();
|
| + EXPECT_FALSE(base::PathExists(intermediate_path));
|
| + EXPECT_FALSE(base::PathExists(target_path));
|
| + EXPECT_TRUE(EnsureNoPendingDownloads());
|
| +}
|
| +
|
| // Check that the cookie policy is correctly updated when downloading a file
|
| // that redirects cross origin.
|
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) {
|
| @@ -1701,6 +1771,17 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadGZipWithNoContent) {
|
| // That's it. This should work without crashing.
|
| }
|
|
|
| +// Make sure that sniffed MIME types are correctly passed through to the
|
| +// download item.
|
| +IN_PROC_BROWSER_TEST_F(DownloadContentTest, SniffedMimeType) {
|
| + GURL url = net::URLRequestMockHTTPJob::GetMockUrl("gzip-content.gz");
|
| + DownloadItem* item = StartDownloadAndReturnItem(shell(), url);
|
| + WaitForCompletion(item);
|
| +
|
| + EXPECT_STREQ("application/x-gzip", item->GetMimeType().c_str());
|
| + EXPECT_TRUE(item->GetOriginalMimeType().empty());
|
| +}
|
| +
|
| IN_PROC_BROWSER_TEST_F(DownloadContentTest, Spam) {
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
|
|
|
|