chromium/components/blocked_content/safe_browsing_triggered_popup_blocker_unittest.cc

// Copyright 2017 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/blocked_content/safe_browsing_triggered_popup_blocker.h"

#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "components/blocked_content/popup_blocker.h"
#include "components/blocked_content/popup_blocker_tab_helper.h"
#include "components/blocked_content/popup_navigation_delegate.h"
#include "components/blocked_content/test/test_popup_navigation_delegate.h"
#include "components/content_settings/browser/page_specific_content_settings.h"
#include "components/content_settings/browser/test_page_specific_content_settings_delegate.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/subresource_filter/content/browser/fake_safe_browsing_database_manager.h"
#include "components/subresource_filter/content/browser/safe_browsing_page_activation_throttle.h"
#include "components/subresource_filter/content/browser/subresource_filter_observer_manager.h"
#include "components/subresource_filter/content/browser/subresource_filter_safe_browsing_client.h"
#include "components/subresource_filter/content/shared/common/subresource_filter_utils.h"
#include "components/subresource_filter/core/browser/subresource_filter_constants.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/user_prefs/user_prefs.h"
#include "components/variations/scoped_variations_ids_provider.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/test/mock_navigation_handle.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_navigation_throttle_inserter.h"
#include "content/public/test/test_renderer_host.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/frame/frame.mojom.h"
#include "third_party/blink/public/mojom/window_features/window_features.mojom.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
#include "url/gurl.h"

namespace blocked_content {

class SafeBrowsingTriggeredPopupBlockerTestBase
    : public content::RenderViewHostTestHarness {};

class SafeBrowsingTriggeredPopupBlockerTest
    : public SafeBrowsingTriggeredPopupBlockerTestBase {};

struct RedirectSamplesAndResults {};

// We always make our decision to trigger on the last entry in the chain.
TEST_F(SafeBrowsingTriggeredPopupBlockerTest,
       MatchOnSafeBrowsingWithRedirectChain) {}

TEST_F(SafeBrowsingTriggeredPopupBlockerTest, MatchingURL_BlocksPopupAndLogs) {}

TEST_F(SafeBrowsingTriggeredPopupBlockerTest,
       MatchingURL_BlocksPopupFromOpenURL) {}

TEST_F(SafeBrowsingTriggeredPopupBlockerTest,
       MatchingURLTrusted_DoesNotBlockPopup) {}

TEST_F(SafeBrowsingTriggeredPopupBlockerTest, NoMatch_NoBlocking) {}

class SafeBrowsingTriggeredPopupBlockerDefaultTest
    : public SafeBrowsingTriggeredPopupBlockerTestBase {};

TEST_F(SafeBrowsingTriggeredPopupBlockerDefaultTest, FeatureEnabledByDefault) {}

TEST_F(SafeBrowsingTriggeredPopupBlockerTest, OnlyBlockOnMatchingUrls) {}

TEST_F(SafeBrowsingTriggeredPopupBlockerTest,
       SameDocumentNavigation_MaintainsBlocking) {}

TEST_F(SafeBrowsingTriggeredPopupBlockerTest,
       FailNavigation_MaintainsBlocking) {}

TEST_F(SafeBrowsingTriggeredPopupBlockerTest, LogActions) {}

class SafeBrowsingTriggeredPopupBlockerFilterAdsDisabledTest
    : public SafeBrowsingTriggeredPopupBlockerTestBase {};

TEST_F(SafeBrowsingTriggeredPopupBlockerFilterAdsDisabledTest,
       WarningMatchWithoutAdBlockOnAbusiveSites_OnlyLogs) {}

class SafeBrowsingTriggeredPopupBlockerFilterAdsEnabledTest
    : public SafeBrowsingTriggeredPopupBlockerTestBase {};

TEST_F(SafeBrowsingTriggeredPopupBlockerFilterAdsEnabledTest,
       WarningMatchWithAdBlockOnAbusiveSites_OnlyLogs) {}

TEST_F(SafeBrowsingTriggeredPopupBlockerTest, NonPrimaryFrameTree) {}

class SafeBrowsingTriggeredPopupBlockerFencedFrameTest
    : public SafeBrowsingTriggeredPopupBlockerTest {};

// Ensures that the popup blocker is not triggered by a fenced frame.
TEST_F(SafeBrowsingTriggeredPopupBlockerFencedFrameTest,
       ShouldNotTriggerPopupBlocker) {}

}  // namespace blocked_content