#include "content/test/test_render_frame_host.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <utility>
#include "base/run_loop.h"
#include "base/uuid.h"
#include "content/browser/fenced_frame/fenced_frame.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/navigator.h"
#include "content/browser/renderer_host/page_impl.h"
#include "content/browser/renderer_host/render_frame_host_delegate.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/frame_messages.mojom.h"
#include "content/common/navigation_params_utils.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h"
#include "content/test/test_navigation_url_loader.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_render_widget_host.h"
#include "ipc/ipc_message.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/ip_endpoint.h"
#include "net/base/load_flags.h"
#include "net/http/http_response_headers.h"
#include "net/storage_access_api/status.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "services/network/public/cpp/parsed_headers.h"
#include "services/network/public/mojom/fetch_api.mojom.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/frame/frame_policy.h"
#include "third_party/blink/public/common/navigation/navigation_params.h"
#include "third_party/blink/public/mojom/devtools/inspector_issue.mojom.h"
#include "third_party/blink/public/mojom/frame/frame.mojom.h"
#include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom.h"
#include "third_party/blink/public/mojom/frame/tree_scope_type.mojom.h"
#include "third_party/blink/public/mojom/loader/mixed_content.mojom.h"
#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_container.mojom.h"
#include "ui/base/page_transition_types.h"
namespace content {
TestRenderFrameHostCreationObserver::TestRenderFrameHostCreationObserver(
WebContents* web_contents)
: … { … }
TestRenderFrameHostCreationObserver::~TestRenderFrameHostCreationObserver() =
default;
void TestRenderFrameHostCreationObserver::RenderFrameCreated(
RenderFrameHost* render_frame_host) { … }
void TestRenderFrameHostCreationObserver::RenderFrameDeleted(
RenderFrameHost* render_frame_host) { … }
TestRenderFrameHost::TestRenderFrameHost(
SiteInstance* site_instance,
scoped_refptr<RenderViewHostImpl> render_view_host,
RenderFrameHostDelegate* delegate,
FrameTree* frame_tree,
FrameTreeNode* frame_tree_node,
int32_t routing_id,
mojo::PendingAssociatedRemote<mojom::Frame> frame_remote,
const blink::LocalFrameToken& frame_token,
const blink::DocumentToken& document_token,
base::UnguessableToken devtools_frame_token,
RenderFrameHostImpl::LifecycleStateImpl lifecycle_state,
scoped_refptr<BrowsingContextState> browsing_context_state)
: … { … }
TestRenderFrameHost::~TestRenderFrameHost() = default;
void TestRenderFrameHost::FlushLocalFrameMessages() { … }
TestRenderViewHost* TestRenderFrameHost::GetRenderViewHost() const { … }
TestPage& TestRenderFrameHost::GetPage() { … }
MockRenderProcessHost* TestRenderFrameHost::GetProcess() const { … }
MockAgentSchedulingGroupHost& TestRenderFrameHost::GetAgentSchedulingGroup() { … }
TestRenderWidgetHost* TestRenderFrameHost::GetRenderWidgetHost() { … }
void TestRenderFrameHost::AddMessageToConsole(
blink::mojom::ConsoleMessageLevel level,
const std::string& message) { … }
void TestRenderFrameHost::ReportInspectorIssue(
blink::mojom::InspectorIssueInfoPtr issue) { … }
bool TestRenderFrameHost::IsTestRenderFrameHost() const { … }
void TestRenderFrameHost::DidFailLoadWithError(const GURL& url,
int error_code) { … }
void TestRenderFrameHost::InitializeRenderFrameIfNeeded() { … }
TestRenderFrameHost* TestRenderFrameHost::AppendChild(
const std::string& frame_name) { … }
TestRenderFrameHost* TestRenderFrameHost::AppendChildWithPolicy(
const std::string& frame_name,
const blink::ParsedPermissionsPolicy& allow) { … }
TestRenderFrameHost* TestRenderFrameHost::AppendCredentiallessChild(
const std::string& frame_name) { … }
void TestRenderFrameHost::Detach() { … }
void TestRenderFrameHost::SimulateNavigationStart(const GURL& url) { … }
void TestRenderFrameHost::SimulateRedirect(const GURL& new_url) { … }
void TestRenderFrameHost::SimulateBeforeUnloadCompleted(bool proceed) { … }
void TestRenderFrameHost::SimulateUnloadACK() { … }
void TestRenderFrameHost::SimulateUserActivation() { … }
const std::vector<std::string>& TestRenderFrameHost::GetConsoleMessages() { … }
void TestRenderFrameHost::ClearConsoleMessages() { … }
int TestRenderFrameHost::GetHeavyAdIssueCount(
RenderFrameHostTester::HeavyAdIssueType type) { … }
int TestRenderFrameHost::GetFederatedAuthRequestIssueCount(
std::optional<blink::mojom::FederatedAuthRequestResult> status_type) { … }
int TestRenderFrameHost::GetFederatedAuthUserInfoRequestIssueCount(
std::optional<blink::mojom::FederatedAuthUserInfoRequestResult>
status_type) { … }
void TestRenderFrameHost::SimulateManifestURLUpdate(const GURL& manifest_url) { … }
TestRenderFrameHost* TestRenderFrameHost::AppendFencedFrame() { … }
void TestRenderFrameHost::SendNavigate(int nav_entry_id,
bool did_create_new_entry,
const GURL& url) { … }
void TestRenderFrameHost::SendNavigateWithTransition(
int nav_entry_id,
bool did_create_new_entry,
const GURL& url,
ui::PageTransition transition) { … }
void TestRenderFrameHost::SendNavigateWithParameters(
int nav_entry_id,
bool did_create_new_entry,
const GURL& url,
ui::PageTransition transition,
int response_code) { … }
void TestRenderFrameHost::SendNavigateWithParams(
mojom::DidCommitProvisionalLoadParamsPtr params,
bool was_within_same_document) { … }
void TestRenderFrameHost::SendNavigateWithParamsAndInterfaceParams(
mojom::DidCommitProvisionalLoadParamsPtr params,
mojom::DidCommitProvisionalLoadInterfaceParamsPtr interface_params,
bool was_within_same_document) { … }
void TestRenderFrameHost::SendDidCommitSameDocumentNavigation(
mojom::DidCommitProvisionalLoadParamsPtr params,
blink::mojom::SameDocumentNavigationType same_document_navigation_type,
bool should_replace_current_entry) { … }
void TestRenderFrameHost::SendStartLoadingForAsyncNavigationApiCommit() { … }
void TestRenderFrameHost::SendRendererInitiatedNavigationRequest(
const GURL& url,
bool has_user_gesture) { … }
void TestRenderFrameHost::SimulateDidChangeOpener(
const std::optional<blink::LocalFrameToken>& opener_frame_token) { … }
void TestRenderFrameHost::DidEnforceInsecureRequestPolicy(
blink::mojom::InsecureRequestPolicy policy) { … }
void TestRenderFrameHost::PrepareForCommit() { … }
void TestRenderFrameHost::PrepareForCommitDeprecatedForNavigationSimulator(
network::mojom::URLResponseHeadPtr response,
mojo::ScopedDataPipeConsumerHandle response_body) { … }
void TestRenderFrameHost::PrepareForCommitInternal(
network::mojom::URLResponseHeadPtr response,
mojo::ScopedDataPipeConsumerHandle response_body) { … }
void TestRenderFrameHost::SimulateCommitProcessed(
NavigationRequest* navigation_request,
mojom::DidCommitProvisionalLoadParamsPtr params,
mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker>
browser_interface_broker_receiver,
bool same_document) { … }
#if !BUILDFLAG(IS_ANDROID)
void TestRenderFrameHost::CreateHidServiceForTesting(
mojo::PendingReceiver<blink::mojom::HidService> receiver) { … }
#endif
void TestRenderFrameHost::CreateWebUsbServiceForTesting(
mojo::PendingReceiver<blink::mojom::WebUsbService> receiver) { … }
void TestRenderFrameHost::ResetLocalFrame() { … }
void TestRenderFrameHost::SendCommitNavigation(
mojom::NavigationClient* navigation_client,
NavigationRequest* navigation_request,
blink::mojom::CommonNavigationParamsPtr common_params,
blink::mojom::CommitNavigationParamsPtr commit_params,
network::mojom::URLResponseHeadPtr response_head,
mojo::ScopedDataPipeConsumerHandle response_body,
network::mojom::URLLoaderClientEndpointsPtr url_loader_client_endpoints,
std::unique_ptr<blink::PendingURLLoaderFactoryBundle>
subresource_loader_factories,
std::optional<std::vector<blink::mojom::TransferrableURLLoaderPtr>>
subresource_overrides,
blink::mojom::ControllerServiceWorkerInfoPtr controller,
blink::mojom::ServiceWorkerContainerInfoForClientPtr container_info,
mojo::PendingRemote<network::mojom::URLLoaderFactory>
subresource_proxying_loader_factory,
mojo::PendingRemote<network::mojom::URLLoaderFactory>
keep_alive_loader_factory,
mojo::PendingAssociatedRemote<blink::mojom::FetchLaterLoaderFactory>
fetch_later_loader_factory,
const std::optional<blink::ParsedPermissionsPolicy>& permissions_policy,
blink::mojom::PolicyContainerPtr policy_container,
const blink::DocumentToken& document_token,
const base::UnguessableToken& devtools_navigation_token) { … }
void TestRenderFrameHost::SendCommitFailedNavigation(
mojom::NavigationClient* navigation_client,
NavigationRequest* navigation_request,
blink::mojom::CommonNavigationParamsPtr common_params,
blink::mojom::CommitNavigationParamsPtr commit_params,
bool has_stale_copy_in_cache,
int32_t error_code,
int32_t extended_error_code,
const std::optional<std::string>& error_page_content,
std::unique_ptr<blink::PendingURLLoaderFactoryBundle>
subresource_loader_factories,
const blink::DocumentToken& document_token,
blink::mojom::PolicyContainerPtr policy_container) { … }
mojom::DidCommitProvisionalLoadParamsPtr
TestRenderFrameHost::BuildDidCommitParams(bool did_create_new_entry,
const GURL& url,
ui::PageTransition transition,
int response_code,
bool is_same_document) { … }
mojom::DidCommitProvisionalLoadInterfaceParamsPtr
TestRenderFrameHost::BuildDidCommitInterfaceParams(bool is_same_document) { … }
void TestRenderFrameHost::AbortCommit(NavigationRequest* navigation_request) { … }
mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker>
TestRenderFrameHost::CreateStubBrowserInterfaceBrokerReceiver() { … }
mojo::PendingAssociatedRemote<mojom::Frame>
TestRenderFrameHost::CreateStubFrameRemote() { … }
blink::mojom::PolicyContainerBindParamsPtr
TestRenderFrameHost::CreateStubPolicyContainerBindParams() { … }
mojo::PendingAssociatedReceiver<blink::mojom::AssociatedInterfaceProvider>
TestRenderFrameHost::CreateStubAssociatedInterfaceProviderReceiver() { … }
void TestRenderFrameHost::SimulateLoadingCompleted(
TestRenderFrameHost::LoadingScenario loading_scenario) { … }
}