chromium/content/browser/security/coop/cross_origin_opener_policy_browsertest.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/command_line.h"
#include "base/strings/escape.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "content/browser/process_lock.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/content_navigation_policy.h"
#include "content/public/browser/site_isolation_policy.h"
#include "content/public/common/content_features.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/content_mock_cert_verifier.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/url_loader_interceptor.h"
#include "content/shell/browser/shell.h"
#include "content/test/content_browser_test_utils_internal.h"
#include "content/test/render_document_feature.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/embedded_test_server/request_handler_util.h"
#include "services/network/public/cpp/cross_origin_embedder_policy.h"
#include "services/network/public/cpp/cross_origin_opener_policy.h"
#include "services/network/public/cpp/features.h"
#include "testing/gmock/include/gmock/gmock.h"

HasSubstr;

namespace content {

namespace {

network::CrossOriginOpenerPolicy CoopSameOrigin(
    const std::optional<url::Origin>& origin = std::nullopt) {}

network::CrossOriginOpenerPolicy CoopSameOriginPlusCoep(
    const std::optional<url::Origin>& origin = std::nullopt) {}

network::CrossOriginOpenerPolicy CoopSameOriginAllowPopups(
    const std::optional<url::Origin>& origin = std::nullopt) {}

network::CrossOriginOpenerPolicy CoopRestrictProperties(
    const std::optional<url::Origin>& origin = std::nullopt) {}

network::CrossOriginOpenerPolicy CoopRestrictPropertiesPlusCoep(
    const std::optional<url::Origin>& origin = std::nullopt) {}

network::CrossOriginOpenerPolicy
CoopReportOnlyRestrictPropertiesWithSoapByDefault(
    const std::optional<url::Origin>& origin = std::nullopt) {}

network::CrossOriginOpenerPolicy
CoopReportOnlyRestrictPropertiesPlusCoepWithSoapByDefault(
    const std::optional<url::Origin>& origin = std::nullopt) {}

// This is the value of COOP when navigating to a page without COOP set:
//  - value is kUnsafeNone
//  - soap_by_default_value is kSameOriginAllowPopups
network::CrossOriginOpenerPolicy CoopUnsafeNoneWithSoapByDefault(
    const std::optional<url::Origin>& origin = std::nullopt) {}

network::CrossOriginOpenerPolicy CoopUnsafeNone(
    const std::optional<url::Origin>& origin = std::nullopt) {}

std::unique_ptr<net::test_server::HttpResponse>
CrossOriginIsolatedCrossOriginRedirectHandler(
    const net::test_server::HttpRequest& request) {}

std::unique_ptr<net::test_server::HttpResponse>
CoopAndCspSandboxRedirectHandler(const net::test_server::HttpRequest& request) {}

std::unique_ptr<net::test_server::HttpResponse> ServeCoopOnSecondNavigation(
    unsigned int& navigation_counter,
    const net::test_server::HttpRequest& request) {}

std::unique_ptr<net::test_server::HttpResponse>
ServeDifferentCoopOnSecondNavigation(
    unsigned int& navigation_counter,
    const net::test_server::HttpRequest& request) {}

class CrossOriginOpenerPolicyBrowserTest
    : public ContentBrowserTest,
      public ::testing::WithParamInterface<std::tuple<std::string, bool>> {};

// Same as CrossOriginOpenerPolicyBrowserTest, but disable SharedArrayBuffer by
// default for non crossOriginIsolated process. This is the state we will reach
// after resolving: https://crbug.com/1144104
class NoSharedArrayBufferByDefault : public CrossOriginOpenerPolicyBrowserTest {};

// Same as CrossOriginOpenerPolicyBrowserTest, but enables COOP:
// restrict-properties.
class CoopRestrictPropertiesBrowserTest
    : public CrossOriginOpenerPolicyBrowserTest {};

// Same as CoopRestrictPropertiesBrowserTest, but skips on platforms not
// providing full site isolation, to help test the existence of proxies. Also
// provides helper functions to leverage FrameTreeVisualizer. Inherits its
// parametrization for RenderDocument and BackForwardCache.
class CoopRestrictPropertiesProxiesBrowserTest
    : public CoopRestrictPropertiesBrowserTest {};

// Same as CoopRestrictPropertiesBrowserTest, but uses the new
// BrowsingContextState mode that swaps BrowsingContextState when navigating
// cross BrowsingInstance. Inherits its parametrization for RenderDocument and
// BackForwardCache.
class CoopRestrictPropertiesWithNewBrowsingContextStateModeBrowserTest
    : public CoopRestrictPropertiesBrowserTest {};

CoopRestrictPropertiesAccessBrowserTest;

static constexpr char kCoopRpErrorMessageRegex[] =;

CoopRestrictPropertiesReportingBrowserTest;

// Certain features are only active when SiteIsolation is off or restricted.
// This is the case for example for Default SiteInstances that are used on
// Android to limit the number of processes. Testing these particularities of
// the process model and their interaction with cross-origin isolation requires
// to disable SiteIsolation.
class NoSiteIsolationCrossOriginIsolationBrowserTest
    : public CrossOriginOpenerPolicyBrowserTest {};

VirtualBrowsingContextGroupTest;
SoapByDefaultVirtualBrowsingContextGroupTest;

int VirtualBrowsingContextGroup(WebContents* wc) {}

int SoapByDefaultVirtualBrowsingContextGroup(WebContents* wc) {}

class ProcessReuseOnPrerenderCOOPSwapBrowserTest
    : public CrossOriginOpenerPolicyBrowserTest {};

}  // namespace

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NewPopupCOOP_InheritsSameOrigin) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NewPopupCOOP_InheritsSameOriginAllowPopups) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NewPopupCOOP_CrossOriginDoesNotInheritSameOrigin) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NewPopupCOOP_CrossOriginInheritsRestrictProperties) {}

IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesBrowserTest,
    NewPopupCOOP_CrossOriginInheritsRestrictPropertiesPlusCoep) {}

IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesBrowserTest,
    NewPopupCOOP_CrossOriginInheritsReportOnlyRestrictProperties) {}

IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesBrowserTest,
    NewPopupCOOP_CrossOriginInheritsReportOnlyRestrictPropertiesPlusCoep) {}

IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesBrowserTest,
    NewPopupCOOP_SameOriginSubframeCanNavigatePopupOpenedByMainFrame) {}

IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesBrowserTest,
    NewPopupCOOP_CrossOriginSubframeCannotNavigatePopupOpenedByMainFrame) {}

IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesBrowserTest,
    NewPopupCOOP_CrossOriginSubframeCannotNavigatePopupOpenedByMainFrameToAboutBlank) {}

IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesBrowserTest,
    NewPopupCOOP_CrossOriginSubframeCannotNavigatePopupOpenedByMainFrameWithCoopRpToAboutBlank) {}

IN_PROC_BROWSER_TEST_P(
    CrossOriginOpenerPolicyBrowserTest,
    NewPopupCOOP_SameOriginPolicyAndCrossOriginIframeSetsNoopener) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       BlobInheritsCreatorSameOrigin) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       BlobInheritsInitiatorSameOriginPlusCoepCredentialless) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       BlobInheritsInitiatorSameOriginPlusCoep) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       BlobInheritsCreatorSameOriginAllowPopups) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       BlobInheritsCreatorTopFrameSameOriginCreatorIframeCOEP) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       BlobInheritsCreatorNotInitiator) {}

// Verify that a opening a popup to a COOP page, with sandbox flags inherited
// from the initiator ends up as an error page.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SandboxViaInheritanceWithCoop) {}

// Verify that a navigation toward a COOP page, with sandbox flags inherited
// from the initiator ends up as an error page.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SandboxViaInheritanceNavigationsToCoop) {}

// Verify that a document setting COOP can also set sandbox via CSP.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SandboxViaCspWithCoop) {}

// Verify that navigating from a document sandboxed via CSP to a COOP document,
// and vice versa, does not end up as an error page.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SandboxViaCspNavigationsToCoop) {}

// Verify that CSP sandbox, which makes the origin opaque, is taken into account
// for the COOP enforcement of the final response.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SandboxViaCspOpaqueOriginForResponse) {}

// Verify that CSP sandbox, which makes the origin opaque, is not taken into
// account for the COOP enforcement of the final response.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SandboxViaCspNonOpaqueOriginForRedirect) {}

// Verify that a document setting COOP + COEP and CSP: sandbox cannot live in
// the same process as a document setting COOP + COEP with the same (non-opaque)
// origin.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SandboxViaCspOpaqueOriginForIsolation) {}

class CrossOriginPolicyHeadersObserver : public WebContentsObserver {};

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       RedirectsParseCoopAndCoepHeaders) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CoopIsIgnoredOverHttp) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CoopIsIgnoredOnIframes) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CoopSameOriginIframeInheritance) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CoopCrossOriginIframeInheritance) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NonCoopPageCrashIntoCoop) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CoopPageCrashIntoNonCoop) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CoopPageCrashIntoCoop) {}

// This test is a reproducer for https://crbug.com/1264104.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       BackNavigationCoiToNonCoiAfterCrashReproducer) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       ProxiesAreRemovedWhenCrossingCoopBoundary) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       ProxiesAreKeptWhenNavigatingFromCoopToCoop) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       IsolateInNewProcessDespiteLimitReached) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NoProcessReuseForCOOPProcesses) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SpeculativeRfhsAndCoop) {}

// https://crbug.com/1266819 suggested that navigating to a cross-origin page
// from a cross-origin isolated page is a good reproducer for potential
// speculative RFHs + crossOriginIsolated issues. Tests from both a regular and
// a crashed frame to also verify with the crash optimization commit.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SpeculativeSiteInstanceAndCrossOriginIsolation) {}

// Navigate in between two documents. Check the virtual browsing context group
// is properly updated.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest, Navigation) {}

// Use window.open(url). Check the virtual browsing context group of the two
// window.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest, WindowOpen) {}

namespace {
// Use two URLs, |url_a| and |url_b|. One of them at least uses
// COOP:same-origin-allow-popups, or COOP-Report-Only:same-origin-allow-popups,
// or both (unless soap_by_default is true).
//
// Test two scenario:
// 1. From |url_a|, opens |url_b|
// 2. From |url_a|, navigates to |url_b|.
//
// In both cases, check whether a new virtual browsing context group has been
// used or not.
//
// If soap_by_default is true, then the test will check the soap by default
// virtual browsing context group.
struct VirtualBcgAllowPopupTestCase {};

void RunTest(const VirtualBcgAllowPopupTestCase& test_case, Shell* shell) {}

}  // namespace

IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest,
                       NonCoopToCoopAllowPopup) {}

// coop:same-origin-allow-popup -> coop:none.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest,
                       CoopAllowPopup_NonCoop) {}

// coop:none -> coop:same-origin-allow-popup.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest,
                       CoopRoAllowPopup_NonCoop) {}

// coop:same-origin-allow-popup -> coop:same-origin-allow-popup.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest,
                       CoopAllowPopup_CoopAllowPopup) {}

// coop:same-origin-allow-popup -> coop-ro:same-origin-allow-popup.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest,
                       CoopAllowPopup_CoopRoAllowPopup) {}

// coop-ro:same-origin-allow-popup -> coop:same-origin-allow-popup.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest,
                       CoopRoAllowPopup_CoopAllowPopup) {}

// coop:same-origin-allow-popup + coop-ro:same-origin-allow-popup -> coop:none.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest,
                       CoopPopupRoSameOrigin_NonCoop) {}

// Navigates in between two pages from a different browsing context group. Then
// use the history API to navigate back and forth. Check their virtual browsing
// context group isn't restored.
// The goal is to spot differences when the BackForwardCache is enabled. See
// https://crbug.com/1109648.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest, HistoryNavigation) {}

// 1. A1 opens B2 (same virtual browsing context group).
// 2. B2 navigates to C3 (different virtual browsing context group).
// 3. C3 navigates back to B4 using the history (different virtual browsing
//    context group).
//
// A1 and B4 must not be in the same browsing context group.
IN_PROC_BROWSER_TEST_P(VirtualBrowsingContextGroupTest,
                       HistoryNavigationWithPopup) {}

// A subclass for tests incompatible with OriginKeyedProcessesByDefault.
class CrossOriginOpenerPolicyNoOKPBrowserTest
    : public CrossOriginOpenerPolicyBrowserTest {};

// A test to make sure that loading a page with COOP/COEP headers doesn't set
// is_origin_keyed() on the SiteInstance's SiteInfo. This test should be run
// with OriginKeyedProcessesByDefault disabled, otherwise the SiteInfo will
// be origin-keyed regardless of COOP/COEP.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyNoOKPBrowserTest,
                       CoopCoepNotOriginKeyed) {}

// TODO(crbug.com/40924316): Disable flaky test in Linux.
#if BUILDFLAG(IS_LINUX)
#define MAYBE_CrossOriginIsolatedSiteInstance_MainFrame
#else
#define MAYBE_CrossOriginIsolatedSiteInstance_MainFrame
#endif
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       MAYBE_CrossOriginIsolatedSiteInstance_MainFrame) {}

IN_PROC_BROWSER_TEST_P(
    CrossOriginOpenerPolicyBrowserTest,
    CrossOriginIsolatedSiteInstance_MainFrameRendererInitiated) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CrossOriginIsolatedSiteInstance_IFrame) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CrossOriginIsolatedSiteInstance_Popup) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CrossOriginIsolatedSiteInstance_ErrorPage) {}

// Regression test for https://crbug.com/1226909.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NavigatePopupToErrorAndCrash) {}

// Regression test for https://crbug.com/1239540.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       ReloadCrossOriginIsolatedPageWhileOffline) {}

// Regression test for https://crbug.com/1239540.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       ReloadCoopPageWhileOffline) {}

// Regression test for https://crbug.com/1239540.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       BackNavigationToCrossOriginIsolatedPageWhileOffline) {}

// Regression test for https://crbug.com/1374705.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       ReloadRedirectsToCoopPage) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       ReloadPageWithUpdatedCoopHeader) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CrossOriginRedirectHasProperCrossOriginIsolatedState) {}

// Reproducer test for https://crbug.com/1150938.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       MainFrameA_IframeB_Opens_WindowA) {}

// Regression test for https://crbug.com/1183571. This used to crash.
// A grand child, same-origin with its parent, but cross-origin with the main
// document is accessing a popup.
//
// TODO(arthursonzogni): Add a similar WPT test.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       GrandChildAccessCrash1183571) {}

// This test is a reproducer for https://crbug.com/1305394.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       CrossOriginIframeCoopBypass) {}

// Check whether not using COOP causes a RenderProcessHost change during
// same-origin navigations. This is a control test for the subsequent tests.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       Process_CoopUnsafeNone_SameOrigin) {}

// Check whether using COOP causes a RenderProcessHost change during
// same-origin navigations.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       Process_CoopSameOrigin_SameOrigin) {}

// Check that a COOP mismatch does not cause a RenderProcessHost change during
// same-origin navigations, unless COOP triggers the site isolation heuristic
// of requiring a dedicated process, which would force a process swap.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       Process_CoopAlternate_SameOrigin) {}

// Check whether COOP causes a RenderProcessHost change during same-site
// navigations.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       Process_CoopAlternate_SameSite) {}

// Check whether COOP causes a RenderProcessHost change during cross-origin
// navigations.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       Process_CoopSameOrigin_CrossOrigin) {}

// Smoke test for an iframe in a crossOriginIsolated page doing a same-document
// history navigation. Added to prevent regression of https://crbug.com/1413081.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       SmokeTest_CoopCoepSameDocumentIframeHistoryNavigation) {}

// Ensure that when navigating from a non-COOP site to a site with COOP that
// also requires a dedicated process, there's only one new process created, and
// the BrowsingInstance swap required by COOP doesn't trigger an unneeded
// second process swap at response time.  In other words, the process created
// for the speculative RenderFrameHost at navigation start time ought to be
// reused by the speculative RenderFrameHost that's recomputed at
// OnResponseStarted response time (where it's recomputed due to the
// BrowsingInstance swap required by COOP).
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NoExtraProcessSwapFromDiscardedSpeculativeRFH) {}

// Ensure that same-site navigations that result in a COOP mismatch avoid an
// unnecessary process swap when those navigations happen in a
// BrowsingContextGroup of size 1 (in this case, in the same WebContents).
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NoExtraProcessSwapFromSameSiteCOOPMismatch) {}

// Verify that there's no extra process swap during a same-site navigation from
// one COOP page to another COOP page.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NavigatingFromCOOPToCOOPHasNoExtraProcessCreation) {}

// Ensure that a same-site COOP mismatch that happens in a popup does *not*
// reuse the existing process, unlike in the
// NoExtraProcessSwapFromSameSiteCOOPMismatch test above.  This ensures that
// same-site COOP mismatch reuses the old process only in single-window
// BrowsingInstances, and noopener-like popups with a COOP mismatch still get a
// fresh process.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NoProcessReuseForSameSiteCOOPMismatchInPopup) {}

// Tests the behavior around COOP BrowsingInstance swap when prerendering a COOP
// page.
// Regression test for crbug.com/1519131.
IN_PROC_BROWSER_TEST_P(ProcessReuseOnPrerenderCOOPSwapBrowserTest,
                       COOPSwapForPrerenderingCOOPPage) {}

// TODO(crbug.com/40138297). Test inheritance of the virtual browsing
// context group when using window.open from an iframe, same-origin and
// cross-origin.

static auto kTestParams =;
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(NoSharedArrayBufferByDefault, BaseCase) {}

IN_PROC_BROWSER_TEST_P(NoSharedArrayBufferByDefault, CoopCoepIsolated) {}

IN_PROC_BROWSER_TEST_P(NoSharedArrayBufferByDefault,
                       CoopCoepTransferSharedArrayBufferToIframe) {}

IN_PROC_BROWSER_TEST_P(NoSharedArrayBufferByDefault,
                       CoopCoepTransferSharedArrayBufferToAboutBlankIframe) {}

IN_PROC_BROWSER_TEST_P(
    NoSharedArrayBufferByDefault,
    CoopCoepTransferSharedArrayBufferToAboutBlankIframeWithoutWaiting) {}

// Transfer a SharedArrayBuffer in between two COOP+COEP document with a
// parent/child relationship. The child has set Permissions-Policy:
// cross-origin-isolated=(). As a result, it can't receive the object.
IN_PROC_BROWSER_TEST_P(
    NoSharedArrayBufferByDefault,
    CoopCoepTransferSharedArrayBufferToNoCrossOriginIsolatedIframe) {}

// Transfer a SharedArrayBuffer in between two COOP+COEP document with a
// parent/child relationship. The child has set Permissions-Policy:
// cross-origin-isolated=(). This non-cross-origin-isolated document can
// transfer a SharedArrayBuffer toward the cross-origin-isolated one.
// See https://crbug.com/1144838 for discussions about this behavior.
IN_PROC_BROWSER_TEST_P(
    NoSharedArrayBufferByDefault,
    CoopCoepTransferSharedArrayBufferFromNoCrossOriginIsolatedIframe) {}

class OriginTrialBrowserTest : public ContentBrowserTest {};

// Ensure the UnrestrictedSharedArrayBuffer reverse origin trial is correctly
// implemented.
class UnrestrictedSharedArrayBufferOriginTrialBrowserTest
    : public OriginTrialBrowserTest {};

IN_PROC_BROWSER_TEST_F(UnrestrictedSharedArrayBufferOriginTrialBrowserTest,
                       HasSharedArrayBuffer) {}

// Check setting the OriginTrial works, even in popups where the javascript
// context of the initial empty document is reused.
IN_PROC_BROWSER_TEST_F(UnrestrictedSharedArrayBufferOriginTrialBrowserTest,
                       HasSharedArrayBufferReuseContext) {}

IN_PROC_BROWSER_TEST_F(UnrestrictedSharedArrayBufferOriginTrialBrowserTest,
                       SupportForMeta) {}

IN_PROC_BROWSER_TEST_F(UnrestrictedSharedArrayBufferOriginTrialBrowserTest,
                       TransferSharedArrayBuffer) {}

// Enable the reverse OriginTrial via a <meta> tag. Then send a Webassembly's
// SharedArrayBuffer toward the iframe.
// Regression test for https://crbug.com/1201589).
// The SAB reverse origin trial only work on Desktop.
#if !BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(UnrestrictedSharedArrayBufferOriginTrialBrowserTest,
                       CrashForBug1201589) {}
#endif

// Ensure the SharedArrayBufferOnDesktop kill switch is correctly implemented.
class SharedArrayBufferOnDesktopBrowserTest
    : public CrossOriginOpenerPolicyBrowserTest {};

INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(SharedArrayBufferOnDesktopBrowserTest,
                       DesktopHasSharedArrayBuffer) {}

IN_PROC_BROWSER_TEST_P(SharedArrayBufferOnDesktopBrowserTest,
                       DesktopTransferSharedArrayBuffer) {}

IN_PROC_BROWSER_TEST_P(SoapByDefaultVirtualBrowsingContextGroupTest, NoHeader) {}

IN_PROC_BROWSER_TEST_P(SoapByDefaultVirtualBrowsingContextGroupTest,
                       ToUnsafeNone) {}

IN_PROC_BROWSER_TEST_P(SoapByDefaultVirtualBrowsingContextGroupTest,
                       FromUnsafeNone) {}

IN_PROC_BROWSER_TEST_P(SoapByDefaultVirtualBrowsingContextGroupTest,
                       ToSameOriginAllowPopups) {}

IN_PROC_BROWSER_TEST_P(SoapByDefaultVirtualBrowsingContextGroupTest,
                       FromSameOriginAllowPopus) {}

IN_PROC_BROWSER_TEST_P(SoapByDefaultVirtualBrowsingContextGroupTest,
                       ToSameOrigin) {}

IN_PROC_BROWSER_TEST_P(SoapByDefaultVirtualBrowsingContextGroupTest,
                       FromSameOrigin) {}

// Navigates in between two pages from a different browsing context group. Then
// use the history API to navigate back and forth. Check their virtual browsing
// context group isn't restored.
// The goal is to spot differences when the BackForwardCache is enabled. See
// https://crbug.com/1109648.
IN_PROC_BROWSER_TEST_P(SoapByDefaultVirtualBrowsingContextGroupTest,
                       HistoryNavigation) {}

// 1. A1 opens A2 (same virtual browsing context group).
// 2. A2 navigates to B3 (different virtual browsing context group).
// 3. B3 navigates back to A4 using the history (different virtual browsing
//    context group).
//
// A1 and A4 must not be in the same browsing context group.
IN_PROC_BROWSER_TEST_P(SoapByDefaultVirtualBrowsingContextGroupTest,
                       HistoryNavigationWithPopup) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       CoopRestrictPropertiesIsParsed) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       CoopRestrictPropertiesPlusCoepIsParsed) {}

class CoopRestrictPropertiesOriginTrialBrowserTest
    : public OriginTrialBrowserTest,
      public ::testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesOriginTrialBrowserTest,
                       CoopRestrictPropertiesValidToken) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesOriginTrialBrowserTest,
                       CoopRestrictPropertiesTokenOriginMismatched) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesOriginTrialBrowserTest,
                       CoopRestrictPropertiesPlusCoepValidToken) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesOriginTrialBrowserTest,
                       CoopRestrictPropertiesPlusCoepTokenOriginMismatched) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesOriginTrialBrowserTest,
                       CoopReportOnlyRestrictPropertiesValidToken) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesOriginTrialBrowserTest,
                       CoopReportOnlyRestrictPropertiesTokenOriginMismatched) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesOriginTrialBrowserTest,
                       CoopReportOnlyRestrictPropertiesPlusCoepValidToken) {}

IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesOriginTrialBrowserTest,
    CoopReportOnlyRestrictPropertiesPlusCoepTokenOriginMismatched) {}

// Verify that a simple navigation from a regular page to a COOP:
// restrict-properties page puts the two pages in different BrowsingInstances in
// the same CoopRelatedGroup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NavigateNonCoopToCoopRp) {}

// Verify that a simple navigation from a COOP: restrict-properties page to a
// regular page puts the two pages in BrowsingInstances in the same
// CoopRelatedGroup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NavigateCoopRpToNonCoop) {}

// Verify that a simple navigation from a COOP: restrict-properties page to
// another same-origin COOP: restrict-properties page puts the two pages in the
// same SiteInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NavigateCoopRpToCoopRpSameOrigin) {}

// Verify that a simple navigation from a COOP: restrict-properties page to
// another cross-origin COOP: restrict-properties page puts the two pages in
// different SiteInstances and BrowsingInstances in the same CoopRelatedGroup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NavigateCoopRpToCoopRpCrossOrigin) {}

// Verify that a simple navigation from a COOP: restrict-properties page to
// another same-origin COOP: restrict-properties page that also sets COEP puts
// the two pages in different SiteInstances and BrowsingInstances in the same
// CoopRelatedGroup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NavigateCoopRpToCoopRpPlusCoep) {}

// Verify that a navigation from a regular page to a COOP: restrict-properties
// and then to another regular page reuses the initial BrowsingInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NavigateNonCoopToCoopRpToNonCoop) {}

// Verify that a navigation from a security sensitive page to a COOP:
// restrict-properties changes the CoopRelatedGroup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NavigateWebUiToCoopRp) {}

// Verify that a popup opened with matching COOP: restrict-properties value and
// origin stays in the same SiteInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NoSwapForMatchingPopupAndMainPage) {}

// Verify that a popup in a different BrowsingInstance within the same
// CoopRelatedGroup can come back to the main page SiteInstance if navigating to
// a compatible page.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       ReuseBrowsingInstanceInCoopGroupPopupAndMainPage) {}

// Verify that a popup a in a different BrowsingInstance within the same
// CoopRelatedGroup can come back to the main page SiteInstance if navigating to
// a compatible page, initiated by the renderer.
IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesBrowserTest,
    ReuseBrowsingInstanceInCoopGroupPopupAndMainPageRenderInitiated) {}

// Verify that two pages in different BrowsingInstances within the same
// CoopRelatedGroup can both navigate to a third page, and end up in the same
// SiteInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       ReuseBrowsingInstanceInCoopGroupTwoPopups) {}

// Verify that CSP: sandbox is taken into account for the common coop origin
// computation.
// TODO(crbug.com/40879437): This is not currently the case. Enable once
// COOP is bundled with the appropriate origin.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       DoNotReuseBrowsingInstanceInCoopGroupOpaqueOrigin) {}

// Verify that active WebContents counting works across different
// BrowsingInstances in the same CoopRelatedGroup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       ActiveWebContentsCountInCoopRelatedGroup) {}

// Verify that the COOP: restrict-properties origin is inherited by a subframe.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       CommonCoopOriginInheritedBySubframe) {}

// Verify that the COOP: restrict-properties origin is inherited by a subframe
// even when it specifies its own COOP header, which should be ignored.
IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesBrowserTest,
    CommonCoopOriginInheritedBySubframeOverridesIgnoredCoopHeader) {}

// Verify that the COOP: restrict-properties origin is inherited by a subframe
// even when it is in a popup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       CommonCoopOriginInheritedBySubframeInPopup) {}

// This test verifies that navigating to a COOP: restrict-properties page and
// back uses the appropriate BrowsingInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       HistoryNavigationBackToCoopRpFromNonCoop) {}

// This test verifies that navigating to a regular page from a COOP:
// restrict-properties page and then back, puts the initial page in the
// appropriate BrowsingInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       HistoryNavigationBackToNonCoopFromCoopRp) {}

// This test verifies that a popup initially on a regular page navigates to a
// COOP: restrict-properties page and back gets put in the appropriate
// BrowsingInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       HistoryNavigationBackToCoopRpFromNonCoopInPopup) {}

// This test verifies that a popup initially on a COOP: restrict-properties page
// that navigates to a regular page and then back, gets put in the appropriate
// original BrowsingInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       HistoryNavigationBackToNonCoopFromCoopRpInPopup) {}

// This test verifies that the reload of a COOP: restrict-properties page ends
// up in the appropriate BrowsingInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       HistoryNavigationReloadOfCoopRp) {}

// This test verifies that the failed reload of a COOP: restrict-properties page
// ends up in the appropriate BrowsingInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       HistoryNavigationFailedReloadOfCoopRp) {}

// This test verifies that a back navigation supposed to be in the same
// CoopRelatedGroup, but that ends up in a different one due a change in header
// is handled properly.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       HistoryNavigationsBackToChangedCoopHeader) {}

// This test verifies that after a simple page opens a popup to a COOP:
// restrict-properties page, we have two cross-BrowsingInstance proxies.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       SimpleCrossBrowsingInstanceProxy) {}

// This test verifies that a new iframe in a page that opened a popup in a
// different BrowsingInstance in the same CoopRelatedGroup is not visible to
// the popup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       SubframeInMainPageCrossBrowsingInstanceProxy) {}

// This test verifies that a new iframe in a popup that lives in a different
// BrowsingInstance in the same CoopRelatedGroup has visibility of the opener
// frame and of no other frame in the other BrowsingInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       SubframeInPopupCrossBrowsingInstanceProxy) {}

// This test verifies that a subframe opening a popup in another
// BrowsingInstance in the same CoopRelatedGroup gets the appropriate proxies.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       SubframeOpenerCrossBrowsingInstanceProxy) {}

// This test verifies that a popup opened from a popup already in a different
// BrowsingInstance but same CoopRelatedGroup as its opener, cannot see its
// opener's opener.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       ChainedPopupsCrossBrowsingInstanceProxies) {}

// This test verifies that a new popup opened from a popup in the same
// BrowsingInstance will have visibility of all its BrowsingInstance frames, but
// will only have visibility of the direct opener frame in a different
// BrowsingInstance in the same CoopRelatedGroup.
// TODO(crbug.com/40286486): Failing on Mac bots
#if BUILDFLAG(IS_MAC)
#define MAYBE_ChainedPopupsMixedBrowsingInstanceProxies
#else
#define MAYBE_ChainedPopupsMixedBrowsingInstanceProxies
#endif
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       MAYBE_ChainedPopupsMixedBrowsingInstanceProxies) {}

// Allows waiting until a frame name change is effective in the Browser process.
class FrameNameChangedWaiter : public WebContentsObserver {};

// This test verifies that proxies usually created to support named targeting
// are not created for cross-BrowsingInstance frames.
// TODO(crbug.com/40276662): This test will likely need to change if we
// implement per-BrowsingInstance names. In that case, named targeting would be
// possible using the per-BrowsingContextGroup names, and proxies should be
// created.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       NamedTargetingCrossBrowsingInstanceProxies) {}

// This test verifies that proxies are created on demand to support postMessage
// event.source, even cross-BrowsingInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       PostMessageProxiesCrossBrowsingInstance) {}

// This test verifies that proxies are created on demand to support postMessage
// event.source, even cross-BrowsingInstance, even when the source is an iframe
// for which the target frame's SiteInstanceGroup does not have a main frame
// proxy yet.
// TODO(crbug.com/40286486) Failing on mac bots
#if BUILDFLAG(IS_MAC)
#define MAYBE_SubframePostMessageProxiesCrossBrowsingInstance
#else
#define MAYBE_SubframePostMessageProxiesCrossBrowsingInstance
#endif
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       MAYBE_SubframePostMessageProxiesCrossBrowsingInstance) {}

// Smoke test for the case where a proxy for a given subframe is created before
// other subframe proxies, that might be below it in the indexed order.
// TODO(1495328,40269878): Failing on bots in multiple platforms
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       DISABLED_SubframesProxiesInWrongOrderSmokeTest) {}

// This test verifies that a BrowsingInstance swap to a different
// CoopRelatedGroup clears preexisting proxies to other BrowsingInstances.
IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesProxiesBrowserTest,
    StrictBrowsingInstanceSwapDeletesCrossBrowsingInstanceProxies) {}

// This test verifies that proxies are as expected after a navigation. Start on
// a page with an existing SiteInstance before navigating to a COOP:
// restrict-properties page.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       ExistingSiteInstanceNavigationProxies) {}

// This test verifies that proxies are as expected after a navigation. Start on
// a page in a related SiteInstance before navigating to a COOP:
// restrict-properties page.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       RelatedSiteInstanceNavigationProxies) {}

// This test verifies that proxies are as expected after a navigation. Start on
// a page in an unrelated SiteInstance before navigating to a COOP:
// restrict-properties page.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       UnrelatedSiteInstanceNavigationProxies) {}

// This test verifies that an opener update does not create extra proxies in
// SiteInstanceGroups in other BrowsingInstances.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesProxiesBrowserTest,
                       NoExtraProxyDiscoveredByOpenerUpdate) {}

// This test verifies that named targeting does not resolve across
// BrowsingInstances.
// TODO(crbug.com/40276662): Named targeting might evolve in the future,
// when we're able to have per-BrowsingInstance names. For now, we're simply
// blocking all named targeting.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesBrowserTest,
                       NamedTargetingIsBlockedAcrossBrowsingInstances) {}

// Smoke test with kNewBrowsingContextStateOnBrowsingContextGroupSwap enabled.
// Verifies that nothing breaks when we're dealing with proxies across different
// BrowsingInstances with COOP: restrict-properties.
// TODO(crbug.com/40061970): Enable once BrowsingContextState new mode
// implementation is further down the line. Currently this test crashes even
// with COOP: same-origin.
IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesWithNewBrowsingContextStateModeBrowserTest,
    DISABLED_BrowsingContextStateNewModeSmokeTest) {}

IN_PROC_BROWSER_TEST_P(NoSiteIsolationCrossOriginIsolationBrowserTest,
                       COICanLiveInDefaultSI) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       ConsoleErrorOnWindowLocationAccess) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       ConsoleErrorOnWindowIndexedAccess) {}

IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       ConsoleErrorOnWindowNamedAccess) {}

// Navigate in between two documents. Check the virtual browsing context group
// is properly updated.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesReportingBrowserTest,
                       NavigationVirtualBrowsingContextGroup) {}

// Navigate in between two documents. Check the virtual browsing context group
// is properly updated.
IN_PROC_BROWSER_TEST_P(CrossOriginOpenerPolicyBrowserTest,
                       NavigationVirtualBrowsingContextGroupNoopener) {}

// Use window.open(url). Check the virtual browsing context group of the two
// window.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesReportingBrowserTest,
                       WindowOpenVirtualBrowsingContextGroup) {}

// Verify that two documents in different browsing context groups in the same
// CoopRelatedGroup only have access to window.closed and window.postMessage().
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       PropertiesAreBlockedAcrossBrowsingContextGroup) {}

// Verifies that the BrowsingContextGroupInfo is properly propagated when
// opening a popup in the same SiteInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       SimpleLocalPopup) {}

// Verifies that the BrowsingContextGroupInfo is properly propagated when
// opening a popup in the same browsing context group in another SiteInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       SimpleRemotePopup) {}

// Verifies that the BrowsingContextGroupInfo is properly propagated when
// opening a popup in another browsing context group in the same
// CoopRelatedGroup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       SimpleCoopPopup) {}

// Verifies in more details how the BrowsingContextGroupInfo is propagated when
// opening a popup in another browsing context group in the same
// CoopRelatedGroup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       SimpleCoopPopupDetailed) {}

// Verifies that BrowsingContextGroupInfo is properly propagated to an iframe
// in the same SiteInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest, LocalSubframe) {}

// Verifies that BrowsingContextGroupInfo is properly propagated to an iframe
// in the same browsing context group in another SiteInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       RemoteSubframe) {}

// Verifies that BrowsingContextGroupInfo is properly propagated to iframes and
// iframes in popups, all living in the same SiteInstance.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       LocalSubframesInPopup) {}

// Verifies that BrowsingContextGroupInfo is properly propagated to iframes and
// iframes in popups, all living in the same browsing context group.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       RemoteSubframesInPopup) {}

// Verifies that BrowsingContextGroupInfo is properly propagated to iframes and
// iframes in popups living in a different browsing context group in the same
// CoopRelatedGroup.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       SubframesInCoopPopup) {}

// Verify that navigating to another browsing context group in the same
// CoopRelatedGroup and ending up in an error page propagates the
// BrowsingContextGroupInfo properly.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       NavigationToError) {}

// Verify that navigating to another browsing context group in the same
// CoopRelatedGroup and going back propagates the BrowsingContextGroupInfo
// properly.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       HistoryNavigation) {}

// Verify that activating a BackForwardCache entry in another browsing context
// group propagates the BrowsingContextGroupInfo properly.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       BackForwardCacheNavigation) {}

// Verify that navigating to another browsing context group in the same
// CoopRelatedGroup from a crashed frame propagates the BrowsingContextGroupInfo
// properly.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       PostCrashNavigation) {}

// Verify that navigating to another browsing context group in another
// CoopRelatedGroup, in one of the rare cases that preserve openers (here to a
// WebUI), propagates the correct BrowsingContextGroupInfo.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       NavigationToOtherCoopRelatedGroup) {}

// This test verifies that two pages in different browsing context groups with
// the same origin trying to access each other does not cause a crash.
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       SameOriginInDifferentBrowsingContextGroupAccess) {}

// Similar to above test, but forces process reuse to have both the popup and
// the main page live in the same process.
IN_PROC_BROWSER_TEST_P(
    CoopRestrictPropertiesAccessBrowserTest,
    SameOriginInDifferentBrowsingContextGroupAccessSameProcess) {}

// Regression test for https://crbug.com/1491282.  Ensure that when a
// navigation to a COOP: RP page requires a new BrowsingInstance in a new
// CoopRelatedGroup, a subsequent navigation that stays in the same
// CoopRelatedGroup does not crash.  In this case, it is essential that when a
// new non-COOP BrowsingInstance in a new CoopRelatedGroup is created at
// request start time, that BrowsingInstance isn't incorrectly reused at
// response started time, if the response came back with COOP: RP headers and
// requires a BrowsingInstance with a different common_coop_origin().
IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest,
                       NewBrowsingInstanceFromBeginNavigationCannotBeReused) {}

IN_PROC_BROWSER_TEST_P(CoopRestrictPropertiesAccessBrowserTest, Prerender) {}

}  // namespace content