| 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 "chrome/browser/download/download_browsertest.h" | 5 #include "chrome/browser/download/download_browsertest.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 content::TestFileErrorInjector::FileErrorInfo error_info; | 424 content::TestFileErrorInjector::FileErrorInfo error_info; |
| 425 }; | 425 }; |
| 426 | 426 |
| 427 DownloadTest() {} | 427 DownloadTest() {} |
| 428 | 428 |
| 429 void SetUpOnMainThread() override { | 429 void SetUpOnMainThread() override { |
| 430 BrowserThread::PostTask( | 430 BrowserThread::PostTask( |
| 431 BrowserThread::IO, FROM_HERE, | 431 BrowserThread::IO, FROM_HERE, |
| 432 base::BindOnce(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); | 432 base::BindOnce(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
| 433 ASSERT_TRUE(InitialSetup()); | 433 ASSERT_TRUE(InitialSetup()); |
| 434 host_resolver()->AddRule("www.a.com", "127.0.0.1"); |
| 434 } | 435 } |
| 435 | 436 |
| 436 void TearDownOnMainThread() override { | 437 void TearDownOnMainThread() override { |
| 437 // Needs to be torn down on the main thread. file_activity_observer_ holds a | 438 // Needs to be torn down on the main thread. file_activity_observer_ holds a |
| 438 // reference to the ChromeDownloadManagerDelegate which should be destroyed | 439 // reference to the ChromeDownloadManagerDelegate which should be destroyed |
| 439 // on the UI thread. | 440 // on the UI thread. |
| 440 file_activity_observer_.reset(); | 441 file_activity_observer_.reset(); |
| 441 } | 442 } |
| 442 | 443 |
| 443 // Returning false indicates a failure of the setup, and should be asserted | 444 // Returning false indicates a failure of the setup, and should be asserted |
| (...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2804 ASSERT_EQ(img_url, download_items[0]->GetOriginalUrl()); | 2805 ASSERT_EQ(img_url, download_items[0]->GetOriginalUrl()); |
| 2805 base::FilePath file = download_items[0]->GetTargetFilePath(); | 2806 base::FilePath file = download_items[0]->GetTargetFilePath(); |
| 2806 // The contents of the file is the value of the Referer header if there was | 2807 // The contents of the file is the value of the Referer header if there was |
| 2807 // one. | 2808 // one. |
| 2808 EXPECT_TRUE(VerifyFile(file, "", 0)); | 2809 EXPECT_TRUE(VerifyFile(file, "", 0)); |
| 2809 } | 2810 } |
| 2810 | 2811 |
| 2811 // This test ensures that a cross-domain download correctly sets the referrer | 2812 // This test ensures that a cross-domain download correctly sets the referrer |
| 2812 // according to the referrer policy. | 2813 // according to the referrer policy. |
| 2813 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadCrossDomainReferrerPolicy) { | 2814 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadCrossDomainReferrerPolicy) { |
| 2814 host_resolver()->AddRule("www.a.com", "127.0.0.1"); | |
| 2815 embedded_test_server()->RegisterRequestHandler( | 2815 embedded_test_server()->RegisterRequestHandler( |
| 2816 base::Bind(&ServerRedirectRequestHandler)); | 2816 base::Bind(&ServerRedirectRequestHandler)); |
| 2817 embedded_test_server()->RegisterRequestHandler( | 2817 embedded_test_server()->RegisterRequestHandler( |
| 2818 base::Bind(&EchoReferrerRequestHandler)); | 2818 base::Bind(&EchoReferrerRequestHandler)); |
| 2819 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory()); | 2819 embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory()); |
| 2820 ASSERT_TRUE(embedded_test_server()->Start()); | 2820 ASSERT_TRUE(embedded_test_server()->Start()); |
| 2821 EnableFileChooser(true); | 2821 EnableFileChooser(true); |
| 2822 std::vector<DownloadItem*> download_items; | 2822 std::vector<DownloadItem*> download_items; |
| 2823 GetDownloads(browser(), &download_items); | 2823 GetDownloads(browser(), &download_items); |
| 2824 ASSERT_TRUE(download_items.empty()); | 2824 ASSERT_TRUE(download_items.empty()); |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3865 browser(), 1, | 3865 browser(), 1, |
| 3866 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 3866 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
| 3867 ui_test_utils::NavigateToURL(browser(), extension_url); | 3867 ui_test_utils::NavigateToURL(browser(), extension_url); |
| 3868 | 3868 |
| 3869 observer->WaitForFinished(); | 3869 observer->WaitForFinished(); |
| 3870 | 3870 |
| 3871 // Download shelf should close. | 3871 // Download shelf should close. |
| 3872 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 3872 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 3873 } | 3873 } |
| 3874 #endif // defined(OS_CHROMEOS) | 3874 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |