chromium/content/browser/preloading/prerender/prerender_host_unittest.cc

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

#include "content/browser/preloading/prerender/prerender_host.h"
#include <memory>

#include "base/functional/bind.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/browser/preloading/preloading.h"
#include "content/browser/preloading/prerender/prerender_attributes.h"
#include "content/browser/preloading/prerender/prerender_features.h"
#include "content/browser/preloading/prerender/prerender_final_status.h"
#include "content/browser/preloading/prerender/prerender_host.h"
#include "content/browser/preloading/prerender/prerender_host_registry.h"
#include "content/browser/preloading/prerender/prerender_metrics.h"
#include "content/public/browser/preloading.h"
#include "content/public/browser/preloading_data.h"
#include "content/public/test/mock_web_contents_observer.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/preloading_test_util.h"
#include "content/public/test/prerender_test_util.h"
#include "content/test/mock_commit_deferring_condition.h"
#include "content/test/navigation_simulator_impl.h"
#include "content/test/test_render_frame_host.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
#include "net/http/http_request_headers.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/public/common/loader/loader_constants.h"
#include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom-shared.h"

namespace content {
namespace {

_;

TEST(IsActivationHeaderMatchTest, OrderInsensitive) {}

TEST(IsActivationHeaderMatchTest, KeyCaseInsensitive) {}

TEST(IsActivationHeaderMatchTest, ValueCaseInsensitive) {}

TEST(IsActivationHeaderMatchTest, CalculateMismatchedHeaders) {}

ExpectedReadyForActivationState;

// Finish a prerendering navigation that was already started with
// CreateAndStartHost().
void CommitPrerenderNavigation(
    PrerenderHost& host,
    ExpectedReadyForActivationState ready_for_activation =
        ExpectedReadyForActivationState(true),
    scoped_refptr<net::HttpResponseHeaders> headers = nullptr) {}

std::unique_ptr<NavigationSimulatorImpl> CreateActivation(
    const GURL& prerendering_url,
    WebContentsImpl& web_contents) {}

class PrerenderHostTest : public RenderViewHostImplTestHarness {};

class NoVarySearchHeaderPrerenderHostTest
    : public PrerenderHostTest,
      public ::testing::WithParamInterface<bool> {};

TEST_P(NoVarySearchHeaderPrerenderHostTest, IsNoVarySearchHeaderSet) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(PrerenderHostTest, Activate) {}

TEST_F(PrerenderHostTest, DontActivate) {}

// Tests that cross-site main frame navigations in a prerendered page cannot
// occur even if they start after the prerendered page has been reserved for
// activation.
TEST_F(PrerenderHostTest, MainFrameNavigationForReservedHost) {}

// Tests that an activation can successfully commit after the prerendering page
// has updated its PageState.
TEST_F(PrerenderHostTest, ActivationAfterPageStateUpdate) {}

// Test that WebContentsObserver::LoadProgressChanged is not invoked when the
// page gets loaded while prerendering but is invoked on prerender activation.
// Check that in case the load is incomplete with load progress
// `kPartialLoadProgress`, we would see
// LoadProgressChanged(kPartialLoadProgress) called on activation.
TEST_F(PrerenderHostTest, LoadProgressChangedInvokedOnActivation) {}

TEST_F(PrerenderHostTest, DontCancelPrerenderWhenTriggerGetsHidden) {}

TEST_F(PrerenderHostTest, CancelActivationFromHiddenPage) {}

TEST_F(PrerenderHostTest, DontCancelPrerenderWhenTriggerGetsVisible) {}

// Skip this test on Android as it doesn't support the OCCLUDED state.
#if !BUILDFLAG(IS_ANDROID)
TEST_F(PrerenderHostTest, DontCancelPrerenderWhenTriggerGetsOcculded) {}
#endif

TEST_F(PrerenderHostTest, UrlMatchPredicate) {}

// Regression test for https://crbug.com/1366046: This test will crash if
// PrerenderHost is set to "ready_for_activation" after getting canceled.
TEST_F(PrerenderHostTest, CanceledPrerenderCannotBeReadyForActivation) {}

TEST(AreHttpRequestHeadersCompatible, IgnoreRTT) {}

}  // namespace
}  // namespace content