#include "content/test/navigation_simulator_impl.h"
#include <utility>
#include "base/debug/stack_trace.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "content/browser/renderer_host/back_forward_cache_metrics.h"
#include "content/browser/renderer_host/debug_urls.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/navigation_entry_impl.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/content_navigation_policy.h"
#include "content/common/features.h"
#include "content/common/navigation_params_utils.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_utils.h"
#include "content/test/test_navigation_url_loader.h"
#include "content/test/test_render_frame_host.h"
#include "content/test/test_web_contents.h"
#include "ipc/ipc_message.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/load_flags.h"
#include "net/storage_access_api/status.h"
#include "net/url_request/redirect_info.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/network/public/mojom/fetch_api.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
#include "third_party/blink/public/common/navigation/navigation_params.h"
#include "third_party/blink/public/mojom/loader/mixed_content.mojom.h"
namespace content {
namespace {
class NavigationThrottleCallbackRunner : public NavigationThrottle { … };
int64_t g_unique_identifier = …;
FrameTreeNode* GetFrameTreeNodeForPendingEntry(
NavigationControllerImpl& controller) { … }
}
RenderFrameHost* NavigationSimulator::NavigateAndCommitFromBrowser(
WebContents* web_contents,
const GURL& url) { … }
RenderFrameHost* NavigationSimulator::Reload(WebContents* web_contents) { … }
RenderFrameHost* NavigationSimulator::GoBack(WebContents* web_contents) { … }
RenderFrameHost* NavigationSimulator::GoForward(WebContents* web_contents) { … }
RenderFrameHost* NavigationSimulator::GoToOffset(WebContents* web_contents,
int offset) { … }
RenderFrameHost* NavigationSimulator::NavigateAndCommitFromDocument(
const GURL& original_url,
RenderFrameHost* render_frame_host) { … }
RenderFrameHost* NavigationSimulator::NavigateAndFailFromBrowser(
WebContents* web_contents,
const GURL& url,
int net_error_code) { … }
RenderFrameHost* NavigationSimulator::ReloadAndFail(WebContents* web_contents,
int net_error_code) { … }
RenderFrameHost* NavigationSimulator::GoBackAndFail(WebContents* web_contents,
int net_error_code) { … }
RenderFrameHost* NavigationSimulator::GoToOffsetAndFail(
WebContents* web_contents,
int offset,
int net_error_code) { … }
RenderFrameHost* NavigationSimulator::NavigateAndFailFromDocument(
const GURL& original_url,
int net_error_code,
RenderFrameHost* render_frame_host) { … }
std::unique_ptr<NavigationSimulator>
NavigationSimulator::CreateBrowserInitiated(const GURL& original_url,
WebContents* web_contents) { … }
std::unique_ptr<NavigationSimulatorImpl>
NavigationSimulatorImpl::CreateBrowserInitiated(const GURL& original_url,
WebContents* web_contents) { … }
std::unique_ptr<NavigationSimulator>
NavigationSimulator::CreateHistoryNavigation(int offset,
WebContents* web_contents,
bool is_renderer_initiated) { … }
std::unique_ptr<NavigationSimulatorImpl>
NavigationSimulatorImpl::CreateHistoryNavigation(int offset,
WebContents* web_contents,
bool is_renderer_initiated) { … }
std::unique_ptr<NavigationSimulator>
NavigationSimulator::CreateRendererInitiated(
const GURL& original_url,
RenderFrameHost* render_frame_host) { … }
std::unique_ptr<NavigationSimulatorImpl>
NavigationSimulatorImpl::CreateRendererInitiated(
const GURL& original_url,
RenderFrameHost* render_frame_host) { … }
std::unique_ptr<NavigationSimulator> NavigationSimulator::CreateFromPending(
NavigationController& controller) { … }
std::unique_ptr<NavigationSimulatorImpl>
NavigationSimulatorImpl::CreateFromPending(NavigationController& controller) { … }
std::unique_ptr<NavigationSimulatorImpl>
NavigationSimulatorImpl::CreateFromPendingInFrame(
FrameTreeNode* frame_tree_node) { … }
NavigationSimulatorImpl::NavigationSimulatorImpl(
const GURL& original_url,
bool browser_initiated,
WebContentsImpl* web_contents,
TestRenderFrameHost* render_frame_host)
: … { … }
NavigationSimulatorImpl::~NavigationSimulatorImpl() { … }
void NavigationSimulatorImpl::InitializeFromStartedRequest(
NavigationRequest* request) { … }
void NavigationSimulatorImpl::RegisterTestThrottle() { … }
void NavigationSimulatorImpl::Start() { … }
void NavigationSimulatorImpl::StartComplete() { … }
void NavigationSimulatorImpl::Redirect(const GURL& new_url) { … }
void NavigationSimulatorImpl::RedirectComplete(
int previous_num_will_redirect_request_called,
int previous_did_redirect_navigation_called) { … }
void NavigationSimulatorImpl::ReadyToCommit() { … }
void NavigationSimulatorImpl::WillProcessResponseComplete() { … }
void NavigationSimulatorImpl::ReadyToCommitComplete() { … }
void NavigationSimulatorImpl::Commit() { … }
void NavigationSimulatorImpl::AbortCommit() { … }
void NavigationSimulatorImpl::AbortFromRenderer() { … }
void NavigationSimulatorImpl::Fail(int error_code) { … }
void NavigationSimulatorImpl::FailComplete(int error_code) { … }
void NavigationSimulatorImpl::CommitErrorPage() { … }
void NavigationSimulatorImpl::CommitSameDocument() { … }
void NavigationSimulatorImpl::SetInitiatorFrame(
RenderFrameHost* initiator_frame_host) { … }
void NavigationSimulatorImpl::SetTransition(ui::PageTransition transition) { … }
void NavigationSimulatorImpl::SetHasUserGesture(bool has_user_gesture) { … }
void NavigationSimulatorImpl::SetNavigationInputStart(
base::TimeTicks navigation_input_start) { … }
void NavigationSimulatorImpl::SetNavigationStart(
base::TimeTicks navigation_start) { … }
void NavigationSimulatorImpl::SetReloadType(ReloadType reload_type) { … }
void NavigationSimulatorImpl::SetMethod(const std::string& method) { … }
void NavigationSimulatorImpl::SetIsFormSubmission(bool is_form_submission) { … }
void NavigationSimulatorImpl::SetReferrer(blink::mojom::ReferrerPtr referrer) { … }
void NavigationSimulatorImpl::SetSocketAddress(
const net::IPEndPoint& remote_endpoint) { … }
void NavigationSimulatorImpl::SetWasFetchedViaCache(
bool was_fetched_via_cache) { … }
void NavigationSimulatorImpl::SetIsSignedExchangeInnerResponse(
bool is_signed_exchange_inner_response) { … }
void NavigationSimulatorImpl::SetPermissionsPolicyHeader(
blink::ParsedPermissionsPolicy permissions_policy_header) { … }
void NavigationSimulatorImpl::SetContentsMimeType(
const std::string& contents_mime_type) { … }
void NavigationSimulatorImpl::SetRedirectHeaders(
scoped_refptr<net::HttpResponseHeaders> redirect_headers) { … }
void NavigationSimulatorImpl::SetResponseHeaders(
scoped_refptr<net::HttpResponseHeaders> response_headers) { … }
void NavigationSimulatorImpl::SetResponseBody(
mojo::ScopedDataPipeConsumerHandle response_body) { … }
void NavigationSimulatorImpl::SetLoadURLParams(
NavigationController::LoadURLParams* load_url_params) { … }
void NavigationSimulatorImpl::SetAutoAdvance(bool auto_advance) { … }
void NavigationSimulatorImpl::SetResolveErrorInfo(
const net::ResolveErrorInfo& resolve_error_info) { … }
void NavigationSimulatorImpl::SetSSLInfo(const net::SSLInfo& ssl_info) { … }
void NavigationSimulatorImpl::SetResponseDnsAliases(
std::vector<std::string> aliases) { … }
void NavigationSimulatorImpl::SetEarlyHintsPreloadLinkHeaderReceived(
bool received) { … }
NavigationThrottle::ThrottleCheckResult
NavigationSimulatorImpl::GetLastThrottleCheckResult() { … }
NavigationRequest* NavigationSimulatorImpl::GetNavigationHandle() { … }
content::GlobalRequestID NavigationSimulatorImpl::GetGlobalRequestID() { … }
void NavigationSimulatorImpl::BrowserInitiatedStartAndWaitBeforeUnload() { … }
void NavigationSimulatorImpl::RenderFrameDeleted(
RenderFrameHost* render_frame_host) { … }
void NavigationSimulatorImpl::DidStartNavigation(
NavigationHandle* navigation_handle) { … }
void NavigationSimulatorImpl::DidRedirectNavigation(
NavigationHandle* navigation_handle) { … }
void NavigationSimulatorImpl::ReadyToCommitNavigation(
NavigationHandle* navigation_handle) { … }
void NavigationSimulatorImpl::DidFinishNavigation(
NavigationHandle* navigation_handle) { … }
void NavigationSimulatorImpl::OnWillStartRequest() { … }
void NavigationSimulatorImpl::OnWillRedirectRequest() { … }
void NavigationSimulatorImpl::OnWillFailRequest() { … }
void NavigationSimulatorImpl::OnWillProcessResponse() { … }
bool NavigationSimulatorImpl::SimulateBrowserInitiatedStart() { … }
bool NavigationSimulatorImpl::SimulateRendererInitiatedStart() { … }
void NavigationSimulatorImpl::MaybeWaitForThrottleChecksComplete(
base::OnceClosure complete_closure) { … }
void NavigationSimulatorImpl::MaybeWaitForReadyToCommitCheckComplete() { … }
void NavigationSimulatorImpl::Wait() { … }
bool NavigationSimulatorImpl::OnThrottleChecksComplete(
NavigationThrottle::ThrottleCheckResult result) { … }
void NavigationSimulatorImpl::PrepareCompleteCallbackOnRequest() { … }
RenderFrameHost* NavigationSimulatorImpl::GetFinalRenderFrameHost() { … }
bool NavigationSimulatorImpl::IsDeferred() { … }
bool NavigationSimulatorImpl::HasFailed() { … }
bool NavigationSimulatorImpl::DidCreateNewEntry(
bool same_document,
bool should_replace_current_entry) { … }
void NavigationSimulatorImpl::SetSessionHistoryOffset(
int session_history_offset) { … }
void NavigationSimulatorImpl::set_history_list_was_cleared(
bool history_cleared) { … }
mojom::DidCommitProvisionalLoadParamsPtr
NavigationSimulatorImpl::BuildDidCommitProvisionalLoadParams(
bool same_document,
bool failed_navigation,
int last_http_status_code) { … }
void NavigationSimulatorImpl::SetKeepLoading(bool keep_loading) { … }
void NavigationSimulatorImpl::StopLoading() { … }
void NavigationSimulatorImpl::
SimulateUnloadCompletionCallbackForPreviousFrameIfNeeded(
RenderFrameHostImpl* previous_rfh) { … }
bool NavigationSimulatorImpl::NeedsThrottleChecks() const { … }
bool NavigationSimulatorImpl::NeedsPreCommitChecks() const { … }
}