chromium/content/public/test/prerender_test_util.cc

// Copyright 2021 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/public/test/prerender_test_util.h"

#include <tuple>

#include "base/functional/callback_helpers.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/trace_event/typed_macros.h"
#include "base/types/cxx23_to_underlying.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/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/blink/public/common/features.h"

namespace content {
namespace test {
namespace {

constexpr char kAddSpeculationRuleScript[] =;

std::string ConvertEagernessToString(
    blink::mojom::SpeculationEagerness eagerness) {}

// Builds <script type="speculationrules"> element for prerendering.
std::string BuildScriptElementSpeculationRules(
    const std::vector<GURL>& prerendering_urls,
    std::optional<blink::mojom::SpeculationEagerness> eagerness,
    std::optional<std::string> no_vary_search_hint,
    const std::string& target_hint) {}

constexpr char kAddSpeculationRulePrefetchScript[] =;

PrerenderHostRegistry& GetPrerenderHostRegistry(WebContents* web_contents) {}

PrerenderHost* GetPrerenderHostById(WebContents* web_contents, int host_id) {}

PrerenderHost* GetPrerenderHostByUrl(WebContents* web_contents,
                                     const GURL& url) {}

}  // namespace

class PrerenderHostRegistryObserverImpl
    : public PrerenderHostRegistry::Observer {};

PrerenderHostRegistryObserver::PrerenderHostRegistryObserver(
    WebContents& web_contents)
    :{}

PrerenderHostRegistryObserver::~PrerenderHostRegistryObserver() = default;

void PrerenderHostRegistryObserver::WaitForTrigger(const GURL& url) {}

GURL PrerenderHostRegistryObserver::WaitForNextTrigger() {}

void PrerenderHostRegistryObserver::NotifyOnTrigger(
    const GURL& url,
    base::OnceClosure callback) {}

base::flat_set<GURL> PrerenderHostRegistryObserver::GetTriggeredUrls() const {}

class PrerenderHostObserverImpl : public PrerenderHost::Observer {};

PrerenderHostObserver::PrerenderHostObserver(WebContents& web_contents,
                                             int prerender_host)
    :{}

PrerenderHostObserver::PrerenderHostObserver(WebContents& web_contents,
                                             const GURL& gurl)
    :{}

PrerenderHostObserver::~PrerenderHostObserver() = default;

void PrerenderHostObserver::WaitForActivation() {}

void PrerenderHostObserver::WaitForHeaders() {}

void PrerenderHostObserver::WaitForDestroyed() {}

bool PrerenderHostObserver::was_activated() const {}

PrerenderHostCreationWaiter::PrerenderHostCreationWaiter() {}

int PrerenderHostCreationWaiter::Wait() {}

ScopedPrerenderFeatureList::ScopedPrerenderFeatureList() {}

PrerenderTestHelper::PrerenderTestHelper(const WebContents::Getter& fn)
    :{}

PrerenderTestHelper::~PrerenderTestHelper() = default;

void PrerenderTestHelper::RegisterServerRequestMonitor(
    net::test_server::EmbeddedTestServer* http_server) {}
void PrerenderTestHelper::RegisterServerRequestMonitor(
    net::test_server::EmbeddedTestServer& test_server) {}

// static
int PrerenderTestHelper::GetHostForUrl(WebContents& web_contents,
                                       const GURL& gurl) {}

int PrerenderTestHelper::GetHostForUrl(const GURL& gurl) {}

bool PrerenderTestHelper::HasNewTabHandle(int host_id) {}

void PrerenderTestHelper::WaitForPrerenderLoadCompletion(int host_id) {}

// static
void PrerenderTestHelper::WaitForPrerenderLoadCompletion(
    WebContents& web_contents,
    const GURL& gurl) {}

void PrerenderTestHelper::WaitForPrerenderLoadCompletion(const GURL& gurl) {}

int PrerenderTestHelper::AddPrerender(const GURL& prerendering_url,
                                      int32_t world_id) {}

int PrerenderTestHelper::AddPrerender(
    const GURL& prerendering_url,
    std::optional<blink::mojom::SpeculationEagerness> eagerness,
    const std::string& target_hint,
    int32_t world_id) {}

int PrerenderTestHelper::AddPrerender(
    const GURL& prerendering_url,
    std::optional<blink::mojom::SpeculationEagerness> eagerness,
    std::optional<std::string> no_vary_search_hint,
    const std::string& target_hint,
    int32_t world_id) {}

void PrerenderTestHelper::AddPrerenderAsync(const GURL& prerendering_url,
                                            int32_t world_id) {}

void PrerenderTestHelper::AddPrerendersAsync(
    const std::vector<GURL>& prerendering_urls,
    std::optional<blink::mojom::SpeculationEagerness> eagerness,
    const std::string& target_hint,
    int32_t world_id) {}

void PrerenderTestHelper::AddPrerendersAsync(
    const std::vector<GURL>& prerendering_urls,
    std::optional<blink::mojom::SpeculationEagerness> eagerness,
    std::optional<std::string> no_vary_search_hint,
    const std::string& target_hint,
    int32_t world_id) {}

void PrerenderTestHelper::AddPrefetchAsync(const GURL& prefetch_url) {}

std::unique_ptr<PrerenderHandle>
PrerenderTestHelper::AddEmbedderTriggeredPrerenderAsync(
    const GURL& prerendering_url,
    PreloadingTriggerType trigger_type,
    const std::string& embedder_histogram_suffix,
    ui::PageTransition page_transition) {}

void PrerenderTestHelper::NavigatePrerenderedPage(int host_id,
                                                  const GURL& gurl) {}

void PrerenderTestHelper::CancelPrerenderedPage(int host_id) {}

// static
std::unique_ptr<content::TestNavigationObserver>
PrerenderTestHelper::NavigatePrimaryPageAsync(WebContents& web_contents,
                                              const GURL& gurl) {}

std::unique_ptr<content::TestNavigationObserver>
PrerenderTestHelper::NavigatePrimaryPageAsync(const GURL& gurl) {}

// static
void PrerenderTestHelper::NavigatePrimaryPage(WebContents& web_contents,
                                              const GURL& gurl) {}

void PrerenderTestHelper::NavigatePrimaryPage(const GURL& gurl) {}

void PrerenderTestHelper::OpenNewWindowWithoutOpener(WebContents& web_contents,
                                                     const GURL& url) {}

void PrerenderTestHelper::SetHoldback(PreloadingType preloading_type,
                                      PreloadingPredictor predictor,
                                      bool holdback) {}

void PrerenderTestHelper::SetHoldback(std::string_view preloading_type,
                                      std::string_view predictor,
                                      bool holdback) {}

::testing::AssertionResult PrerenderTestHelper::VerifyPrerenderingState(
    const GURL& gurl) {}

// static
RenderFrameHost* PrerenderTestHelper::GetPrerenderedMainFrameHost(
    WebContents& web_contents,
    int host_id) {}

// static
RenderFrameHost* PrerenderTestHelper::GetPrerenderedMainFrameHost(
    WebContents& web_contents,
    const GURL& url) {}

RenderFrameHost* PrerenderTestHelper::GetPrerenderedMainFrameHost(int host_id) {}

RenderFrameHost* PrerenderTestHelper::GetPrerenderedMainFrameHost(
    const GURL& url) {}

int PrerenderTestHelper::GetRequestCount(const GURL& url) {}

net::test_server::HttpRequest::HeaderMap PrerenderTestHelper::GetRequestHeaders(
    const GURL& url) {}

void PrerenderTestHelper::WaitForRequest(const GURL& url, int count) {}

void PrerenderTestHelper::MonitorResourceRequest(
    const net::test_server::HttpRequest& request) {}

WebContents* PrerenderTestHelper::GetWebContents() {}

std::string PrerenderTestHelper::GenerateHistogramName(
    const std::string& histogram_base_name,
    content::PreloadingTriggerType trigger_type,
    const std::string& embedder_suffix) {}

ScopedPrerenderWebContentsDelegate::ScopedPrerenderWebContentsDelegate(
    WebContents& web_contents)
    :{}

ScopedPrerenderWebContentsDelegate::~ScopedPrerenderWebContentsDelegate() {}

PreloadingEligibility ScopedPrerenderWebContentsDelegate::IsPrerender2Supported(
    WebContents& web_contents) {}

}  // namespace test

}  // namespace content