chromium/components/subresource_filter/content/shared/browser/activation_state_computing_navigation_throttle_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/subresource_filter/content/shared/browser/activation_state_computing_navigation_throttle.h"

#include <memory>
#include <optional>
#include <utility>
#include <vector>

#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/test_simple_task_runner.h"
#include "components/subresource_filter/content/shared/common/subresource_filter_utils.h"
#include "components/subresource_filter/core/browser/async_document_subresource_filter.h"
#include "components/subresource_filter/core/browser/async_document_subresource_filter_test_utils.h"
#include "components/subresource_filter/core/common/constants.h"
#include "components/subresource_filter/core/common/scoped_timers.h"
#include "components/subresource_filter/core/common/test_ruleset_creator.h"
#include "components/subresource_filter/core/common/test_ruleset_utils.h"
#include "components/subresource_filter/core/mojom/subresource_filter.mojom.h"
#include "components/url_pattern_index/proto/rules.pb.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_renderer_host.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace subresource_filter {

proto;

// The tests are parameterized by a bool which enables speculative main frame
// activation computation in DRYRUN mode. In practice, this will correspond to
// the kAdTagging feature.
class ActivationStateComputingNavigationThrottleTest
    : public content::RenderViewHostTestHarness,
      public content::WebContentsObserver,
      public ::testing::WithParamInterface<bool> {};

ActivationStateComputingThrottleMainFrameTest;
ActivationStateComputingThrottleSubFrameTest;

TEST_P(ActivationStateComputingThrottleMainFrameTest, Activate) {}

TEST_P(ActivationStateComputingThrottleMainFrameTest,
       NoPageActivationNotification_NoActivation) {}

TEST_P(ActivationStateComputingThrottleMainFrameTest,
       AllowlistDoesNotApply_CausesActivation) {}

TEST_P(ActivationStateComputingThrottleMainFrameTest,
       Allowlisted_DisablesFiltering) {}

TEST_P(ActivationStateComputingThrottleSubFrameTest, Activate) {}

TEST_P(ActivationStateComputingThrottleSubFrameTest,
       AllowlistDoesNotApply_CausesActivation) {}

TEST_P(ActivationStateComputingThrottleSubFrameTest,
       Allowlisted_DisableDocumentFiltering) {}

TEST_P(ActivationStateComputingThrottleSubFrameTest,
       Allowlisted_DisablesGenericRules) {}

TEST_P(ActivationStateComputingThrottleSubFrameTest, DryRunIsPropagated) {}

TEST_P(ActivationStateComputingThrottleSubFrameTest,
       DryRunWithLoggingIsPropagated) {}

TEST_P(ActivationStateComputingThrottleSubFrameTest, DisabledStatePropagated) {}

TEST_P(ActivationStateComputingThrottleSubFrameTest, DisabledStatePropagated2) {}

// TODO(crbug.com/40155196): A test is needed to verify that
// ComputeActivationState was called appropriately.  Previously this was done
// via looking at performance histograms, but those are now obsolete.

TEST_P(ActivationStateComputingThrottleSubFrameTest, SpeculationWithDelay) {}

INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();

}  // namespace subresource_filter