chromium/components/safe_browsing/content/browser/ui_manager_unittest.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/safe_browsing/content/browser/ui_manager.h"

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/mock_callback.h"
#include "base/values.h"
#include "components/prefs/testing_pref_service.h"
#include "components/safe_browsing/content/browser/safe_browsing_blocking_page.h"
#include "components/safe_browsing/content/browser/safe_browsing_blocking_page_factory.h"
#include "components/safe_browsing/content/browser/safe_browsing_controller_client.h"
#include "components/safe_browsing/content/browser/unsafe_resource_util.h"
#include "components/safe_browsing/core/browser/db/util.h"
#include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/security_interstitials/content/security_interstitial_controller_client.h"
#include "components/security_interstitials/content/settings_page_helper.h"
#include "components/security_interstitials/core/base_safe_browsing_error_ui.h"
#include "components/security_interstitials/core/metrics_helper.h"
#include "components/security_interstitials/core/unsafe_resource.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

BrowserThread;

static const char* kGoodURL =;
static const char* kGoodIpAddress =;
static const char* kBadURL =;
static const char* kBadURLWithAlternateScheme =;
static const char* kBadURLWithPath =;
static const char* kIpAddress =;
static const char* kIpAddressAlternatePathAndScheme =;
static const char* kRedirectURL =;
static const char* kAnotherRedirectURL =;

namespace safe_browsing {

class SafeBrowsingCallbackWaiter {};

// A test blocking page that does not create windows.
class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage {};

// A factory that creates TestSafeBrowsingBlockingPages.
class TestSafeBrowsingBlockingPageFactory
    : public SafeBrowsingBlockingPageFactory {};

class TestSafeBrowsingUIManagerDelegate
    : public SafeBrowsingUIManager::Delegate {};

class SafeBrowsingUIManagerTest : public content::RenderViewHostTestHarness {};

TEST_F(SafeBrowsingUIManagerTest, Allowlist) {}

TEST_F(SafeBrowsingUIManagerTest, AllowlistIgnoresSitesNotAdded) {}

TEST_F(SafeBrowsingUIManagerTest,
       PendingAllowlistOnlyAddedOnceForSameNavigation) {}

TEST_F(SafeBrowsingUIManagerTest, AllowlistRemembersThreatType) {}

TEST_F(SafeBrowsingUIManagerTest, Allowlisted_RedirectChain) {}

TEST_F(SafeBrowsingUIManagerTest, AllowlistIgnoresPath) {}

TEST_F(SafeBrowsingUIManagerTest, AllowlistIgnoresScheme) {}

TEST_F(SafeBrowsingUIManagerTest, AllowlistIPAddress) {}

TEST_F(SafeBrowsingUIManagerTest, AllowlistIgnoresThreatType) {}

TEST_F(SafeBrowsingUIManagerTest, UICallbackProceed) {}

TEST_F(SafeBrowsingUIManagerTest, UICallbackDontProceed) {}

TEST_F(SafeBrowsingUIManagerTest, IOCallbackProceed) {}

TEST_F(SafeBrowsingUIManagerTest, IOCallbackDontProceed) {}

namespace {

// A WebContentsDelegate that records whether
// VisibleSecurityStateChanged() was called.
class SecurityStateWebContentsDelegate : public content::WebContentsDelegate {};

}  // namespace

// Tests that the WebContentsDelegate is notified of a visible security
// state change when a blocking page is shown.
TEST_F(SafeBrowsingUIManagerTest, VisibleSecurityStateChanged) {}

TEST_F(SafeBrowsingUIManagerTest, ShowBlockPageNoCallback) {}

TEST_F(SafeBrowsingUIManagerTest, NoInterstitialInExtensions) {}

TEST_F(SafeBrowsingUIManagerTest, DisplayInterstitial) {}

TEST_F(SafeBrowsingUIManagerTest, DisplayInterstitial_PostCommitInterstitial) {}

TEST_F(SafeBrowsingUIManagerTest, InvalidRenderFrameHostId) {}

// Regression test for https://g-issues.chromium.org/issues/327838835
TEST_F(SafeBrowsingUIManagerTest,
       DontSendClientSafeBrowsingWarningShownReportNullWebContents) {}

TEST_F(SafeBrowsingUIManagerTest,
       AllowlistSetSeverestThreatTypeInRedirectChain) {}

}  // namespace safe_browsing