chromium/content/browser/renderer_host/navigation_request_browsertest.cc

// Copyright 2016 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/renderer_host/navigation_request.h"

#include <memory>

#include "base/command_line.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "content/browser/process_lock.h"
#include "content/browser/renderer_host/debug_urls.h"
#include "content/browser/renderer_host/navigation_controller_impl.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/site_instance_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/content_navigation_policy.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/runtime_feature_state/runtime_feature_state_document_data.h"
#include "content/public/browser/site_isolation_policy.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/result_codes.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_content_browser_client.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/mock_web_contents_observer.h"
#include "content/public/test/navigation_handle_observer.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_frame_navigation_observer.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_service.mojom.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/url_loader_interceptor.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_download_manager_delegate.h"
#include "content/test/content_browser_test_utils_internal.h"
#include "content/test/mock_commit_deferring_condition.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/url_request/url_request_failed_job.h"
#include "services/network/public/cpp/features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
#include "third_party/blink/public/common/runtime_feature_state/runtime_feature_state_context.h"
#include "third_party/blink/public/common/runtime_feature_state/runtime_feature_state_read_context.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
#include "third_party/blink/public/mojom/runtime_feature_state/runtime_feature.mojom.h"
#include "ui/base/page_transition_types.h"
#include "url/scheme_host_port.h"
#include "url/url_constants.h"

namespace {

// Text to place in an HTML body. Should not contain any markup.
const char kBodyTextContent[] =;

}  // namespace

namespace content {

namespace {

// A test NavigationThrottle that will return pre-determined checks and run
// callbacks when the various NavigationThrottle methods are called. It is
// not instantiated directly but through a TestNavigationThrottleInstaller.
class TestNavigationThrottle : public NavigationThrottle {};

// Installs a TestNavigationThrottle either on all following requests or on
// requests with an expected starting URL, and allows waiting for various
// NavigationThrottle related events. Waiting works only for the immediately
// next navigation. New instances are needed to wait for further navigations.
class TestNavigationThrottleInstaller : public WebContentsObserver {};

// Same as above, but installs NavigationThrottles that do not directly return
// the pre-programmed check results, but first DEFER the navigation at each
// stage and then resume/cancel asynchronously.
class TestDeferringNavigationThrottleInstaller
    : public TestNavigationThrottleInstaller {};

// Records all navigation start URLs from the WebContents.
class NavigationStartUrlRecorder : public WebContentsObserver {};

void ExpectChildFrameSetAsCollapsedInFTN(Shell* shell, bool expect_collapsed) {}

void ExpectChildFrameCollapsedInLayout(Shell* shell,
                                       const std::string& frame_id,
                                       bool expect_collapsed) {}

void ExpectChildFrameCollapsed(Shell* shell,
                               const std::string& frame_id,
                               bool expect_collapsed) {}

}  // namespace

class NavigationRequestBrowserTest : public ContentBrowserTest {};

// A test class that calls IsolateAllSitesForTesting() early enough in the setup
// that we get consistent results for AreOriginKeyedProcessesEnabledByDefault()
// if kOriginKeyedProcessesByDefault is enabled. Specifically, make sure the
// initial shell's main frame's BrowsingInstance gets the correct default
// isolation state, which depends on AreOriginKeyedProcessesEnabledByDefault().
class NavigationRequestBrowserTest_IsolateAllSites
    : public NavigationRequestBrowserTest {};

class NavigationRequestDownloadBrowserTest
    : public NavigationRequestBrowserTest {};

// Ensure that PageTransition is properly set on the NavigationHandle.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, VerifyPageTransition) {}

// Ensure that the following methods on NavigationHandle behave correctly:
// * IsInMainFrame
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, VerifyFrameTree) {}

// Ensure that the WasRedirected() method on NavigationHandle behaves correctly.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, VerifyRedirect) {}

// Ensure that we can read and write to the browser process's copy of the blink
// runtime-enabled features via NavigationRequest's method
// GetMutableRuntimeFeatureStateContext() during commit. Then ensure that its
// values are persisted to the RenderFrameHostImpl's read-only context.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       RuntimeFeatureStatePersisted) {}

// Similar to RuntimeFeatureStatePersisted but ensures that even for
// runtime-enabled feature values that are equivalent to the previous state.
// This is important to persist as it helps the renderer determine force-enabled
// and force-disabled values.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       RuntimeFeatureStatePersistedForSameValue) {}

// Similar to RuntimeFeatureStatePersisted but ensures that even for
// runtime-enabled feature values are cleared across redirects.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       RuntimeFeatureStateClearOnRedirect) {}

// Ensure that a certificate error results in a committed navigation with
// the appropriate error code on the handle.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, VerifyCertErrorFailure) {}

// Ensure that the IsRendererInitiated() method on NavigationHandle behaves
// correctly.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, VerifyRendererInitiated) {}

// Ensure that methods on NavigationHandle behave correctly with an iframe that
// navigates to its srcdoc attribute.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, VerifySrcdoc) {}

// Ensure that the IsSameDocument() method on NavigationHandle behaves
// correctly.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, VerifySameDocument) {}

// Ensure that a NavigationThrottle can cancel the navigation at navigation
// start.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ThrottleCancelStart) {}

// Ensure that a NavigationThrottle can cancel the navigation when a navigation
// is redirected.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ThrottleCancelRedirect) {}

// Ensure that a NavigationThrottle can respond CANCEL when a navigation fails.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ThrottleCancelFailure) {}

// Ensure that a NavigationThrottle can cancel the navigation when the response
// is received.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ThrottleCancelResponse) {}

// Ensure that a NavigationThrottle can cancel the navigation when committing
// without a URLLoader.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       ThrottleCancelCommitWithoutUrlLoader) {}

// Ensure that a NavigationThrottle can defer and resume the navigation at
// navigation start, navigation redirect and response received.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ThrottleDefer) {}

// Ensure that a NavigationThrottle can defer and resume the navigation at
// navigation start and navigation failure.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ThrottleDeferFailure) {}

// Ensure that a NavigationThrottle can defer and resume the navigation when
// navigating without a URLLoader. This test covers multiple types of
// navigations that do not require a URLLoader (same-document navigations and
// about:blank).
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       ThrottleDeferCommitWithoutUrlLoader) {}

// Ensure that a NavigationThrottle can defer and cancel the navigation when
// navigating without a URLLoader. This test covers multiple types of
// navigations that do not require a URLLoader (same-document navigations and
// about:blank).
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       ThrottleDeferAndCancelCommitWithoutUrlLoader) {}

// Ensure that a NavigationThrottle can block the navigation and collapse the
// frame owner both on request start as well as after a redirect. Plus, ensure
// that the frame is restored on the subsequent non-error-page navigation.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ThrottleBlockAndCollapse) {}

// BLOCK_REQUEST_AND_COLLAPSE should block the navigation in legacy <frame>'s,
// but should not collapse the <frame> element itself for legacy reasons.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       ThrottleBlockAndCollapse_LegacyFrameNotCollapsed) {}

// Checks that the RequestContextType value is properly set.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       VerifyRequestContextTypeForFrameTree) {}

// Checks that the RequestContextType value is properly set for an hyper-link.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       VerifyHyperlinkRequestContextType) {}

// Checks that the RequestContextType value is properly set for an form (POST).
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       VerifyFormRequestContextType) {}

// Checks that the error code is properly set on the NavigationHandle when a
// NavigationThrottle cancels.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       ErrorCodeOnThrottleCancelNavigation) {}

// Checks that there's no UAF if NavigationRequest::WillStartRequest cancels the
// navigation.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       CancelNavigationInWillStartRequest) {}

// Verify that a cross-process navigation in a frame for which the current
// renderer process is not live will not result in leaking a
// RenderProcessHost. See https://crbug.com/949977.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       NoLeakFromStartingSiteInstance) {}

// Specialized test that verifies the NavigationHandle gets the HTTPS upgraded
// URL from the very beginning of the navigation.
class NavigationRequestHttpsUpgradeBrowserTest
    : public NavigationRequestBrowserTest {};

// Tests that the start URL is HTTPS upgraded for a same site navigation.
IN_PROC_BROWSER_TEST_F(NavigationRequestHttpsUpgradeBrowserTest,
                       StartUrlIsHttpsUpgradedSameSite) {}

// Tests that the start URL is HTTPS upgraded for a cross site navigation.
IN_PROC_BROWSER_TEST_F(NavigationRequestHttpsUpgradeBrowserTest,
                       StartUrlIsHttpsUpgradedCrossSite) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       BrowserInitiatedMainFrameReload) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       BrowserInitiatedSubFrameReload) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       RendererInitiatedMainFrameReload) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       RendererInitiatedSubFrameReload) {}

// Ensure that browser-initiated same-document navigations are detected and
// don't issue network requests.  See crbug.com/663777.
// Browser-initiated same-document navigations should trigger a
// WillCommitWithoutUrlLoader() callback, instead of the WillStartRequest()
// and WillProcessResponse() callbacks used when there is a network request.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       SameDocumentBrowserInitiatedNoReload) {}

class NavigationRequestHostResolutionFailureTest : public ContentBrowserTest {};

IN_PROC_BROWSER_TEST_F(NavigationRequestHostResolutionFailureTest,
                       HostResolutionFailure) {}

// Record and list the navigations that are started and finished.
class NavigationLogger : public WebContentsObserver {};

// Verifies that when a navigation is blocked after a redirect, the renderer
// doesn't try to commit an error page to the pre-redirect URL. This would cause
// a NavigationHandle mismatch and a new NavigationHandle creation to commit
// the error page. This test makes sure that only one NavigationHandle is used
// for committing the error page. See https://crbug.com/695421
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, BlockedOnRedirect) {}

// Tests that when a navigation starts while there's an existing one, the first
// one has the right error code set on its navigation handle.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ErrorCodeOnCancel) {}

// Tests that when a renderer-initiated request redirects to a URL that the
// renderer can't access, the right error code is set on the NavigationHandle.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ErrorCodeOnRedirect) {}

// Test to verify that error pages caused by NavigationThrottle blocking a
// request in the main frame from being made are properly committed in a
// separate error page process.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       ErrorPageBlockedNavigation) {}

// Test to verify that error pages caused by network error or other
// recoverable error are properly committed in the process for the
// destination URL.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ErrorPageNetworkError) {}

class ReadyToCommitObserver : public WebContentsObserver {};

// Ensure that adding a deferring condition that's already satisfied when
// checked (i.e. can return synchronously) doesn't block commit.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       SynchronouslyCompleteCommitDeferringCondition) {}

// Ensure asynchronously deferring conditions block the navigation when it's
// ready to commit.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       AsyncCommitDeferringCondition) {}

// Ensure a navigation can be cancelled while an asynchronously deferring
// condition is blocking commit.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       CancelWhileCommitDeferred) {}

// Ensure throttles registered by tests using RegisterThrottleForTesting() are
// executed after those registered by the WebContents' browser client (i.e. how
// non-test throttles are normally registered).
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       RegisterThrottleForTestingIsLast) {}

// Tests the case where a browser-initiated navigation to a normal webpage is
// blocked (net::ERR_BLOCKED_BY_CLIENT) while departing from a privileged WebUI
// page (chrome://gpu). It is a security risk for the error page to commit in
// the privileged process.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, BlockedRequestAfterWebUI) {}

// Redirects to renderer debug URLs caused problems.
// See https://crbug.com/728398.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       RedirectToRendererDebugUrl) {}

// Check that iframe with embedded credentials are blocked.
// See https://crbug.com/755892.
// TODO(crbug.com/40799853): Enable the test again.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       DISABLED_BlockCredentialedSubresources) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest_IsolateAllSites,
                       StartToCommitMetrics) {}

// Verify that the TimeToReadyToCommit2 metrics are correctly logged for
// SameProcess vs CrossProcess as well as MainFrame vs Subframe cases.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       TimeToReadyToCommitMetrics) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestDownloadBrowserTest, IsDownload) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestDownloadBrowserTest,
                       DownloadFalseForHtmlResponse) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestDownloadBrowserTest,
                       DownloadFalseFor404) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestDownloadBrowserTest,
                       DownloadFalseForFailedNavigation) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestDownloadBrowserTest,
                       RedirectToDownload) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestDownloadBrowserTest,
                       RedirectToDownloadFails) {}

// Set of tests that check the various NavigationThrottle events can be used
// with custom error pages.
class NavigationRequestThrottleResultWithErrorPageBrowserTest
    : public NavigationRequestBrowserTest,
      public ::testing::WithParamInterface<NavigationThrottle::ThrottleAction> {};

IN_PROC_BROWSER_TEST_P(NavigationRequestThrottleResultWithErrorPageBrowserTest,
                       WillStartRequest) {}

IN_PROC_BROWSER_TEST_P(NavigationRequestThrottleResultWithErrorPageBrowserTest,
                       WillRedirectRequest) {}

IN_PROC_BROWSER_TEST_P(NavigationRequestThrottleResultWithErrorPageBrowserTest,
                       WillFailRequest) {}

IN_PROC_BROWSER_TEST_P(NavigationRequestThrottleResultWithErrorPageBrowserTest,
                       WillProcessResponse) {}

INSTANTIATE_TEST_SUITE_P();

// The set of tests...
// * NavigationRequestDownloadBrowserTest.AllowedResourceDownloaded
// * NavigationRequestDownloadBrowserTest.AllowedResourceNotDownloaded
// * NavigationRequestDownloadBrowserTest.Disallowed
//
// ...covers every combination of possible states for:
// * CommonNavigationParams::download_policy (allow vs disallow)
// * NavigationHandle::IsDownload()
//
// Download policies that enumerate allowed / disallowed options are not tested
// here.
IN_PROC_BROWSER_TEST_F(NavigationRequestDownloadBrowserTest,
                       AllowedResourceDownloaded) {}

// See NavigationRequestDownloadBrowserTest.AllowedResourceNotDownloaded
IN_PROC_BROWSER_TEST_F(NavigationRequestDownloadBrowserTest,
                       AllowedResourceNotDownloaded) {}

// See NavigationRequestDownloadBrowserTest.AllowedResourceNotDownloaded
IN_PROC_BROWSER_TEST_F(NavigationRequestDownloadBrowserTest, Disallowed) {}

class NavigationRequestBackForwardBrowserTest
    : public NavigationRequestBrowserTest,
      public WebContentsObserver {};

IN_PROC_BROWSER_TEST_F(NavigationRequestBackForwardBrowserTest,
                       NavigationEntryOffsets) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBackForwardBrowserTest,
                       NavigationEntryOffsetsForSubframes) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBackForwardBrowserTest,
                       NavigationEntryLimit) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBackForwardBrowserTest,
                       LocationReplace) {}

// Tests that the correct net::AuthChallengeInfo is exposed from the
// NavigationHandle when the page requests authentication.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, AuthChallengeInfo) {}

class TestMixedContentWebContentsDelegate : public WebContentsDelegate {};

// Tests that an iframe with a non-webby scheme is not treated as mixed
// content. See https://crbug.com/621131.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       NonWebbyIframeIsNotMixedContent) {}

// Tests that a NavigationRequest's RFH can be retrieved during a synchronous
// renderer commit same-document navigation (regardless of whether the
// navigation commits or not).
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       GetRFHDuringSyncRendererCommitSameDocumentNavigation) {}

// Tests that a NavigationRequest's RFH can be retrieved during a synchronous
// renderer commit initial-about-blank navigation (regardless of whether the
// navigation commits or not).
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       GetRFHDuringInitialAboutBlankNavigation) {}

// Verify that when navigating to a site that doesn't require a dedicated
// process from a initial siteless SiteInstance, the SiteInstance sets its site
// at ready-to-commit time (rather than at DidCommitNavigation time).
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       SiteIsSetAtResponseTimeWithoutSiteIsolation) {}

// Check that a subframe can load an error page with an about:srcdoc URL, and
// that the origin does not inherit the parent's origin (i.e., behaves like all
// error pages) in this case.  In practice, this path may be taken by the heavy
// ads intervention (for an example, see the
// HeavyAdInterventionEnabled_ErrorPageLoaded test).
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       OriginForSrcdocErrorPageInSubframe) {}

// Verify that when navigation 1, which starts in an initial siteless
// SiteInstance and results in an error page, races with navigation 2, which
// requires a dedicated process and wants to reuse an existing process,
// navigation 2 does not incorrectly reuse navigation 1's process.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       ErrorPageMarksProcessAsUsed) {}

// Check that a renderer-initiated navigation from an error page to about:blank
// honors the initiator origin when selecting the SiteInstance and process for
// about:blank.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       NavigateToAboutBlankFromErrorPage) {}

CSPEmbeddedEnforcementBrowserTest;

IN_PROC_BROWSER_TEST_F(CSPEmbeddedEnforcementBrowserTest,
                       CheckCSPEmbeddedEnforcement) {}

class NavigationRequestFencedFrameBrowserTest
    : public NavigationRequestBrowserTest {};

IN_PROC_BROWSER_TEST_F(
    NavigationRequestFencedFrameBrowserTest,
    ShouldRespectOutermostFrameCOEPParentAndChildOnInsecureContent) {}

IN_PROC_BROWSER_TEST_F(
    NavigationRequestFencedFrameBrowserTest,
    RespectOutermostFrameCOEPParentOnInsecureContentAndChildOnSecureContent) {}

// Ensure that fenced frames don't enable the view source mode since navigations
// in fenced frames to view-sources URLs are blocked.
IN_PROC_BROWSER_TEST_F(NavigationRequestFencedFrameBrowserTest,
                       ViewSourceNavigation_FencedFrame) {}

class NavigationRequestPrerenderBrowserTest
    : public NavigationRequestBrowserTest {};

// Make sure if a main frame page served with a COOP header attempts to navigate
// itself to about:srcdoc that we handle it correctly.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       CoopWithMainframeAboutSrcdocNavigation) {}

// Same as CoopWithMainframeAboutSrcdocNavigation above, except instead of a
// single, redirected navigation, we get two distinct navigations in this case.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       CoopWithMainframeAboutSrcdocNavigation2) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestPrerenderBrowserTest,
                       CoopCoepCheckWithPrerender) {}

enum class TestMPArchType {};

class NavigationRequestMPArchBrowserTest
    : public NavigationRequestBrowserTest,
      public testing::WithParamInterface<TestMPArchType> {};

INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(NavigationRequestMPArchBrowserTest,
                       ShouldNotUpdateHistory) {}

// Tests that when trying to commit an error page for a failed navigation, but
// the renderer process of the error page crashed, the navigation won't commit
// and the browser won't crash.
// Regression test for https://crbug.com/1444360.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       RendererCrashedBeforeCommitErrorPage) {}

namespace {

constexpr char kResponseBody[] =;

// HTTP response template with adjustable header and body contents.
const char kResponseTemplate[] =;

// Test version of a NavigationThrottle that requests the response body.
class ResponseBodyNavigationThrottle : public NavigationThrottle {};

}  // namespace

class NavigationRequestResponseBodyBrowserTest
    : public NavigationRequestBrowserTest {};

IN_PROC_BROWSER_TEST_F(NavigationRequestResponseBodyBrowserTest, Received) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestResponseBodyBrowserTest,
                       ContentLengthZero) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestResponseBodyBrowserTest,
                       BodyLargerThanDataPipeSize) {}

// Helper class to turn off strict site isolation, to allow testing dynamic
// isolated origins added for future BrowsingInstances.
class NavigationRequestNoSiteIsolationBrowserTest
    : public NavigationRequestBrowserTest {};

// Test the early swap metrics logged when performing the early swap out of the
// initial RenderFrameHost.  Currently, the vast majority of navigations are
// allowed to reuse the initial RFH.  One exception is a navigation to a
// future-isolated origin, which forces a BrowsingInstance swap so that the
// isolation can take effect right away, so this is the case this test
// exercises.
IN_PROC_BROWSER_TEST_F(NavigationRequestNoSiteIsolationBrowserTest,
                       EarlySwapMetrics_InitialFrame) {}

// Test that same-site cross-origin navigations keep user activation even when
// site isolation is disabled.
IN_PROC_BROWSER_TEST_F(NavigationRequestNoSiteIsolationBrowserTest,
                       UserActivationSameSite) {}

// Test that navigating the outermost main frame to a javascript: url does not
// preserve user activation state.
IN_PROC_BROWSER_TEST_F(NavigationRequestNoSiteIsolationBrowserTest,
                       UserActivationJavascriptUrlMainFrame) {}

// Test that navigating an iframe to a javascript: url preserves the user
// activation state.
IN_PROC_BROWSER_TEST_F(NavigationRequestNoSiteIsolationBrowserTest,
                       UserActivationJavascriptUrlChildFrame) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       EarlySwapMetrics_CrashNoCommit) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       EarlySwapMetrics_CrashedSubframe) {}

IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       EarlySwapMetrics_NoSwapForWebUI) {}

// Check the output of NavigationHandle::SandboxFlagsInitiator() when the
// navigation is initiated from the omnibox. It must be `kNone`.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       InitiatorSandboxFlags_BrowserInitiated) {}

// Check the output of NavigationHandle::SandboxFlagsInitiator() when the
// navigation is initiated by the top-level document. It must match.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       InitiatorSandboxFlags_DocumentInitiated) {}

// Check the output of NavigationHandle::SandboxFlagsInitiator() when the
// navigation is initiated by a sandboxed iframe.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       InitiatorSandboxFlags_SandboxedIframe) {}

// Tests the scenario when a navigation without URLLoader is cancelled and an
// error page is committed using the same NavigationRequest.
// See https://crbug.com/1487944.
IN_PROC_BROWSER_TEST_F(
    NavigationRequestBrowserTest,
    ThrottleDeferAndCancelCommitWithoutUrlLoaderWithErrorPage) {}

// data: URLs should have opaque origins with nonce that is stable across a
// navigation, which is stored as the tentative origin to commit.
IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
                       TentativeOriginToCommitIsStable_Data) {}

}  // namespace content