#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "base/base64.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_file_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_browsertest_utils.h"
#include "chrome/browser/download/download_commands.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_crx_util.h"
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_item_web_app_data.h"
#include "chrome/browser/download/download_manager_utils.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/download/download_request_limiter.h"
#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/download/download_target_determiner.h"
#include "chrome/browser/download/download_test_file_activity_observer.h"
#include "chrome/browser/download/simple_download_manager_coordinator_factory.h"
#include "chrome/browser/extensions/install_verifier.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_browsertest_util.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
#include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/download/public/common/download_danger_type.h"
#include "components/download/public/common/download_features.h"
#include "components/download/public/common/download_interrupt_reasons.h"
#include "components/download/public/common/download_item.h"
#include "components/download/public/common/in_progress_download_manager.h"
#include "components/history/content/browser/download_conversions.h"
#include "components/history/core/browser/download_constants.h"
#include "components/history/core/browser/download_row.h"
#include "components/history/core/browser/history_service.h"
#include "components/infobars/content/content_infobar_manager.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "components/infobars/core/infobar.h"
#include "components/lookalikes/core/safety_tip_test_utils.h"
#include "components/metrics/content/subprocess_metrics_provider.h"
#include "components/permissions/permission_request_manager.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/content/browser/safe_browsing_service_interface.h"
#include "components/safe_browsing/content/common/file_type_policies_test_util.h"
#include "components/safe_browsing/content/common/proto/download_file_types.pb.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/security_state/core/security_state.h"
#include "components/services/quarantine/test_support.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/device_service.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/download_request_utils.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/storage_partition_config.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/download_test_observer.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/hit_test_region_observer.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/slow_download_http_response.h"
#include "content/public/test/test_download_http_response.h"
#include "content/public/test/test_file_error_injector.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/url_loader_interceptor.h"
#include "content/public/test/url_loader_monitor.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/scoped_ignore_content_verifier_for_test.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/features.h"
#include "net/base/filename_util.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/embedded_test_server/request_handler_util.h"
#include "net/test/scoped_mutually_exclusive_feature_list.h"
#include "net/test/url_request/url_request_mock_http_job.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "pdf/buildflags.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
#include "services/device/public/mojom/wake_lock_provider.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/loader/network_utils.h"
#include "third_party/blink/public/common/loader/referrer_utils.h"
#include "third_party/blink/public/common/switches.h"
#include "third_party/blink/public/mojom/context_menu/context_menu.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/ui_base_features.h"
#include "ui/gfx/geometry/point_conversions.h"
#if !BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/download/bubble/download_bubble_ui_controller.h"
#include "chrome/browser/download/bubble/download_display_controller.h"
#include "chrome/browser/ui/download/download_display.h"
#endif
#if BUILDFLAG(FULL_SAFE_BROWSING)
#include "chrome/browser/safe_browsing/download_protection/download_feedback_service.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_service.h"
#include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
#endif
#if BUILDFLAG(ENABLE_PDF)
#include "base/test/with_feature_override.h"
#include "chrome/browser/pdf/pdf_extension_test_util.h"
#include "chrome/browser/pdf/test_pdf_viewer_stream_manager.h"
#include "chrome/browser/ui/pdf/chrome_pdf_document_helper_client.h"
#include "components/pdf/browser/pdf_document_helper.h"
#include "pdf/pdf_features.h"
#endif
BrowserContext;
BrowserThread;
DownloadManager;
URLLoaderInterceptor;
URLLoaderMonitor;
WebContents;
DownloadItem;
DownloadUrlParameters;
Extension;
URLRequestMockHTTPJob;
EmbeddedTestServer;
namespace {
class InnerWebContentsAttachedWaiter : public content::WebContentsObserver { … };
void VerifyNewDownloadId(uint32_t expected_download_id, uint32_t download_id) { … }
class DownloadTestContentBrowserClient : public content::ContentBrowserClient { … };
class CreatedObserver : public content::DownloadManager::Observer { … };
class OnCanDownloadDecidedObserver { … };
class PercentWaiter : public download::DownloadItem::Observer { … };
const char kGoodCrxId[] = …;
const char kGoodCrxPath[] = …;
const char kLargeThemeCrxId[] = …;
const char kLargeThemePath[] = …;
const char kUserScriptPath[] = …;
class DownloadsHistoryDataCollector { … };
bool WasAutoOpened(DownloadItem* item) { … }
bool IsDownloadExternallyRemoved(DownloadItem* item) { … }
#if !BUILDFLAG(IS_CHROMEOS)
void SetHiddenDownloadCallback(DownloadItem* item,
download::DownloadInterruptReason reason) { … }
#endif
class SimpleDownloadManagerCoordinatorWaiter
: public download::SimpleDownloadManagerCoordinator::Observer { … };
void CreateCompletedDownload(content::DownloadManager* download_manager,
const std::string& guid,
const base::FilePath target_path,
std::vector<GURL> url_chain,
int64_t file_size) { … }
#if !BUILDFLAG(IS_CHROMEOS)
bool IsDownloadUiVisible(BrowserWindow* window) { … }
bool IsDownloadDetailedUiVisible(BrowserWindow* window) { … }
#endif
}
class HistoryObserver : public DownloadHistory::Observer { … };
class DownloadReferrerPolicyTest
: public DownloadTestBase,
public ::testing::WithParamInterface<network::mojom::ReferrerPolicy> { … };
INSTANTIATE_TEST_SUITE_P(…);
class MPArchDownloadTest : public DownloadTestBase { … };
class PrerenderDownloadTest : public MPArchDownloadTest { … };
namespace {
class FakeDownloadProtectionService
: public safe_browsing::DownloadProtectionService { … };
class FakeSafeBrowsingService : public safe_browsing::TestSafeBrowsingService { … };
class TestSafeBrowsingServiceFactory
: public safe_browsing::SafeBrowsingServiceFactory { … };
class DownloadTestWithFakeSafeBrowsing : public DownloadTestBase { … };
class DownloadWakeLockTest : public DownloadTestBase { … };
}
DownloadTest;
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeType) { … }
#if BUILDFLAG(IS_WIN)
IN_PROC_BROWSER_TEST_F(DownloadTest, Quarantine_DependsOnLocalConfig) {
embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory());
ASSERT_TRUE(embedded_test_server()->Start());
GURL url =
embedded_test_server()->GetURL("/" + std::string(kDownloadTest1Path));
DownloadAndWait(browser(), url);
EXPECT_EQ(1, browser()->tab_strip_model()->count());
base::FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
base::FilePath downloaded_file(DestinationFile(browser(), file));
base::ScopedAllowBlockingForTesting allow_blocking;
EXPECT_TRUE(quarantine::IsFileQuarantined(downloaded_file, url, GURL()));
CheckDownload(browser(), file, file);
}
IN_PROC_BROWSER_TEST_F(DownloadTest, CheckLocalhostZone_DependsOnLocalConfig) {
embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory());
ASSERT_TRUE(embedded_test_server()->Start());
GURL url =
embedded_test_server()->GetURL("localhost", "/downloads/a_zip_file.zip");
DownloadAndWait(browser(), url);
base::FilePath file(FILE_PATH_LITERAL("a_zip_file.zip"));
base::FilePath downloaded_file(DestinationFile(browser(), file));
EXPECT_FALSE(quarantine::IsFileQuarantined(downloaded_file, GURL(), GURL()));
}
IN_PROC_BROWSER_TEST_F(DownloadTest, CheckLocalFileZone_DependsOnLocalConfig) {
base::FilePath source_file = GetTestDataDirectory()
.AppendASCII("downloads")
.AppendASCII("a_zip_file.zip");
GURL url = net::FilePathToFileURL(source_file);
DownloadAndWait(browser(), url);
base::FilePath file(FILE_PATH_LITERAL("a_zip_file.zip"));
base::FilePath downloaded_file(DestinationFile(browser(), file));
EXPECT_FALSE(quarantine::IsFileQuarantined(downloaded_file, GURL(), GURL()));
}
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadMimeTypeSelect) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, NoDownload) { … }
static std::unique_ptr<net::test_server::HttpResponse>
RespondWithContentTypeHandler(const net::test_server::HttpRequest& request) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, MimeTypesToShowNotDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadResourceThrottleCancels) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest,
DownloadRequestLimiterDisallowsAnchorDownloadTag) { … }
IN_PROC_BROWSER_TEST_F(PrerenderDownloadTest,
DownloadRequestLimiterIsUnaffectedByPrerendering) { … }
class FencedFrameDownloadTest : public MPArchDownloadTest { … };
IN_PROC_BROWSER_TEST_F(FencedFrameDownloadTest,
DownloadRequestLimiterIsUnaffectedByFencedFrame) { … }
IN_PROC_BROWSER_TEST_F(FencedFrameDownloadTest,
FencedFrameSandboxFlagBlockDownload) { … }
IN_PROC_BROWSER_TEST_F(FencedFrameDownloadTest, NetworkCutoffBlockSaveImageAs) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, ContentDisposition) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, UnknownSize) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, KnownSize) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_IncognitoRegular) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DontCloseNewTab1) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CloseNewTab1) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DontCloseNewTab2) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DontCloseNewTab3) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CloseNewTab2) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CloseNewTab3) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CloseNewTab4) { … }
static std::unique_ptr<net::test_server::HttpResponse>
ServerRedirectRequestHandler(const net::test_server::HttpRequest& request) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_DownloadHistoryCheck …
#else
#define MAYBE_DownloadHistoryCheck …
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_DownloadHistoryCheck) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadHistoryDangerCheck) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, BrowserCloseAfterDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, AnchorDownloadTag) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, UserScriptDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_AutoOpenByUser) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstall) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallDenysPermissions) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInstallAcceptPermissions) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CrxInvalid) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CrxLargeTheme) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrl) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, TransientDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, NullInitiator) { … }
class DownloadTestSplitCacheEnabledBase : public DownloadTest { … };
enum class SplitCacheTestCase { … };
const struct { … } kTestCaseToFeatureMapping[] = …;
std::string GetSplitCacheTestName(SplitCacheTestCase test_case) { … }
class DownloadTestSplitCacheEnabled
: public DownloadTestSplitCacheEnabledBase,
public testing::WithParamInterface<SplitCacheTestCase> { … };
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(ENABLE_PDF)
class PdfDownloadTestSplitCacheEnabled
: public DownloadTestSplitCacheEnabledBase,
public testing::WithParamInterface<std::tuple<bool, SplitCacheTestCase>> { … };
IN_PROC_BROWSER_TEST_P(
PdfDownloadTestSplitCacheEnabled,
SaveMainFramePdfFromPrimaryFrameContextMenuBrowserInitiatedNavigation) { … }
IN_PROC_BROWSER_TEST_P(
PdfDownloadTestSplitCacheEnabled,
SaveMainFramePdfFromPrimaryFrameContextMenuRendererInitiatedNavigation) { … }
IN_PROC_BROWSER_TEST_P(
PdfDownloadTestSplitCacheEnabled,
SaveMainFramePdfFromExtensionFrameContextMenuBrowserInitiatedNavigation) { … }
IN_PROC_BROWSER_TEST_P(
PdfDownloadTestSplitCacheEnabled,
SaveMainFramePdfFromExtensionFrameContextMenuRendererInitiatedNavigation) { … }
IN_PROC_BROWSER_TEST_P(
PdfDownloadTestSplitCacheEnabled,
SaveMainFramePdfFromContentFrameContextMenuBrowserInitiatedNavigation) { … }
IN_PROC_BROWSER_TEST_P(
PdfDownloadTestSplitCacheEnabled,
SaveMainFramePdfFromContentFrameContextMenuRendererInitiatedNavigation) { … }
IN_PROC_BROWSER_TEST_P(PdfDownloadTestSplitCacheEnabled,
SaveSubframePdfFromPdfUIIsolationInfo) { … }
#endif
IN_PROC_BROWSER_TEST_P(DownloadTestSplitCacheEnabled,
SaveSubframeImageFromContextMenuIsolationInfo) { … }
#if BUILDFLAG(ENABLE_PDF)
IN_PROC_BROWSER_TEST_P(PdfDownloadTestSplitCacheEnabled,
SaveSubframePdfFromContextMenuIsolationInfo) { … }
INSTANTIATE_TEST_SUITE_P(…);
#endif
class DownloadTestWithHistogramTester : public DownloadTest { … };
IN_PROC_BROWSER_TEST_F(DownloadTestWithHistogramTester,
DISABLED_SavePageNonHTMLViaGet) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH) && \
(!defined(NDEBUG) || defined(MEMORY_SANITIZER))
#define MAYBE_SaveLargeImage …
#elif BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \
BUILDFLAG(IS_CHROMEOS)
#define MAYBE_SaveLargeImage …
#else
#define MAYBE_SaveLargeImage …
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_SaveLargeImage) { … }
static std::unique_ptr<net::test_server::HttpResponse>
FilterMethodSpecificURLsHandler(const net::test_server::HttpRequest& request) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaPost) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, SaveImageInPostPage) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_DownloadErrorsServer …
#else
#define MAYBE_DownloadErrorsServer …
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_DownloadErrorsServer) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DownloadErrorsServerNavigate404) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_DownloadErrorsFile …
#else
#define MAYBE_DownloadErrorsFile …
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_DownloadErrorsFile) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadErrorReadonlyFolder) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadDangerousBlobData) { … }
static std::unique_ptr<net::test_server::HttpResponse>
EchoReferrerRequestHandler(const net::test_server::HttpRequest& request) { … }
IN_PROC_BROWSER_TEST_P(DownloadReferrerPolicyTest,
AltClickDownloadReferrerPolicy) { … }
IN_PROC_BROWSER_TEST_P(DownloadReferrerPolicyTest, SaveLinkAsReferrerPolicy) { … }
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_SaveLinkAsVsCrossOriginResourcePolicy …
#else
#define MAYBE_SaveLinkAsVsCrossOriginResourcePolicy …
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest,
MAYBE_SaveLinkAsVsCrossOriginResourcePolicy) { … }
IN_PROC_BROWSER_TEST_P(DownloadReferrerPolicyTest,
DISABLED_SaveImageAsReferrerPolicy) { … }
IN_PROC_BROWSER_TEST_P(DownloadReferrerPolicyTest,
DownloadCrossDomainReferrerPolicy) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, TestMultipleDownloadsRequests) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, MultipleDownloadsFromIframeSrcdoc) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest,
CrossOriginRedirectDownloadFromAnchorDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest,
MultipleCrossOriginRedirectDownloadsFromAnchorDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Renaming) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_DownloadTest_CrazyFilenames …
#else
#define MAYBE_DownloadTest_CrazyFilenames …
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_DownloadTest_CrazyFilenames) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_Remove) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_PauseResumeCancel) { … }
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \
defined(ARCH_CPU_ARM_FAMILY)
#define MAYBE_DownloadTest_PercentComplete …
#else
#define MAYBE_DownloadTest_PercentComplete …
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_DownloadTest_PercentComplete) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_NoPrompt) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_WithPrompt) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_WithPromptAlways) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_Automatic) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, Resumption_MultipleAttempts) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_GZipWithNoContent) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, SecurityLevels) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, FileExistenceCheckOpeningDownloadsPage) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CrossOriginDownloadNavigatesIframe) { … }
IN_PROC_BROWSER_TEST_F(DownloadWakeLockTest,
DISABLED_WakeLockAcquireAndCancel) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DownloadLargeDataURL) { … }
class InProgressDownloadTest : public DownloadTest { … };
IN_PROC_BROWSER_TEST_F(InProgressDownloadTest,
ResumeInProgressDownloadBeforeLoadingHistory) { … }
IN_PROC_BROWSER_TEST_F(InProgressDownloadTest,
DownloadURLWithInProgressManager) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, SaveCanvasImage) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, ContextMenuSaveImageWithAcceptHeader) { … }
#if BUILDFLAG(FULL_SAFE_BROWSING)
namespace {
class DisableSafeBrowsingOnInProgressDownload
: public content::DownloadTestObserver { … };
}
IN_PROC_BROWSER_TEST_F(DownloadTest,
DangerousFileWithSBDisabledBeforeCompletion) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DangerousFileWithSBDisabledBeforeStart) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, SafeSupportedFile) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, FeedbackServiceDiscardDownload) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FeedbackServiceKeepDownload …
#else
#define MAYBE_FeedbackServiceKeepDownload …
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_FeedbackServiceKeepDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTestWithFakeSafeBrowsing,
SendUncommonDownloadReportIfUserProceed) { … }
IN_PROC_BROWSER_TEST_F(DownloadTestWithFakeSafeBrowsing,
SendDownloadReportIfUserProceedsDeepScanning) { … }
IN_PROC_BROWSER_TEST_F(DownloadTestWithFakeSafeBrowsing,
SendUncommonDownloadReportIfUserDiscard) { … }
IN_PROC_BROWSER_TEST_F(DownloadTestWithFakeSafeBrowsing,
NoUncommonDownloadReportIfIncognito) { … }
#endif
#if !BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_DownloadAndWait) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(DownloadTest, PerWindowShelf) {
embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory());
ASSERT_TRUE(embedded_test_server()->Start());
GURL url = embedded_test_server()->GetURL("/download-test3.gif");
base::FilePath download_file(
FILE_PATH_LITERAL("download-test3-attachment.gif"));
DownloadAndWait(browser(), url);
base::FilePath file(FILE_PATH_LITERAL("download-test3.gif"));
CheckDownload(browser(), download_file, file);
EXPECT_EQ(1, browser()->tab_strip_model()->count());
EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
EXPECT_TRUE(chrome::AddSelectedTabWithURL(
browser(), GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_TYPED));
EXPECT_EQ(2, browser()->tab_strip_model()->count());
EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
browser()->window()->GetDownloadShelf()->Close();
EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
browser()->tab_strip_model()->ActivateTabAt(
0, TabStripUserGestureDetails(
TabStripUserGestureDetails::GestureType::kOther));
EXPECT_EQ(2, browser()->tab_strip_model()->count());
EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
}
IN_PROC_BROWSER_TEST_F(DownloadTest, CloseShelfOnDownloadsTab) {
embedded_test_server()->ServeFilesFromDirectory(GetTestDataDirectory());
ASSERT_TRUE(embedded_test_server()->Start());
GURL url =
embedded_test_server()->GetURL("/" + std::string(kDownloadTest1Path));
DownloadAndWait(browser(), url);
EXPECT_EQ(1, browser()->tab_strip_model()->count());
EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
chrome::ShowDownloads(browser());
EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
}
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest,
DISABLED_IncognitoDownloadSurfaceVisibility) { … }
#if BUILDFLAG(IS_LINUX)
#define MAYBE_NewWindow …
#else
#define MAYBE_NewWindow …
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, MAYBE_NewWindow) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, PRE_DownloadTest_History) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_History) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, HiddenDownload) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_AutoOpenClosesSurface) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, CrxDenyInstallClosesSurface) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest, WebAppDownloadOnlyShowsUiInWebAppWindow) { … }
IN_PROC_BROWSER_TEST_F(DownloadTest,
RegularBrowserDownloadDoesNotShowInWebAppWindow) { … }
#endif
IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadFromWebApp) { … }