#include "content/browser/preloading/prerender/prerender_host_registry.h"
#include <cstdint>
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "content/browser/preloading/preloading.h"
#include "content/browser/preloading/preloading_confidence.h"
#include "content/browser/preloading/preloading_config.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_metrics.h"
#include "content/browser/preloading/speculation_rules/speculation_host_impl.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/site_instance_impl.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/preloading_test_util.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_browser_context.h"
#include "content/test/mock_commit_deferring_condition.h"
#include "content/test/navigation_simulator_impl.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
#include "net/base/load_flags.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/loader/mixed_content.mojom.h"
#include "third_party/blink/public/mojom/speculation_rules/speculation_rules.mojom.h"
namespace content {
namespace {
blink::mojom::SpeculationCandidatePtr CreatePrerenderCandidate(
const GURL& url) { … }
void SendCandidates(const std::vector<GURL>& urls,
mojo::Remote<blink::mojom::SpeculationHost>& remote) { … }
void SendCandidate(const GURL& url,
mojo::Remote<blink::mojom::SpeculationHost>& remote) { … }
const int kNoFrameTreeNodeId = …;
std::unique_ptr<NavigationSimulatorImpl> CreateActivation(
const GURL& prerendering_url,
WebContentsImpl& web_contents) { … }
void CommitPrerenderNavigation(PrerenderHost& host) { … }
class PrerenderHostRegistryTest : public RenderViewHostImplTestHarness { … };
TEST_F(PrerenderHostRegistryTest, CreateAndStartHost_SpeculationRule) { … }
TEST_F(PrerenderHostRegistryTest, CreateAndStartHost_Embedder_DirectURLInput) { … }
TEST_F(PrerenderHostRegistryTest, CreateAndStartHost_PreloadingConfigHoldback) { … }
TEST_F(PrerenderHostRegistryTest,
CreateAndStartHost_HoldbackOverride_Holdback) { … }
TEST_F(PrerenderHostRegistryTest, CreateAndStartHost_HoldbackOverride_Allowed) { … }
TEST_F(PrerenderHostRegistryTest, CreateAndStartHostForSameURL) { … }
class PrerenderHostRegistryLimitTest : public PrerenderHostRegistryTest { … };
TEST_F(PrerenderHostRegistryLimitTest, NumberLimit_Activation) { … }
TEST_F(PrerenderHostRegistryLimitTest, NumberLimit_SameOriginNavigateAway) { … }
TEST_F(PrerenderHostRegistryLimitTest, NumberLimit_CrossOriginNavigateAway) { … }
class PrerenderHostRegistryNewLimitAndSchedulerTest
: public PrerenderHostRegistryTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(PrerenderHostRegistryNewLimitAndSchedulerTest,
NewLimitAndScheduler_Eager) { … }
TEST_P(PrerenderHostRegistryNewLimitAndSchedulerTest,
NewLimitAndScheduler_NonEager) { … }
TEST_P(PrerenderHostRegistryNewLimitAndSchedulerTest,
NewLimitAndScheduler_Embedder) { … }
TEST_F(PrerenderHostRegistryTest,
ReserveHostToActivateBeforeReadyForActivation) { … }
TEST_F(PrerenderHostRegistryTest, CancelHost) { … }
TEST_F(PrerenderHostRegistryTest,
CancelHostWhileCommitDeferringConditionIsRunning) { … }
TEST_F(PrerenderHostRegistryTest,
CancelAndStartHostWhileCommitDeferringConditionIsRunning) { … }
TEST_F(PrerenderHostRegistryTest,
DontStartPrerenderWhenEmbedderTriggerIsAlreadyHidden) { … }
TEST_F(PrerenderHostRegistryTest, SameInitialAndActivationParams) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationBeginParams_InitiatorFrameToken) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationBeginParams_Headers) { … }
TEST_F(PrerenderHostRegistryTest, PurposeHeaderIsIgnoredForParamMatching) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationBeginParams_LoadFlags) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationBeginParams_SkipServiceWorker) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationBeginParams_MixedContentContextType) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationBeginParams_IsFormSubmission) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationBeginParams_SearchableFormUrl) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationBeginParams_SearchableFormEncoding) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationCommonParams_InitiatorOrigin) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationCommonParams_ShouldNotCheckMainWorldCSP) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationCommonParams_Method) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationCommonParams_HrefTranslate) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationCommonParams_Transition) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationCommonParams_RequestContextType) { … }
TEST_F(PrerenderHostRegistryTest,
CompareInitialAndActivationCommonParams_ReferrerPolicy) { … }
TEST_F(PrerenderHostRegistryTest, InsecureRequestPolicyIsSetWhilePrerendering) { … }
TEST_F(PrerenderHostRegistryTest,
InsecureNavigationsSetIsSetWhilePrerendering) { … }
TEST_F(PrerenderHostRegistryTest,
HasPotentiallyTrustworthyUniqueOriginIsSetWhilePrerendering) { … }
TEST_F(PrerenderHostRegistryTest, OneTaskToDeleteAllHosts) { … }
TEST_F(PrerenderHostRegistryTest, DisallowPageHavingEffectiveUrl_TriggerUrl) { … }
TEST_F(PrerenderHostRegistryTest,
DisallowPageHavingEffectiveUrl_PrerenderingUrl) { … }
TEST_F(PrerenderHostRegistryTest,
DisallowPageHavingEffectiveUrl_ActivationUrl) { … }
}
}