Changeset 281832 in webkit


Ignore:
Timestamp:
Aug 31, 2021 4:53:15 PM (11 months ago)
Author:
Chris Dumez
Message:

Enable SharedArrayBuffer support when COOP/COEP headers are used
https://bugs.webkit.org/show_bug.cgi?id=229559
<rdar://problem/82391945>

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline a few web-platform-tests now that window.crossOriginIsolated properly returns
true when COOP+COEP are used.

Note that SharedArrayBuffer are already forcefully enabled by run-webkit-tests.py when running
the layout tests, which is why there are not more layout test results changes. At some point,
we should stop forcefully enabling SharedArrayBuffer when running web-platform-tests at least,
since WPT tests already make sure to use COOP+COEP when testing SharedArrayBuffer.

  • web-platform-tests/IndexedDB/serialize-sharedarraybuffer-throws.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https-expected.txt:

Note that some subtests are failing because we don't support the Permissions-Policy HTTP header:

  • web-platform-tests/html/cross-origin-opener-policy/coep.https-expected.txt:

Source/WebCore:

Make sure window.crossOriginIsolated returns true when COOP=same-origin and
COEP=require-corp are used. Also make sure that cross-origin-isolates pages
are allowed to use SharedArrayBuffer.

Change is covered by rebaselined layout tests and new API tests.

  • loader/DocumentLoader.cpp:

(WebCore::toNeedsBrowsingContextGroupSwitch):
(WebCore::DocumentLoader::responseReceived):

  • loader/EmptyClients.cpp:

(WebCore::EmptyFrameLoaderClient::dispatchDecidePolicyForResponse):

  • loader/EmptyFrameLoaderClient.h:
  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::checkContentPolicy):

  • loader/FrameLoader.h:
  • loader/FrameLoaderClient.h:
  • loader/FrameLoaderTypes.h:
  • page/DOMWindow.cpp:

(WebCore::DOMWindow::crossOriginIsolated const):

  • page/DOMWindow.idl:

Source/WebKit:

Make sure window.crossOriginIsolated returns true when COOP=same-origin and
COEP=require-corp are used. Also make sure that cross-origin-isolates pages
are allowed to use SharedArrayBuffer.

When the WebProcess determines it needs to switch browsing context group it
now sends a NeedsBrowsingContextGroupSwitch::YesWithoutCrossOriginIsolation /
NeedsBrowsingContextGroupSwitch::YesWithCrossOriginIsolation enum value to
the UIProcess with the DecidePolicyForResponse IPC instead of a simple
boolean. We send YesWithoutCrossOriginIsolation when the navigation
destination will be cross-origin-isolated due to COOP=same-origin and
COEP=require-corp. In the UIProcess, when YesWithCrossOriginIsolation is
received, we take care of launching a fresh WebProcess (never recycling an
existing WebProcess) and we make this WebProcess as cross-origin-isolated.
When a process is cross-origin-isolated, we pass it a XPC flag on launch
to allow the process to use SharedArrayBuffer. We use an XPC flag because
JSC Options need to be set before JSC::initialize() is called, which occurs
during XPC service initialization. When a WebProcess is marked as
cross-origin-isolated, we make sure to never cache it so it cannot be
recycled for a new navigation (given that it has special permission to use
SharedArrayBuffer).

  • Scripts/webkit/messages.py:

(headers_for_type):

  • Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:

(WebKit::XPCServiceInitializer):

  • UIProcess/Launcher/ProcessLauncher.h:

(WebKit::ProcessLauncher::Client::shouldEnableSharedArrayBuffer const):

  • UIProcess/Launcher/mac/ProcessLauncherMac.mm:

(WebKit::ProcessLauncher::launchProcess):

  • UIProcess/ProvisionalPageProxy.cpp:

(WebKit::ProvisionalPageProxy::decidePolicyForResponse):

  • UIProcess/ProvisionalPageProxy.h:
  • UIProcess/SuspendedPageProxy.cpp:

(WebKit::SuspendedPageProxy::findReusableSuspendedPageProcess):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::decidePolicyForResponse):
(WebKit::WebPageProxy::decidePolicyForResponseShared):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::createNewWebProcess):
(WebKit::WebProcessPool::createWebPage):

  • UIProcess/WebProcessPool.h:
  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::create):
(WebKit::WebProcessProxy::createForServiceWorkers):
(WebKit::WebProcessProxy::WebProcessProxy):
(WebKit::WebProcessProxy::canBeAddedToWebProcessCache const):

  • UIProcess/WebProcessProxy.h:

(WebKit::WebProcessProxy::isCrossOriginIsolated const):

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

Source/WebKitLegacy/mac:

  • WebCoreSupport/WebFrameLoaderClient.h:
  • WebCoreSupport/WebFrameLoaderClient.mm:

(WebFrameLoaderClient::dispatchDecidePolicyForResponse):

Source/WebKitLegacy/win:

  • WebCoreSupport/WebFrameLoaderClient.cpp:

(WebFrameLoaderClient::dispatchDecidePolicyForResponse):

  • WebCoreSupport/WebFrameLoaderClient.h:

Tools:

Add API test coverage. SharedArrayBuffer support is currently forcefully enabled by
run-webkit-tests.py so it would not be practical to write layout tests for this at
the moment.

  • TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:

(-[PSONScheme addMappingFromURLString:toData:withCOOPValue:withCOEPValue:]):
(-[PSONScheme webView:startURLSchemeTask:]):

Location:
trunk
Files:
2 added
47 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r281830 r281832  
     12021-08-31  Chris Dumez  <cdumez@apple.com>
     2
     3        Enable SharedArrayBuffer support when COOP/COEP headers are used
     4        https://bugs.webkit.org/show_bug.cgi?id=229559
     5        <rdar://problem/82391945>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Rebaseline a few web-platform-tests now that window.crossOriginIsolated properly returns
     10        true when COOP+COEP are used.
     11
     12        Note that SharedArrayBuffer are already forcefully enabled by run-webkit-tests.py when running
     13        the layout tests, which is why there are not more layout test results changes. At some point,
     14        we should stop forcefully enabling SharedArrayBuffer when running web-platform-tests at least,
     15        since WPT tests already make sure to use COOP+COEP when testing SharedArrayBuffer.
     16
     17        * web-platform-tests/IndexedDB/serialize-sharedarraybuffer-throws.https-expected.txt:
     18        * web-platform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https-expected.txt:
     19        Note that some subtests are failing because we don't support the Permissions-Policy HTTP header:
     20        - https://w3c.github.io/webappsec-permissions-policy/
     21
     22        * web-platform-tests/html/cross-origin-opener-policy/coep.https-expected.txt:
     23
    1242021-08-31  Marcos Caceres  <marcos@marcosc.com>
    225
  • trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/serialize-sharedarraybuffer-throws.https-expected.txt

    r280504 r281832  
    11
    2 FAIL IndexedDB: Attempting to serialize a SharedArrayBuffer should throw assert_true: The page is served with COOP and COEP, it should be cross-origin-isolated. expected true got false
     2FAIL IndexedDB: Attempting to serialize a SharedArrayBuffer should throw assert_throws_dom: function "() => {
     3            rq = objStore.put({sab: sab}, 'key');
     4        }" threw object "DataError: Failed to store record in an IDBObjectStore: The object store uses in-line keys and the key parameter was provided." that is not a DOMException DataCloneError: property "code" is equal to 0, expected 25
    35
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https-expected.txt

    r281055 r281832  
    11
    2 FAIL frame: origin = https://localhost:9443, value = undefined assert_equals: expected true but got false
    3 FAIL frame: origin = https://localhost:9443, value = * assert_equals: expected true but got false
    4 FAIL frame: origin = https://localhost:9443, value = self assert_equals: expected true but got false
    5 PASS frame: origin = https://localhost:9443, value = (\)
    6 PASS frame: origin = https://127.0.0.1:9443, value = undefined
    7 PASS frame: origin = https://127.0.0.1:9443, value = *
    8 PASS frame: origin = https://127.0.0.1:9443, value = self
    9 PASS frame: origin = https://127.0.0.1:9443, value = (\)
    10 FAIL dedicated worker: scheme = https, value = undefined assert_equals: expected true but got false
    11 FAIL dedicated worker: scheme = https, value = * assert_equals: expected true but got false
    12 FAIL dedicated worker: scheme = https, value = self assert_equals: expected true but got false
    13 PASS dedicated worker: scheme = https, value = (\)
    14 PASS dedicated worker: scheme = data, value = undefined
    15 PASS dedicated worker: scheme = data, value = *
    16 PASS dedicated worker: scheme = data, value = self
    17 PASS dedicated worker: scheme = data, value = (\)
    18 FAIL dedicated worker: scheme = blob, value = undefined assert_equals: expected true but got false
    19 FAIL dedicated worker: scheme = blob, value = * assert_equals: expected true but got false
    20 FAIL dedicated worker: scheme = blob, value = self assert_equals: expected true but got false
    21 PASS dedicated worker: scheme = blob, value = (\)
     2PASS frame: origin = https://localhost:9443, value = undefined
     3PASS frame: origin = https://localhost:9443, value = *
     4PASS frame: origin = https://localhost:9443, value = self
     5FAIL frame: origin = https://localhost:9443, value = (\) assert_equals: expected false but got true
     6FAIL frame: origin = https://127.0.0.1:9443, value = undefined assert_equals: expected false but got true
     7FAIL frame: origin = https://127.0.0.1:9443, value = * assert_equals: expected false but got true
     8FAIL frame: origin = https://127.0.0.1:9443, value = self assert_equals: expected false but got true
     9FAIL frame: origin = https://127.0.0.1:9443, value = (\) assert_equals: expected false but got true
     10PASS dedicated worker: scheme = https, value = undefined
     11PASS dedicated worker: scheme = https, value = *
     12PASS dedicated worker: scheme = https, value = self
     13FAIL dedicated worker: scheme = https, value = (\) assert_equals: expected false but got true
     14FAIL dedicated worker: scheme = data, value = undefined assert_equals: expected false but got true
     15FAIL dedicated worker: scheme = data, value = * assert_equals: expected false but got true
     16FAIL dedicated worker: scheme = data, value = self assert_equals: expected false but got true
     17FAIL dedicated worker: scheme = data, value = (\) assert_equals: expected false but got true
     18PASS dedicated worker: scheme = blob, value = undefined
     19PASS dedicated worker: scheme = blob, value = *
     20PASS dedicated worker: scheme = blob, value = self
     21FAIL dedicated worker: scheme = blob, value = (\) assert_equals: expected false but got true
    2222FAIL shared worker: withCoopCoep = false Can't find variable: SharedWorker
    2323FAIL shared worker: withCoopCoep = true Can't find variable: SharedWorker
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-opener-policy/coep.https-expected.txt

    r280504 r281832  
    88PASS Same-origin popup without coep
    99PASS historical: "same-site" popup without coep
    10 FAIL Bonus: window.crossOriginIsolated assert_true: expected true got false
     10PASS Bonus: window.crossOriginIsolated
    1111
  • trunk/Source/WebCore/ChangeLog

    r281831 r281832  
     12021-08-31  Chris Dumez  <cdumez@apple.com>
     2
     3        Enable SharedArrayBuffer support when COOP/COEP headers are used
     4        https://bugs.webkit.org/show_bug.cgi?id=229559
     5        <rdar://problem/82391945>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Make sure window.crossOriginIsolated returns true when COOP=same-origin and
     10        COEP=require-corp are used. Also make sure that cross-origin-isolates pages
     11        are allowed to use SharedArrayBuffer.
     12
     13        Change is covered by rebaselined layout tests and new API tests.
     14
     15        * loader/DocumentLoader.cpp:
     16        (WebCore::toNeedsBrowsingContextGroupSwitch):
     17        (WebCore::DocumentLoader::responseReceived):
     18        * loader/EmptyClients.cpp:
     19        (WebCore::EmptyFrameLoaderClient::dispatchDecidePolicyForResponse):
     20        * loader/EmptyFrameLoaderClient.h:
     21        * loader/FrameLoader.cpp:
     22        (WebCore::FrameLoader::checkContentPolicy):
     23        * loader/FrameLoader.h:
     24        * loader/FrameLoaderClient.h:
     25        * loader/FrameLoaderTypes.h:
     26        * page/DOMWindow.cpp:
     27        (WebCore::DOMWindow::crossOriginIsolated const):
     28        * page/DOMWindow.idl:
     29
    1302021-08-31  Kate Cheney  <katherine_cheney@apple.com>
    231
  • trunk/Source/WebCore/Headers.cmake

    r281808 r281832  
    435435    dom/ContainerNode.h
    436436    dom/ContextDestructionObserver.h
     437    dom/CrossOriginMode.h
    437438    dom/CustomElementReactionQueue.h
    438439    dom/DOMException.h
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r281808 r281832  
    12951295                4682D2001F79783000C863DB /* StoredCredentialsPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4682D1FF1F79782300C863DB /* StoredCredentialsPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
    12961296                468344E01EDDFAAA00B7795B /* DOMRectList.h in Headers */ = {isa = PBXBuildFile; fileRef = 468344DE1EDDFA5F00B7795B /* DOMRectList.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1297                4688EE3C26DD2610002AF5C4 /* CrossOriginMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4688EE3A26DD260C002AF5C4 /* CrossOriginMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    12971298                469CCCFE269D021C006E0314 /* BroadcastChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 469CCCFC269D0202006E0314 /* BroadcastChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
    12981299                46AAAA3D25D3632000BAF42F /* AudioFileReaderCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 46AAAA3A25D3631400BAF42F /* AudioFileReaderCocoa.h */; };
     
    83368337                468344DD1EDDFA5F00B7795B /* DOMRectList.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMRectList.cpp; sourceTree = "<group>"; };
    83378338                468344DE1EDDFA5F00B7795B /* DOMRectList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMRectList.h; sourceTree = "<group>"; };
     8339                4688EE3A26DD260C002AF5C4 /* CrossOriginMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CrossOriginMode.h; sourceTree = "<group>"; };
    83388340                468B8BDE25CC849300F67822 /* JSBaseAudioContextCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBaseAudioContextCustom.cpp; sourceTree = "<group>"; };
    83398341                469CCCFA269D0202006E0314 /* BroadcastChannel.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BroadcastChannel.cpp; sourceTree = "<group>"; };
     
    2987229874                                97627B8B14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp */,
    2987329875                                97627B8C14FB3CEE002CDCA1 /* ContextDestructionObserver.h */,
     29876                                4688EE3A26DD260C002AF5C4 /* CrossOriginMode.h */,
    2987429877                                7CF570C62492BD49008EB33C /* CurrentScriptIncrementer.h */,
    2987529878                                9B56C9A91C89329A00C456DF /* CustomElementReactionQueue.cpp */,
     
    3150031503                                E1C416120F6562FD0092D2FB /* CrossOriginAccessControl.h in Headers */,
    3150131504                                4672AA9826B0943300E6EC38 /* CrossOriginEmbedderPolicy.h in Headers */,
     31505                                4688EE3C26DD2610002AF5C4 /* CrossOriginMode.h in Headers */,
    3150231506                                4672AA9926B0943F00E6EC38 /* CrossOriginOpenerPolicy.h in Headers */,
    3150331507                                41ABE67B1D0580DB006D862D /* CrossOriginPreflightChecker.h in Headers */,
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r281055 r281832  
    8282using namespace Inspector;
    8383
     84static std::atomic<CrossOriginMode> globalCrossOriginMode { CrossOriginMode::Shared };
     85
    8486static Lock allScriptExecutionContextsMapLock;
    8587static HashMap<ScriptExecutionContextIdentifier, ScriptExecutionContext*>& allScriptExecutionContextsMap() WTF_REQUIRES_LOCK(allScriptExecutionContextsMapLock)
     
    624626#endif
    625627
     628void ScriptExecutionContext::setCrossOriginMode(CrossOriginMode crossOriginMode)
     629{
     630    globalCrossOriginMode = crossOriginMode;
     631}
     632
     633CrossOriginMode ScriptExecutionContext::crossOriginMode()
     634{
     635    return globalCrossOriginMode;
     636}
     637
    626638bool ScriptExecutionContext::postTaskTo(ScriptExecutionContextIdentifier identifier, Task&& task)
    627639{
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r281771 r281832  
    2929
    3030#include "ActiveDOMObject.h"
     31#include "CrossOriginMode.h"
    3132#include "DOMTimer.h"
    3233#include "PermissionController.h"
     
    175176    virtual void beginLoadingFontSoon(FontLoadRequest&) { }
    176177
     178    WEBCORE_EXPORT static void setCrossOriginMode(CrossOriginMode);
     179    static CrossOriginMode crossOriginMode();
     180
    177181    void ref() { refScriptExecutionContext(); }
    178182    void deref() { derefScriptExecutionContext(); }
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r281802 r281832  
    949949}
    950950
     951static BrowsingContextGroupSwitchDecision toBrowsingContextGroupSwitchDecision(const std::optional<CrossOriginOpenerPolicyEnforcementResult>& currentCoopEnforcementResult)
     952{
     953    if (!currentCoopEnforcementResult || !currentCoopEnforcementResult->needsBrowsingContextGroupSwitch)
     954        return BrowsingContextGroupSwitchDecision::StayInGroup;
     955    if (currentCoopEnforcementResult->crossOriginOpenerPolicy.value == CrossOriginOpenerPolicyValue::SameOriginPlusCOEP)
     956        return BrowsingContextGroupSwitchDecision::NewIsolatedGroup;
     957    return BrowsingContextGroupSwitchDecision::NewSharedGroup;
     958}
     959
    951960void DocumentLoader::responseReceived(const ResourceResponse& response, CompletionHandler<void()>&& completionHandler)
    952961{
     
    10491058        mainResourceLoader->markInAsyncResponsePolicyCheck();
    10501059    auto requestIdentifier = PolicyCheckIdentifier::create();
    1051     bool needsBrowsingContextGroupSwitch = m_currentCoopEnforcementResult && m_currentCoopEnforcementResult->needsBrowsingContextGroupSwitch;
    1052     frameLoader()->checkContentPolicy(m_response, requestIdentifier, needsBrowsingContextGroupSwitch, [this, protectedThis = makeRef(*this), mainResourceLoader = WTFMove(mainResourceLoader),
     1060    auto browsingContextGroupSwitchDecision = toBrowsingContextGroupSwitchDecision(m_currentCoopEnforcementResult);
     1061    frameLoader()->checkContentPolicy(m_response, requestIdentifier, browsingContextGroupSwitchDecision, [this, protectedThis = makeRef(*this), mainResourceLoader = WTFMove(mainResourceLoader),
    10531062        completionHandler = completionHandlerCaller.release(), requestIdentifier] (PolicyAction policy, PolicyCheckIdentifier responseIdentifier) mutable {
    10541063        RELEASE_ASSERT(responseIdentifier.isValidFor(requestIdentifier));
  • trunk/Source/WebCore/loader/EmptyClients.cpp

    r281818 r281832  
    818818}
    819819
    820 void EmptyFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceResponse&, const ResourceRequest&, PolicyCheckIdentifier, const String&, bool, FramePolicyFunction&&)
     820void EmptyFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceResponse&, const ResourceRequest&, PolicyCheckIdentifier, const String&, BrowsingContextGroupSwitchDecision, FramePolicyFunction&&)
    821821{
    822822}
  • trunk/Source/WebCore/loader/EmptyFrameLoaderClient.h

    r281516 r281832  
    9797    void dispatchShow() final;
    9898
    99     void dispatchDecidePolicyForResponse(const ResourceResponse&, const ResourceRequest&, PolicyCheckIdentifier, const String&, bool needsBrowsingContextGroupSwitch, FramePolicyFunction&&) final;
     99    void dispatchDecidePolicyForResponse(const ResourceResponse&, const ResourceRequest&, PolicyCheckIdentifier, const String&, BrowsingContextGroupSwitchDecision, FramePolicyFunction&&) final;
    100100    void dispatchDecidePolicyForNewWindowAction(const NavigationAction&, const ResourceRequest&, FormState*, const String&, PolicyCheckIdentifier, FramePolicyFunction&&) final;
    101101    void dispatchDecidePolicyForNavigationAction(const NavigationAction&, const ResourceRequest&, const ResourceResponse& redirectResponse, FormState*, PolicyDecisionMode, PolicyCheckIdentifier, FramePolicyFunction&&) final;
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r281817 r281832  
    414414}
    415415
    416 void FrameLoader::checkContentPolicy(const ResourceResponse& response, PolicyCheckIdentifier identifier, bool needsBrowsingContextGroupSwitch, ContentPolicyDecisionFunction&& function)
     416void FrameLoader::checkContentPolicy(const ResourceResponse& response, PolicyCheckIdentifier identifier, BrowsingContextGroupSwitchDecision browsingContextGroupSwitchDecision, ContentPolicyDecisionFunction&& function)
    417417{
    418418    if (!activeDocumentLoader()) {
     
    423423
    424424    // FIXME: Validate the policy check identifier.
    425     client().dispatchDecidePolicyForResponse(response, activeDocumentLoader()->request(), identifier, activeDocumentLoader()->downloadAttribute(), needsBrowsingContextGroupSwitch, WTFMove(function));
     425    client().dispatchDecidePolicyForResponse(response, activeDocumentLoader()->request(), identifier, activeDocumentLoader()->downloadAttribute(), browsingContextGroupSwitchDecision, WTFMove(function));
    426426}
    427427
  • trunk/Source/WebCore/loader/FrameLoader.h

    r281516 r281832  
    221221    void setDefersLoading(bool);
    222222
    223     void checkContentPolicy(const ResourceResponse&, PolicyCheckIdentifier, bool needsBrowsingContextGroupSwitch, ContentPolicyDecisionFunction&&);
     223    void checkContentPolicy(const ResourceResponse&, PolicyCheckIdentifier, BrowsingContextGroupSwitchDecision, ContentPolicyDecisionFunction&&);
    224224
    225225    void didExplicitOpen();
  • trunk/Source/WebCore/loader/FrameLoaderClient.h

    r281516 r281832  
    191191    virtual void dispatchShow() = 0;
    192192
    193     virtual void dispatchDecidePolicyForResponse(const ResourceResponse&, const ResourceRequest&, PolicyCheckIdentifier, const String& downloadAttribute, bool needsBrowsingContextGroupSwitch, FramePolicyFunction&&) = 0;
     193    virtual void dispatchDecidePolicyForResponse(const ResourceResponse&, const ResourceRequest&, PolicyCheckIdentifier, const String& downloadAttribute, BrowsingContextGroupSwitchDecision, FramePolicyFunction&&) = 0;
    194194    virtual void dispatchDecidePolicyForNewWindowAction(const NavigationAction&, const ResourceRequest&, FormState*, const String& frameName, PolicyCheckIdentifier, FramePolicyFunction&&) = 0;
    195195    virtual void dispatchDecidePolicyForNavigationAction(const NavigationAction&, const ResourceRequest&, const ResourceResponse& redirectResponse, FormState*, PolicyDecisionMode, PolicyCheckIdentifier, FramePolicyFunction&&) = 0;
  • trunk/Source/WebCore/loader/FrameLoaderTypes.h

    r280870 r281832  
    168168};
    169169
     170enum class BrowsingContextGroupSwitchDecision : uint8_t {
     171    StayInGroup,
     172    NewSharedGroup,
     173    NewIsolatedGroup,
     174};
     175
    170176// Passed to FrameLoader::urlSelected() and ScriptController::executeIfJavaScriptURL()
    171177// to control whether, in the case of a JavaScript URL, executeIfJavaScriptURL() should
     
    277283};
    278284
     285template<> struct EnumTraits<WebCore::BrowsingContextGroupSwitchDecision> {
     286    using values = EnumValues<
     287        WebCore::BrowsingContextGroupSwitchDecision,
     288        WebCore::BrowsingContextGroupSwitchDecision::StayInGroup,
     289        WebCore::BrowsingContextGroupSwitchDecision::NewSharedGroup,
     290        WebCore::BrowsingContextGroupSwitchDecision::NewIsolatedGroup
     291    >;
     292};
     293
    279294template<> struct EnumTraits<WebCore::ShouldOpenExternalURLsPolicy> {
    280295    using values = EnumValues<
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r281808 r281832  
    19251925bool DOMWindow::crossOriginIsolated() const
    19261926{
    1927     // FIXME: Implemented this. This should return true if COOP/COEP are used and the page is allowed to use APIs
    1928     // that require cross-origin isolation (e.g. SharedArrayBuffer).
    1929     return false;
     1927    ASSERT(ScriptExecutionContext::crossOriginMode() == CrossOriginMode::Shared || !document() || document()->topDocument().crossOriginOpenerPolicy().value == CrossOriginOpenerPolicyValue::SameOriginPlusCOEP);
     1928    return ScriptExecutionContext::crossOriginMode() == CrossOriginMode::Isolated;
    19301929}
    19311930
  • trunk/Source/WebCore/page/DOMWindow.idl

    r281808 r281832  
    8080    // FIXME: This is specified to be [SecureContext]
    8181    readonly attribute DOMApplicationCache applicationCache;
    82     // FIXME: Implement 'originIsolated'
    83     // readonly attribute boolean originIsolated;
    8482
    8583    // user prompts
  • trunk/Source/WebCore/workers/WorkerGlobalScope.cpp

    r281808 r281832  
    587587bool WorkerGlobalScope::crossOriginIsolated() const
    588588{
    589     // FIXME: Implemented this. This should return true if COOP/COEP are used and the page is allowed to use APIs
    590     // that require cross-origin isolation (e.g. SharedArrayBuffer).
    591     return false;
     589    return ScriptExecutionContext::crossOriginMode() == CrossOriginMode::Isolated;
    592590}
    593591
  • trunk/Source/WebKit/ChangeLog

    r281831 r281832  
     12021-08-31  Chris Dumez  <cdumez@apple.com>
     2
     3        Enable SharedArrayBuffer support when COOP/COEP headers are used
     4        https://bugs.webkit.org/show_bug.cgi?id=229559
     5        <rdar://problem/82391945>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Make sure window.crossOriginIsolated returns true when COOP=same-origin and
     10        COEP=require-corp are used. Also make sure that cross-origin-isolates pages
     11        are allowed to use SharedArrayBuffer.
     12
     13        When the WebProcess determines it needs to switch browsing context group it
     14        now sends a NeedsBrowsingContextGroupSwitch::YesWithoutCrossOriginIsolation /
     15        NeedsBrowsingContextGroupSwitch::YesWithCrossOriginIsolation enum value to
     16        the UIProcess with the DecidePolicyForResponse IPC instead of a simple
     17        boolean. We send YesWithoutCrossOriginIsolation when the navigation
     18        destination will be cross-origin-isolated due to COOP=same-origin and
     19        COEP=require-corp. In the UIProcess, when YesWithCrossOriginIsolation is
     20        received, we take care of launching a fresh WebProcess (never recycling an
     21        existing WebProcess) and we make this WebProcess as cross-origin-isolated.
     22        When a process is cross-origin-isolated, we pass it a XPC flag on launch
     23        to allow the process to use SharedArrayBuffer. We use an XPC flag because
     24        JSC Options need to be set before JSC::initialize() is called, which occurs
     25        during XPC service initialization. When a WebProcess is marked as
     26        cross-origin-isolated, we make sure to never cache it so it cannot be
     27        recycled for a new navigation (given that it has special permission to use
     28        SharedArrayBuffer).
     29
     30        * Scripts/webkit/messages.py:
     31        (headers_for_type):
     32        * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:
     33        (WebKit::XPCServiceInitializer):
     34        * UIProcess/Launcher/ProcessLauncher.h:
     35        (WebKit::ProcessLauncher::Client::shouldEnableSharedArrayBuffer const):
     36        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
     37        (WebKit::ProcessLauncher::launchProcess):
     38        * UIProcess/ProvisionalPageProxy.cpp:
     39        (WebKit::ProvisionalPageProxy::decidePolicyForResponse):
     40        * UIProcess/ProvisionalPageProxy.h:
     41        * UIProcess/SuspendedPageProxy.cpp:
     42        (WebKit::SuspendedPageProxy::findReusableSuspendedPageProcess):
     43        * UIProcess/WebPageProxy.cpp:
     44        (WebKit::WebPageProxy::decidePolicyForResponse):
     45        (WebKit::WebPageProxy::decidePolicyForResponseShared):
     46        * UIProcess/WebPageProxy.h:
     47        * UIProcess/WebPageProxy.messages.in:
     48        * UIProcess/WebProcessPool.cpp:
     49        (WebKit::WebProcessPool::createNewWebProcess):
     50        (WebKit::WebProcessPool::createWebPage):
     51        * UIProcess/WebProcessPool.h:
     52        * UIProcess/WebProcessProxy.cpp:
     53        (WebKit::WebProcessProxy::create):
     54        (WebKit::WebProcessProxy::createForServiceWorkers):
     55        (WebKit::WebProcessProxy::WebProcessProxy):
     56        (WebKit::WebProcessProxy::canBeAddedToWebProcessCache const):
     57        * UIProcess/WebProcessProxy.h:
     58        (WebKit::WebProcessProxy::isCrossOriginIsolated const):
     59        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     60        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
     61        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
     62
    1632021-08-31  Kate Cheney  <katherine_cheney@apple.com>
    264
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r281732 r281832  
    688688        'PAL::SessionID': ['<pal/SessionID.h>'],
    689689        'WebCore::AutoplayEventFlags': ['<WebCore/AutoplayEvent.h>'],
     690        'WebCore::BrowsingContextGroupSwitchDecision': ['<WebCore/FrameLoaderTypes.h>'],
    690691        'WebCore::CreateNewGroupForHighlight': ['<WebCore/AppHighlight.h>'],
    691692        'WebCore::DOMPasteAccessResponse': ['<WebCore/DOMPasteAccess.h>'],
  • trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h

    r279890 r281832  
    9393        if (xpc_dictionary_get_bool(initializerMessage, "disable-jit"))
    9494            JSC::ExecutableAllocator::setJITEnabled(false);
     95        if (xpc_dictionary_get_bool(initializerMessage, "enable-shared-array-buffer")) {
     96            JSC::Options::initialize();
     97            JSC::Options::AllowUnfinalizedAccessScope scope;
     98            JSC::Options::useSharedArrayBuffer() = true;
     99        }
    95100    }
    96101
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp

    r281277 r281832  
    123123    encoder << attrStyleEnabled;
    124124    encoder << shouldThrowExceptionForGlobalConstantRedeclaration;
     125    encoder << crossOriginMode;
    125126
    126127#if ENABLE(SERVICE_CONTROLS)
     
    390391    if (!decoder.decode(parameters.shouldThrowExceptionForGlobalConstantRedeclaration))
    391392        return false;
     393    if (!decoder.decode(parameters.crossOriginMode))
     394        return false;
    392395
    393396#if ENABLE(SERVICE_CONTROLS)
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.h

    r281277 r281832  
    3232#include "UserData.h"
    3333#include "WebProcessDataStoreParameters.h"
     34#include <WebCore/CrossOriginMode.h>
    3435#include <wtf/HashMap.h>
    3536#include <wtf/ProcessID.h>
     
    136137    bool attrStyleEnabled { false };
    137138    bool shouldThrowExceptionForGlobalConstantRedeclaration { true };
     139    WebCore::CrossOriginMode crossOriginMode { WebCore::CrossOriginMode::Shared }; // Cross-origin isolation via COOP+COEP headers.
    138140
    139141#if ENABLE(SERVICE_CONTROLS)
  • trunk/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h

    r272882 r281832  
    6262        virtual bool shouldConfigureJSCForTesting() const { return false; }
    6363        virtual bool isJITEnabled() const { return true; }
     64        virtual bool shouldEnableSharedArrayBuffer() const { return false; }
    6465#if PLATFORM(COCOA)
    6566        virtual RefPtr<XPCEventHandler> xpcEventHandler() const { return nullptr; }
  • trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm

    r280811 r281832  
    206206        if (!m_client->isJITEnabled())
    207207            xpc_dictionary_set_bool(bootstrapMessage.get(), "disable-jit", true);
     208        if (m_client->shouldEnableSharedArrayBuffer())
     209            xpc_dictionary_set_bool(bootstrapMessage.get(), "enable-shared-array-buffer", true);
    208210    }
    209211
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp

    r281817 r281832  
    331331}
    332332
    333 void ProvisionalPageProxy::decidePolicyForResponse(FrameIdentifier frameID, FrameInfoData&& frameInfo, WebCore::PolicyCheckIdentifier identifier, uint64_t navigationID, const WebCore::ResourceResponse& response, const WebCore::ResourceRequest& request, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, bool needsBrowsingContextGroupSwitch, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData& userData)
     333void ProvisionalPageProxy::decidePolicyForResponse(FrameIdentifier frameID, FrameInfoData&& frameInfo, WebCore::PolicyCheckIdentifier identifier, uint64_t navigationID, const WebCore::ResourceResponse& response, const WebCore::ResourceRequest& request, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, BrowsingContextGroupSwitchDecision browsingContextGroupSwitchDecision, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData& userData)
    334334{
    335335    if (!validateInput(frameID, navigationID))
    336336        return;
    337337
    338     m_page.decidePolicyForResponseShared(m_process.copyRef(), m_webPageID, frameID, WTFMove(frameInfo), identifier, navigationID, response, request, canShowMIMEType, downloadAttribute, wasAllowedByInjectedBundle, needsBrowsingContextGroupSwitch, mainResourceLoadIdentifier, listenerID, userData);
     338    m_page.decidePolicyForResponseShared(m_process.copyRef(), m_webPageID, frameID, WTFMove(frameInfo), identifier, navigationID, response, request, canShowMIMEType, downloadAttribute, wasAllowedByInjectedBundle, browsingContextGroupSwitchDecision, mainResourceLoadIdentifier, listenerID, userData);
    339339}
    340340
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h

    r281706 r281832  
    126126
    127127    void decidePolicyForNavigationActionAsync(WebCore::FrameIdentifier, FrameInfoData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, NavigationActionData&&, FrameInfoData&& originatingFrameInfo, std::optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody, WebCore::ResourceResponse&& redirectResponse, const UserData&, uint64_t listenerID);
    128     void decidePolicyForResponse(WebCore::FrameIdentifier, FrameInfoData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, bool needsBrowsingContextGroupSwitch, uint64_t listenerID, uint64_t mainResourceLoadIdentifier, const UserData&);
     128    void decidePolicyForResponse(WebCore::FrameIdentifier, FrameInfoData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, WebCore::BrowsingContextGroupSwitchDecision, uint64_t listenerID, uint64_t mainResourceLoadIdentifier, const UserData&);
    129129    void didChangeProvisionalURLForFrame(WebCore::FrameIdentifier, uint64_t navigationID, URL&&);
    130130    void didPerformServerRedirect(const String& sourceURLString, const String& destinationURLString, WebCore::FrameIdentifier);
  • trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp

    r278253 r281832  
    5555    for (auto* suspendedPage : allSuspendedPages()) {
    5656        auto& process = suspendedPage->process();
    57         if (&process.processPool() == &processPool && process.registrableDomain() == registrableDomain && &process.websiteDataStore() == &dataStore)
     57        if (&process.processPool() == &processPool && process.registrableDomain() == registrableDomain && &process.websiteDataStore() == &dataStore && process.crossOriginMode() != CrossOriginMode::Isolated)
    5858            return &process;
    5959    }
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r281817 r281832  
    56215621void WebPageProxy::decidePolicyForResponse(FrameIdentifier frameID, FrameInfoData&& frameInfo, PolicyCheckIdentifier identifier,
    56225622    uint64_t navigationID, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, const String& downloadAttribute,
    5623     bool wasAllowedByInjectedBundle, bool needsBrowsingContextGroupSwitch, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData& userData)
    5624 {
    5625     decidePolicyForResponseShared(m_process.copyRef(), m_webPageID, frameID, WTFMove(frameInfo), identifier, navigationID, response, request, canShowMIMEType, downloadAttribute, wasAllowedByInjectedBundle, needsBrowsingContextGroupSwitch, mainResourceLoadIdentifier, listenerID, userData);
    5626 }
    5627 
    5628 void WebPageProxy::decidePolicyForResponseShared(Ref<WebProcessProxy>&& process, PageIdentifier webPageID, FrameIdentifier frameID, FrameInfoData&& frameInfo, PolicyCheckIdentifier identifier, uint64_t navigationID, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, bool needsBrowsingContextGroupSwitch, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData& userData)
     5623    bool wasAllowedByInjectedBundle, BrowsingContextGroupSwitchDecision browsingContextGroupSwitchDecision, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData& userData)
     5624{
     5625    decidePolicyForResponseShared(m_process.copyRef(), m_webPageID, frameID, WTFMove(frameInfo), identifier, navigationID, response, request, canShowMIMEType, downloadAttribute, wasAllowedByInjectedBundle, browsingContextGroupSwitchDecision, mainResourceLoadIdentifier, listenerID, userData);
     5626}
     5627
     5628void WebPageProxy::decidePolicyForResponseShared(Ref<WebProcessProxy>&& process, PageIdentifier webPageID, FrameIdentifier frameID, FrameInfoData&& frameInfo, PolicyCheckIdentifier identifier, uint64_t navigationID, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, BrowsingContextGroupSwitchDecision browsingContextGroupSwitchDecision, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData& userData)
    56295629{
    56305630    PageClientProtector protector(pageClient());
     
    56395639    auto navigationResponse = API::NavigationResponse::create(API::FrameInfo::create(WTFMove(frameInfo), this).get(), request, response, canShowMIMEType, downloadAttribute);
    56405640
    5641     auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), webPageID, frameID, needsBrowsingContextGroupSwitch, mainResourceLoadIdentifier, identifier, listenerID, navigation = WTFMove(navigation),
     5641    auto listener = makeRef(frame->setUpPolicyListenerProxy([this, protectedThis = makeRef(*this), webPageID, frameID, browsingContextGroupSwitchDecision, mainResourceLoadIdentifier, identifier, listenerID, navigation = WTFMove(navigation),
    56425642        process, navigationResponse] (PolicyAction policyAction, API::WebsitePolicies*, ProcessSwapRequestedByClient processSwapRequestedByClient, RefPtr<SafeBrowsingWarning>&& safeBrowsingWarning, std::optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain) mutable {
    56435643        // FIXME: Assert the API::WebsitePolicies* is nullptr here once clients of WKFramePolicyListenerUseWithPolicies go away.
     
    56505650
    56515651        auto willContinueLoadInNewProcess = WillContinueLoadInNewProcess::No;
    5652         if (policyAction == PolicyAction::Use && needsBrowsingContextGroupSwitch && navigation) {
    5653             RegistrableDomain responseDomain { navigationResponse->response().url() };
    5654             // Avoid process-swapping in cases where the process only contains a single page and is origin-clean.
    5655             if (process->pageCount() > 1 || (process->optionalRegistrableDomain() && *process->optionalRegistrableDomain() != responseDomain)) {
    5656                 WEBPAGEPROXY_RELEASE_LOG(ProcessSwapping, "decidePolicyForResponseShared: Process-swapping due to Cross-Origin-Opener-Policy");
    5657                 websiteDataStore().networkProcess().prepareLoadForWebProcessTransfer(process->coreProcessIdentifier(), mainResourceLoadIdentifier, [this, protectedThis = WTFMove(protectedThis), responseDomain = WTFMove(responseDomain), navigation, navigationResponse = WTFMove(navigationResponse), sender = WTFMove(sender)](auto existingNetworkResourceLoadIdentifierToResume) mutable {
    5658                     auto processForNavigation = m_process->processPool().processForRegistrableDomain(websiteDataStore(), this, responseDomain);
    5659                     continueNavigationInNewProcess(*navigation, nullptr, WTFMove(processForNavigation), ProcessSwapRequestedByClient::No, ShouldTreatAsContinuingLoad::YesAfterResponsePolicyDecision, nullptr, existingNetworkResourceLoadIdentifierToResume);
    5660 
    5661                     receivedPolicyDecision(PolicyAction::Ignore, navigation.get(), nullptr, WTFMove(navigationResponse), WTFMove(sender), { }, WillContinueLoadInNewProcess::Yes);
    5662                 });
    5663                 return;
    5664             }
     5652        if (policyAction == PolicyAction::Use && browsingContextGroupSwitchDecision != BrowsingContextGroupSwitchDecision::StayInGroup && navigation) {
     5653            WEBPAGEPROXY_RELEASE_LOG(ProcessSwapping, "decidePolicyForResponseShared: Process-swapping due to Cross-Origin-Opener-Policy, newProcessIsCrossOriginIsolated=%d", browsingContextGroupSwitchDecision == BrowsingContextGroupSwitchDecision::NewIsolatedGroup);
     5654            websiteDataStore().networkProcess().prepareLoadForWebProcessTransfer(process->coreProcessIdentifier(), mainResourceLoadIdentifier, [this, protectedThis = WTFMove(protectedThis), navigation, navigationResponse = WTFMove(navigationResponse), sender = WTFMove(sender), browsingContextGroupSwitchDecision](auto existingNetworkResourceLoadIdentifierToResume) mutable {
     5655                RefPtr<WebProcessProxy> processForNavigation;
     5656                if (browsingContextGroupSwitchDecision == BrowsingContextGroupSwitchDecision::NewIsolatedGroup)
     5657                    processForNavigation = m_process->processPool().createNewWebProcess(&websiteDataStore(), WebProcessProxy::IsPrewarmed::No, CrossOriginMode::Isolated);
     5658                else {
     5659                    ASSERT(browsingContextGroupSwitchDecision == BrowsingContextGroupSwitchDecision::NewSharedGroup);
     5660                    RegistrableDomain responseDomain { navigationResponse->response().url() };
     5661                    processForNavigation = m_process->processPool().processForRegistrableDomain(websiteDataStore(), this, responseDomain);
     5662                }
     5663                continueNavigationInNewProcess(*navigation, nullptr, processForNavigation.releaseNonNull(), ProcessSwapRequestedByClient::No, ShouldTreatAsContinuingLoad::YesAfterResponsePolicyDecision, nullptr, existingNetworkResourceLoadIdentifierToResume);
     5664
     5665                receivedPolicyDecision(PolicyAction::Ignore, navigation.get(), nullptr, WTFMove(navigationResponse), WTFMove(sender), { }, WillContinueLoadInNewProcess::Yes);
     5666            });
     5667            return;
    56655668        }
    56665669       
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r281817 r281832  
    17441744    void didChangeProvisionalURLForFrameShared(Ref<WebProcessProxy>&&, WebCore::FrameIdentifier, uint64_t navigationID, URL&&);
    17451745    void decidePolicyForNavigationActionAsyncShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, WebCore::FrameIdentifier, FrameInfoData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, NavigationActionData&&, FrameInfoData&& originatingFrameInfo, std::optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody, WebCore::ResourceResponse&& redirectResponse, const UserData&, uint64_t listenerID);
    1746     void decidePolicyForResponseShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, WebCore::FrameIdentifier, FrameInfoData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, bool needsBrowsingContextGroupSwitch, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData&);
     1746    void decidePolicyForResponseShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, WebCore::FrameIdentifier, FrameInfoData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, WebCore::BrowsingContextGroupSwitchDecision, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData&);
    17471747    void startURLSchemeTaskShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, URLSchemeTaskParameters&&);
    17481748    void loadDataWithNavigationShared(Ref<WebProcessProxy>&&, WebCore::PageIdentifier, API::Navigation&, const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, WebCore::ShouldTreatAsContinuingLoad, std::optional<NavigatingToAppBoundDomain>, std::optional<WebsitePoliciesData>&&, WebCore::ShouldOpenExternalURLsPolicy, WebCore::SubstituteData::SessionHistoryVisibility);
     
    20652065        WebCore::ResourceRequest&&, const String& frameName, uint64_t listenerID, const UserData&);
    20662066    void decidePolicyForResponse(WebCore::FrameIdentifier, FrameInfoData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID,
    2067         const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, bool needsBrowsingContextGroupSwitch, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData&);
     2067        const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, bool wasAllowedByInjectedBundle, WebCore::BrowsingContextGroupSwitchDecision, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, const UserData&);
    20682068    void unableToImplementPolicy(WebCore::FrameIdentifier, const WebCore::ResourceError&, const UserData&);
    20692069    void beginSafeBrowsingCheck(const URL&, bool, WebFramePolicyListenerProxy&);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r281771 r281832  
    108108
    109109    # Policy messages
    110     DecidePolicyForResponse(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, WebCore::PolicyCheckIdentifier policyCheckIdentifier, uint64_t navigationID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, bool canShowMIMEType, String downloadAttribute, bool wasAllowedByInjectedBundle, bool needsBrowsingContextGroupSwitch, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, WebKit::UserData userData)
     110    DecidePolicyForResponse(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, WebCore::PolicyCheckIdentifier policyCheckIdentifier, uint64_t navigationID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, bool canShowMIMEType, String downloadAttribute, bool wasAllowedByInjectedBundle, enum:uint8_t WebCore::BrowsingContextGroupSwitchDecision browsingContextGroupSwitchDecision, uint64_t mainResourceLoadIdentifier, uint64_t listenerID, WebKit::UserData userData)
    111111    DecidePolicyForNavigationActionAsync(WebCore::FrameIdentifier frameID, struct WebKit::FrameInfoData frameInfo, WebCore::PolicyCheckIdentifier policyCheckIdentifier, uint64_t navigationID, struct WebKit::NavigationActionData navigationActionData, struct WebKit::FrameInfoData originatingFrameInfoData, std::optional<WebKit::WebPageProxyIdentifier> originatingPageID, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, IPC::FormDataReference requestBody, WebCore::ResourceResponse redirectResponse, WebKit::UserData userData, uint64_t listenerID)
    112112    DecidePolicyForNavigationActionSync(WebCore::FrameIdentifier frameID, bool isMainFrame, struct WebKit::FrameInfoData frameInfo, WebCore::PolicyCheckIdentifier policyCheckIdentifier, uint64_t navigationID, struct WebKit::NavigationActionData navigationActionData, struct WebKit::FrameInfoData originatingFrameInfoData, std::optional<WebKit::WebPageProxyIdentifier> originatingPageID, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, IPC::FormDataReference requestBody, WebCore::ResourceResponse redirectResponse, WebKit::UserData userData) -> (struct WebKit::PolicyDecision PolicyDecision) Synchronous
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r281277 r281832  
    597597}
    598598
    599 Ref<WebProcessProxy> WebProcessPool::createNewWebProcess(WebsiteDataStore* websiteDataStore, WebProcessProxy::IsPrewarmed isPrewarmed)
     599Ref<WebProcessProxy> WebProcessPool::createNewWebProcess(WebsiteDataStore* websiteDataStore, WebProcessProxy::IsPrewarmed isPrewarmed, CrossOriginMode crossOriginMode)
    600600{
    601601#if PLATFORM(COCOA)
     
    605605#endif
    606606
    607     auto processProxy = WebProcessProxy::create(*this, websiteDataStore, isPrewarmed);
     607    auto processProxy = WebProcessProxy::create(*this, websiteDataStore, isPrewarmed, crossOriginMode);
    608608    initializeNewWebProcess(processProxy, websiteDataStore, isPrewarmed);
    609609    m_processes.append(processProxy.copyRef());
     
    804804    parameters.attrStyleEnabled = m_configuration->attrStyleEnabled();
    805805    parameters.shouldThrowExceptionForGlobalConstantRedeclaration = m_configuration->shouldThrowExceptionForGlobalConstantRedeclaration();
     806    parameters.crossOriginMode = process.crossOriginMode();
    806807
    807808#if ENABLE(SERVICE_CONTROLS)
     
    10521053        process = dummyProcessProxy(pageConfiguration->websiteDataStore()->sessionID());
    10531054        if (!process) {
    1054             process = WebProcessProxy::create(*this, pageConfiguration->websiteDataStore(), WebProcessProxy::IsPrewarmed::No, WebProcessProxy::ShouldLaunchProcess::No);
     1055            process = WebProcessProxy::create(*this, pageConfiguration->websiteDataStore(), WebProcessProxy::IsPrewarmed::No, CrossOriginMode::Shared, WebProcessProxy::ShouldLaunchProcess::No);
    10551056            m_dummyProcessProxies.add(pageConfiguration->websiteDataStore()->sessionID(), makeWeakPtr(*process));
    10561057            m_processes.append(*process);
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r281070 r281832  
    515515#endif
    516516
     517    Ref<WebProcessProxy> createNewWebProcess(WebsiteDataStore*, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No, WebCore::CrossOriginMode = WebCore::CrossOriginMode::Shared);
     518
    517519private:
    518520    void platformInitialize();
     
    525527    RefPtr<WebProcessProxy> tryTakePrewarmedProcess(WebsiteDataStore&);
    526528
    527     Ref<WebProcessProxy> createNewWebProcess(WebsiteDataStore*, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
    528529    void initializeNewWebProcess(WebProcessProxy&, WebsiteDataStore*, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
    529530
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r281007 r281832  
    148148}
    149149
    150 Ref<WebProcessProxy> WebProcessProxy::create(WebProcessPool& processPool, WebsiteDataStore* websiteDataStore, IsPrewarmed isPrewarmed, ShouldLaunchProcess shouldLaunchProcess)
    151 {
    152     auto proxy = adoptRef(*new WebProcessProxy(processPool, websiteDataStore, isPrewarmed));
     150Ref<WebProcessProxy> WebProcessProxy::create(WebProcessPool& processPool, WebsiteDataStore* websiteDataStore, IsPrewarmed isPrewarmed, CrossOriginMode crossOriginMode, ShouldLaunchProcess shouldLaunchProcess)
     151{
     152    auto proxy = adoptRef(*new WebProcessProxy(processPool, websiteDataStore, isPrewarmed, crossOriginMode));
    153153    if (shouldLaunchProcess == ShouldLaunchProcess::Yes)
    154154        proxy->connect();
     
    159159Ref<WebProcessProxy> WebProcessProxy::createForServiceWorkers(WebProcessPool& processPool, RegistrableDomain&& registrableDomain, WebsiteDataStore& websiteDataStore)
    160160{
    161     auto proxy = adoptRef(*new WebProcessProxy(processPool, &websiteDataStore, IsPrewarmed::No));
     161    auto proxy = adoptRef(*new WebProcessProxy(processPool, &websiteDataStore, IsPrewarmed::No, CrossOriginMode::Shared));
    162162    proxy->m_registrableDomain = WTFMove(registrableDomain);
    163163    proxy->enableServiceWorkers(processPool.userContentControllerIdentifierForServiceWorkers());
     
    195195#endif
    196196
    197 WebProcessProxy::WebProcessProxy(WebProcessPool& processPool, WebsiteDataStore* websiteDataStore, IsPrewarmed isPrewarmed)
     197WebProcessProxy::WebProcessProxy(WebProcessPool& processPool, WebsiteDataStore* websiteDataStore, IsPrewarmed isPrewarmed, CrossOriginMode crossOriginMode)
    198198    : AuxiliaryProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
    199199    , m_backgroundResponsivenessTimer(*this)
     
    212212#endif
    213213    , m_isPrewarmed(isPrewarmed == IsPrewarmed::Yes)
     214    , m_crossOriginMode(crossOriginMode)
    214215    , m_shutdownPreventingScopeCounter([this](RefCounterEvent event) { if (event == RefCounterEvent::Decrement) maybeShutDown(); })
    215216{
     
    11441145    if (isRunningServiceWorkers()) {
    11451146        WEBPROCESSPROXY_RELEASE_LOG(Process, "canBeAddedToWebProcessCache: Not adding to process cache because the process is running workers");
     1147        return false;
     1148    }
     1149
     1150    if (m_crossOriginMode == CrossOriginMode::Isolated) {
     1151        WEBPROCESSPROXY_RELEASE_LOG(Process, "canBeAddedToWebProcessCache: Not adding to process cache because the process is cross-origin isolated");
    11461152        return false;
    11471153    }
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r281516 r281832  
    4545#include "WebPageProxyIdentifier.h"
    4646#include "WebProcessProxyMessagesReplies.h"
     47#include <WebCore/CrossOriginMode.h>
    4748#include <WebCore/FrameIdentifier.h>
    4849#include <WebCore/MediaProducer.h>
     
    136137    enum class ShouldLaunchProcess : bool { No, Yes };
    137138
    138     static Ref<WebProcessProxy> create(WebProcessPool&, WebsiteDataStore*, IsPrewarmed, ShouldLaunchProcess = ShouldLaunchProcess::Yes);
     139    static Ref<WebProcessProxy> create(WebProcessPool&, WebsiteDataStore*, IsPrewarmed, WebCore::CrossOriginMode = WebCore::CrossOriginMode::Shared, ShouldLaunchProcess = ShouldLaunchProcess::Yes);
    139140    static Ref<WebProcessProxy> createForServiceWorkers(WebProcessPool&, WebCore::RegistrableDomain&&, WebsiteDataStore&);
    140141
     
    420421#endif
    421422
     423    WebCore::CrossOriginMode crossOriginMode() const { return m_crossOriginMode; }
     424
    422425protected:
    423     WebProcessProxy(WebProcessPool&, WebsiteDataStore*, IsPrewarmed);
     426    WebProcessProxy(WebProcessPool&, WebsiteDataStore*, IsPrewarmed, WebCore::CrossOriginMode);
    424427
    425428    // AuxiliaryProcessProxy
     
    441444    bool shouldConfigureJSCForTesting() const final;
    442445    bool isJITEnabled() const final;
     446    bool shouldEnableSharedArrayBuffer() const final { return m_crossOriginMode == WebCore::CrossOriginMode::Isolated; }
    443447
    444448    void validateFreezerStatus();
     
    621625    bool m_hasCommittedAnyProvisionalLoads { false };
    622626    bool m_isPrewarmed;
     627    WebCore::CrossOriginMode m_crossOriginMode { WebCore::CrossOriginMode::Shared };
    623628#if ENABLE(ATTACHMENT_ELEMENT)
    624629    bool m_hasIssuedAttachmentElementRelatedSandboxExtensions { false };
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r281706 r281832  
    818818}
    819819
    820 void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceResponse& response, const ResourceRequest& request, WebCore::PolicyCheckIdentifier identifier, const String& downloadAttribute, bool needsBrowsingContextGroupSwitch, FramePolicyFunction&& function)
     820void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceResponse& response, const ResourceRequest& request, WebCore::PolicyCheckIdentifier identifier, const String& downloadAttribute, BrowsingContextGroupSwitchDecision browsingContextGroupSwitchDecision, FramePolicyFunction&& function)
    821821{
    822822    auto* webPage = m_frame->page();
     
    839839    // If a browsing context switch is requested, we still need to send the IPC to the UIProcess in order to process-swap if necessary, even though the
    840840    // injected bundle has already handled the policy decision.
    841     if (policy == WKBundlePagePolicyActionUse && !needsBrowsingContextGroupSwitch) {
     841    if (policy == WKBundlePagePolicyActionUse && browsingContextGroupSwitchDecision == BrowsingContextGroupSwitchDecision::StayInGroup) {
    842842        WEBFRAMELOADERCLIENT_RELEASE_LOG(Network, "dispatchDecidePolicyForResponse: continuing because injected bundle says so");
    843843        function(PolicyAction::Use, identifier);
     
    856856    auto protector = m_frame.copyRef();
    857857    uint64_t listenerID = m_frame->setUpPolicyListener(identifier, WTFMove(function), WebFrame::ForNavigationAction::No);
    858     if (!webPage->send(Messages::WebPageProxy::DecidePolicyForResponse(m_frame->frameID(), m_frame->info(), identifier, navigationID, response, request, canShowResponse, downloadAttribute, wasAllowedByInjectedBundle, needsBrowsingContextGroupSwitch, mainResourceLoadIdentifier, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())))) {
     858    if (!webPage->send(Messages::WebPageProxy::DecidePolicyForResponse(m_frame->frameID(), m_frame->info(), identifier, navigationID, response, request, canShowResponse, downloadAttribute, wasAllowedByInjectedBundle, browsingContextGroupSwitchDecision, mainResourceLoadIdentifier, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())))) {
    859859        WEBFRAMELOADERCLIENT_RELEASE_LOG(Network, "dispatchDecidePolicyForResponse: ignoring because WebPageProxy::DecidePolicyForResponse failed");
    860860        m_frame->didReceivePolicyDecision(listenerID, PolicyDecision { identifier, std::nullopt, PolicyAction::Ignore, 0, { }, { } });
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h

    r281516 r281832  
    130130    void dispatchShow() final;
    131131   
    132     void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebCore::PolicyCheckIdentifier, const String&, bool needsBrowsingContextGroupSwitch, WebCore::FramePolicyFunction&&) final;
     132    void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebCore::PolicyCheckIdentifier, const String&, WebCore::BrowsingContextGroupSwitchDecision, WebCore::FramePolicyFunction&&) final;
    133133    void dispatchDecidePolicyForNewWindowAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, WebCore::FormState*, const String& frameName, WebCore::PolicyCheckIdentifier, WebCore::FramePolicyFunction&&) final;
    134134    void dispatchDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse, WebCore::FormState*, WebCore::PolicyDecisionMode, WebCore::PolicyCheckIdentifier, WebCore::FramePolicyFunction&&) final;
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r281398 r281832  
    130130#include <WebCore/RuntimeApplicationChecks.h>
    131131#include <WebCore/RuntimeEnabledFeatures.h>
     132#include <WebCore/ScriptExecutionContext.h>
    132133#include <WebCore/SecurityOrigin.h>
    133134#include <WebCore/ServiceWorkerContextData.h>
     
    524525    commonVM().setGlobalConstRedeclarationShouldThrow(parameters.shouldThrowExceptionForGlobalConstantRedeclaration);
    525526
     527    ScriptExecutionContext::setCrossOriginMode(parameters.crossOriginMode);
     528
    526529#if ENABLE(SERVICE_CONTROLS)
    527530    setEnabledServices(parameters.hasImageServices, parameters.hasSelectionServices, parameters.hasRichContentServices);
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r281818 r281832  
     12021-08-31  Chris Dumez  <cdumez@apple.com>
     2
     3        Enable SharedArrayBuffer support when COOP/COEP headers are used
     4        https://bugs.webkit.org/show_bug.cgi?id=229559
     5        <rdar://problem/82391945>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * WebCoreSupport/WebFrameLoaderClient.h:
     10        * WebCoreSupport/WebFrameLoaderClient.mm:
     11        (WebFrameLoaderClient::dispatchDecidePolicyForResponse):
     12
    1132021-08-31  Sihui Liu  <sihui_liu@apple.com>
    214
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h

    r281516 r281832  
    128128    void dispatchShow() final;
    129129
    130     void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebCore::PolicyCheckIdentifier, const String&, bool needsBrowsingContextGroupSwitch, WebCore::FramePolicyFunction&&) final;
     130    void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebCore::PolicyCheckIdentifier, const String&, WebCore::BrowsingContextGroupSwitchDecision, WebCore::FramePolicyFunction&&) final;
    131131    void dispatchDecidePolicyForNewWindowAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, WebCore::FormState*, const WTF::String& frameName, WebCore::PolicyCheckIdentifier, WebCore::FramePolicyFunction&&) final;
    132132    void dispatchDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse, WebCore::FormState*, WebCore::PolicyDecisionMode, WebCore::PolicyCheckIdentifier, WebCore::FramePolicyFunction&&) final;
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r281516 r281832  
    856856}
    857857
    858 void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const WebCore::ResourceResponse& response, const WebCore::ResourceRequest& request, WebCore::PolicyCheckIdentifier identifier, const String&, bool needsBrowsingContextGroupSwitch, WebCore::FramePolicyFunction&& function)
     858void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const WebCore::ResourceResponse& response, const WebCore::ResourceRequest& request, WebCore::PolicyCheckIdentifier identifier, const String&, WebCore::BrowsingContextGroupSwitchDecision, WebCore::FramePolicyFunction&& function)
    859859{
    860860    WebView *webView = getWebView(m_webFrame.get());
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r281818 r281832  
     12021-08-31  Chris Dumez  <cdumez@apple.com>
     2
     3        Enable SharedArrayBuffer support when COOP/COEP headers are used
     4        https://bugs.webkit.org/show_bug.cgi?id=229559
     5        <rdar://problem/82391945>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * WebCoreSupport/WebFrameLoaderClient.cpp:
     10        (WebFrameLoaderClient::dispatchDecidePolicyForResponse):
     11        * WebCoreSupport/WebFrameLoaderClient.h:
     12
    1132021-08-31  Sihui Liu  <sihui_liu@apple.com>
    214
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp

    r281516 r281832  
    520520}
    521521
    522 void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceResponse& response, const ResourceRequest& request, WebCore::PolicyCheckIdentifier identifier, const String&, bool needsBrowsingContextGroupSwitch, FramePolicyFunction&& function)
     522void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceResponse& response, const ResourceRequest& request, WebCore::PolicyCheckIdentifier identifier, const String&, BrowsingContextGroupSwitchDecision, FramePolicyFunction&& function)
    523523{
    524524    WebView* webView = m_webFrame->webView();
  • trunk/Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h

    r281516 r281832  
    9292    void dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone>) override;
    9393
    94     void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebCore::PolicyCheckIdentifier, const String&, bool needsBrowsingContextGroupSwitch, WebCore::FramePolicyFunction&&) override;
     94    void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebCore::PolicyCheckIdentifier, const String&, WebCore::BrowsingContextGroupSwitchDecision, WebCore::FramePolicyFunction&&) override;
    9595    void dispatchDecidePolicyForNewWindowAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, WebCore::FormState*, const WTF::String& frameName, WebCore::PolicyCheckIdentifier, WebCore::FramePolicyFunction&&) override;
    9696    void dispatchDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse, WebCore::FormState*, WebCore::PolicyDecisionMode, WebCore::PolicyCheckIdentifier, WebCore::FramePolicyFunction&&) override;
  • trunk/Tools/ChangeLog

    r281831 r281832  
     12021-08-31  Chris Dumez  <cdumez@apple.com>
     2
     3        Enable SharedArrayBuffer support when COOP/COEP headers are used
     4        https://bugs.webkit.org/show_bug.cgi?id=229559
     5        <rdar://problem/82391945>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Add API test coverage. SharedArrayBuffer support is currently forcefully enabled by
     10        run-webkit-tests.py so it would not be practical to write layout tests for this at
     11        the moment.
     12
     13        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     14        (-[PSONScheme addMappingFromURLString:toData:withCOOPValue:withCOEPValue:]):
     15        (-[PSONScheme webView:startURLSchemeTask:]):
     16
    1172021-08-31  Kate Cheney  <katherine_cheney@apple.com>
    218
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r281709 r281832  
    252252    HashMap<String, RetainPtr<NSData>> _dataMappings;
    253253    HashMap<String, String> _coopValues;
     254    HashMap<String, String> _coepValues;
    254255    HashSet<id <WKURLSchemeTask>> _runningTasks;
    255256    bool _shouldRespondAsynchronously;
     
    258259- (void)addRedirectFromURLString:(NSString *)sourceURLString toURLString:(NSString *)destinationURLString;
    259260- (void)addMappingFromURLString:(NSString *)urlString toData:(const char*)data;
    260 - (void)addMappingFromURLString:(NSString *)urlString toData:(const char*)data withCOOPValue:(const char*)coopValue;
     261- (void)addMappingFromURLString:(NSString *)urlString toData:(const char*)data withCOOPValue:(const char*)coopValue withCOEPValue:(const char*)coepValue;
    261262@end
    262263
     
    280281}
    281282
    282 - (void)addMappingFromURLString:(NSString *)urlString toData:(const char*)data withCOOPValue:(const char*)coopValue
     283- (void)addMappingFromURLString:(NSString *)urlString toData:(const char*)data withCOOPValue:(const char*)coopValue withCOEPValue:(const char*)coepValue
    283284{
    284285    [self addMappingFromURLString:urlString toData:data];
    285286    if (coopValue)
    286287        _coopValues.add(urlString, coopValue);
     288    if (coepValue)
     289        _coepValues.add(urlString, coepValue);
    287290}
    288291
     
    328331        if (!coopValue.isEmpty())
    329332            [headerDictionary setObject:(NSString *)coopValue forKey:@"Cross-Origin-Opener-Policy"];
     333        auto coepValue = _coepValues.get([finalURL absoluteString]);
     334        if (!coepValue.isEmpty())
     335            [headerDictionary setObject:(NSString *)coepValue forKey:@"Cross-Origin-Embedder-Policy"];
    330336
    331337        auto response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:finalURL.get() statusCode:200 HTTPVersion:@"HTTP/1.1" headerFields:headerDictionary]);
     
    71927198enum class IsSameOrigin : bool { No, Yes };
    71937199enum class DoServerSideRedirect : bool { No, Yes };
    7194 static void runCOOPProcessSwapTest(const char* sourceCOOP, const char* destinationCOOP, IsSameOrigin isSameOrigin, DoServerSideRedirect doServerSideRedirect, ExpectSwap expectSwap)
    7195 {
    7196     auto processPoolConfiguration = psonProcessPoolConfiguration();
    7197     auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     7200static void runCOOPProcessSwapTest(const char* sourceCOOP, const char* sourceCOEP, const char* destinationCOOP, const char* destinationCOEP, IsSameOrigin isSameOrigin, DoServerSideRedirect doServerSideRedirect, ExpectSwap expectSwap)
     7201{
     7202    auto processPoolConfiguration = psonProcessPoolConfiguration();
     7203    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     7204    bool sourceShouldBeCrossOriginIsolated = sourceCOOP && !strcmp(sourceCOOP, "same-origin") && sourceCOEP && !strcmp(sourceCOEP, "require-corp");
     7205    bool destinationShouldBeCrossOriginIsolated = destinationCOOP && !strcmp(destinationCOOP, "same-origin") && destinationCOEP && !strcmp(destinationCOEP, "require-corp");
     7206    EXPECT_TRUE(sourceShouldBeCrossOriginIsolated == destinationShouldBeCrossOriginIsolated || expectSwap == ExpectSwap::Yes);
    71987207
    71997208    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     
    72017210    [webViewConfiguration preferences].javaScriptCanOpenWindowsAutomatically = YES;
    72027211    for (_WKExperimentalFeature *feature in [WKPreferences _experimentalFeatures]) {
    7203         if ([feature.key isEqualToString:@"CrossOriginOpenerPolicyEnabled"]) {
     7212        if ([feature.key isEqualToString:@"CrossOriginOpenerPolicyEnabled"])
    72047213            [[webViewConfiguration preferences] _setEnabled:YES forExperimentalFeature:feature];
    7205             break;
    7206         }
     7214        else if ([feature.key isEqualToString:@"CrossOriginEmbedderPolicyEnabled"])
     7215            [[webViewConfiguration preferences] _setEnabled:YES forExperimentalFeature:feature];
    72077216    }
    72087217
    72097218    auto handler = adoptNS([[PSONScheme alloc] init]);
    72107219    if (isSameOrigin == IsSameOrigin::Yes) {
    7211         [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:windowOpenSameOriginCOOPTestBytes withCOOPValue:sourceCOOP];
     7220        [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:windowOpenSameOriginCOOPTestBytes withCOOPValue:sourceCOOP withCOEPValue:sourceCOEP];
    72127221        if (doServerSideRedirect == DoServerSideRedirect::Yes) {
    72137222            [handler addRedirectFromURLString:@"pson://www.webkit.org/popup.html" toURLString:@"pson://www.webkit.org/popup-after-redirect.html"];
    7214             [handler addMappingFromURLString:@"pson://www.webkit.org/popup-after-redirect.html" toData:"popup" withCOOPValue:destinationCOOP];
     7223            [handler addMappingFromURLString:@"pson://www.webkit.org/popup-after-redirect.html" toData:"popup" withCOOPValue:destinationCOOP withCOEPValue:destinationCOEP];
    72157224        } else
    7216             [handler addMappingFromURLString:@"pson://www.webkit.org/popup.html" toData:"popup" withCOOPValue:destinationCOOP];
     7225            [handler addMappingFromURLString:@"pson://www.webkit.org/popup.html" toData:"popup" withCOOPValue:destinationCOOP withCOEPValue:destinationCOEP];
    72177226    } else {
    7218         [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:windowOpenCrossOriginCOOPTestBytes withCOOPValue:sourceCOOP];
     7227        [handler addMappingFromURLString:@"pson://www.webkit.org/main.html" toData:windowOpenCrossOriginCOOPTestBytes withCOOPValue:sourceCOOP withCOEPValue:sourceCOEP];
    72197228        if (doServerSideRedirect == DoServerSideRedirect::Yes) {
    72207229            [handler addRedirectFromURLString:@"pson://www.apple.com/popup.html" toURLString:@"pson://www.apple.com/popup-after-redirect.html"];
    7221             [handler addMappingFromURLString:@"pson://www.apple.com/popup-after-redirect.html" toData:"popup" withCOOPValue:destinationCOOP];
     7230            [handler addMappingFromURLString:@"pson://www.apple.com/popup-after-redirect.html" toData:"popup" withCOOPValue:destinationCOOP withCOEPValue:destinationCOEP];
    72227231        } else
    7223             [handler addMappingFromURLString:@"pson://www.apple.com/popup.html" toData:"popup" withCOOPValue:destinationCOOP];
     7232            [handler addMappingFromURLString:@"pson://www.apple.com/popup.html" toData:"popup" withCOOPValue:destinationCOOP withCOEPValue:destinationCOEP];
    72247233    }
    72257234    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
     
    72887297        else
    72897298            EXPECT_WK_STREQ(@"", windowName);
     7299        finishedRunningScript = true;
     7300    }];
     7301    TestWebKitAPI::Util::run(&finishedRunningScript);
     7302    finishedRunningScript = false;
     7303    [webView evaluateJavaScript:@"self.crossOriginIsolated ? 'isolated' : 'not-isolated'" completionHandler: [&] (id result, NSError *error) {
     7304        NSString *crossOriginIsolated = (NSString *)result;
     7305        if (sourceShouldBeCrossOriginIsolated)
     7306            EXPECT_WK_STREQ(@"isolated", crossOriginIsolated);
     7307        else
     7308            EXPECT_WK_STREQ(@"not-isolated", crossOriginIsolated);
     7309        finishedRunningScript = true;
     7310    }];
     7311    TestWebKitAPI::Util::run(&finishedRunningScript);
     7312    finishedRunningScript = false;
     7313    [webView evaluateJavaScript:@"self.SharedArrayBuffer ? 'has-sab' : 'does-not-have-sab'" completionHandler: [&] (id result, NSError *error) {
     7314        NSString *hasSAB = (NSString *)result;
     7315        if (sourceShouldBeCrossOriginIsolated)
     7316            EXPECT_WK_STREQ(@"has-sab", hasSAB);
     7317        else
     7318            EXPECT_WK_STREQ(@"does-not-have-sab", hasSAB);
    72907319        finishedRunningScript = true;
    72917320    }];
     
    73217350    }];
    73227351    TestWebKitAPI::Util::run(&finishedRunningScript);
     7352    finishedRunningScript = false;
     7353    [createdWebView evaluateJavaScript:@"self.crossOriginIsolated ? 'isolated' : 'not-isolated'" completionHandler: [&] (id result, NSError *error) {
     7354        NSString *crossOriginIsolated = (NSString *)result;
     7355        if (destinationShouldBeCrossOriginIsolated)
     7356            EXPECT_WK_STREQ(@"isolated", crossOriginIsolated);
     7357        else
     7358            EXPECT_WK_STREQ(@"not-isolated", crossOriginIsolated);
     7359        finishedRunningScript = true;
     7360    }];
     7361    TestWebKitAPI::Util::run(&finishedRunningScript);
     7362    finishedRunningScript = false;
     7363    [createdWebView evaluateJavaScript:@"self.SharedArrayBuffer ? 'has-sab' : 'does-not-have-sab'" completionHandler: [&] (id result, NSError *error) {
     7364        NSString *hasSAB = (NSString *)result;
     7365        if (destinationShouldBeCrossOriginIsolated)
     7366            EXPECT_WK_STREQ(@"has-sab", hasSAB);
     7367        else
     7368            EXPECT_WK_STREQ(@"does-not-have-sab", hasSAB);
     7369        finishedRunningScript = true;
     7370    }];
     7371    TestWebKitAPI::Util::run(&finishedRunningScript);
    73237372
    73247373    createdWebView = nullptr;
     
    73277376TEST(ProcessSwap, NavigatingSameOriginToCOOPSameOrigin)
    73287377{
    7329     runCOOPProcessSwapTest(nullptr, "same-origin", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7378    runCOOPProcessSwapTest(nullptr, nullptr, "same-origin", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
    73307379}
    73317380
    73327381TEST(ProcessSwap, NavigatingSameOriginToCOOPSameOrigin2)
    73337382{
    7334     runCOOPProcessSwapTest("unsafe-none", "same-origin", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7383    runCOOPProcessSwapTest("unsafe-none", nullptr, "same-origin", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7384}
     7385
     7386TEST(ProcessSwap, NavigatingSameOriginToCOOPSameOrigin3)
     7387{
     7388    runCOOPProcessSwapTest("unsafe-none", nullptr, "same-origin", "unsafe-none", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7389}
     7390
     7391TEST(ProcessSwap, NavigatingSameOriginToCOOPSameOrigin4)
     7392{
     7393    runCOOPProcessSwapTest("unsafe-none", "unsafe-none", "same-origin", "unsafe-none", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7394}
     7395
     7396TEST(ProcessSwap, NavigatingSameOriginToCOOPAndCOEPSameOrigin)
     7397{
     7398    runCOOPProcessSwapTest(nullptr, nullptr, "same-origin", "require-corp", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
    73357399}
    73367400
    73377401TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOrigin)
    73387402{
    7339     runCOOPProcessSwapTest("same-origin", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7403    runCOOPProcessSwapTest("same-origin", nullptr, nullptr, nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
    73407404}
    73417405
    73427406TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOrigin2)
    73437407{
    7344     runCOOPProcessSwapTest("same-origin", "unsafe-none", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7408    runCOOPProcessSwapTest("same-origin", nullptr, "unsafe-none", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7409}
     7410
     7411TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOrigin3)
     7412{
     7413    runCOOPProcessSwapTest("same-origin", "unsafe-none", "unsafe-none", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7414}
     7415
     7416TEST(ProcessSwap, NavigatingSameOriginFromCOOPAndCOEPSameOrigin)
     7417{
     7418    runCOOPProcessSwapTest("same-origin", "require-corp", nullptr, nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
    73457419}
    73467420
    73477421TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOriginAllowPopup)
    73487422{
    7349     runCOOPProcessSwapTest("same-origin-allow-popup", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7423    runCOOPProcessSwapTest("same-origin-allow-popup", nullptr, nullptr, nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
    73507424}
    73517425
    73527426TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOriginAllowPopup2)
    73537427{
    7354     runCOOPProcessSwapTest("same-origin-allow-popup", "unsafe-none", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7428    runCOOPProcessSwapTest("same-origin-allow-popup", nullptr, "unsafe-none", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7429}
     7430
     7431TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOriginAllowPopup3)
     7432{
     7433    runCOOPProcessSwapTest("same-origin-allow-popup", "unsafe-none", "unsafe-none", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7434}
     7435
     7436TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOriginAllowPopup4)
     7437{
     7438    runCOOPProcessSwapTest("same-origin-allow-popup", "unsafe-none", "unsafe-none", "unsafe-none", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7439}
     7440
     7441TEST(ProcessSwap, NavigatingSameOriginFromCOOPAndCOEPSameOriginAllowPopup)
     7442{
     7443    runCOOPProcessSwapTest("same-origin-allow-popup", "require-corp", nullptr, nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
    73557444}
    73567445
    73577446TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOriginToCOOPSameOrigin)
    73587447{
    7359     runCOOPProcessSwapTest("same-origin", "same-origin", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7448    runCOOPProcessSwapTest("same-origin", nullptr, "same-origin", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7449}
     7450
     7451TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOriginToCOOPSameOrigin2)
     7452{
     7453    runCOOPProcessSwapTest("same-origin", "unsafe-none", "same-origin", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7454}
     7455
     7456TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOriginToCOOPSameOrigin3)
     7457{
     7458    runCOOPProcessSwapTest("same-origin", "unsafe-none", "same-origin", "unsafe-none", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7459}
     7460
     7461TEST(ProcessSwap, NavigatingSameOriginFromCOOPAndCOEPSameOriginToCOOPAndCOEPSameOrigin)
     7462{
     7463    runCOOPProcessSwapTest("same-origin", "require-corp", "same-origin", "require-corp", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::No);
     7464}
     7465
     7466TEST(ProcessSwap, NavigatingSameOriginFromCOOPAndCOEPSameOriginToCOOPSameOrigin)
     7467{
     7468    // Should swap because the destination is missing COEP.
     7469    runCOOPProcessSwapTest("same-origin", "require-corp", "same-origin", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
     7470}
     7471
     7472TEST(ProcessSwap, NavigatingSameOriginFromCOOPSameOriginToCOOPAndCOEPSameOrigin)
     7473{
     7474    // Should swap because the source is missing COEP.
     7475    runCOOPProcessSwapTest("same-origin", nullptr, "same-origin", "require-corp", IsSameOrigin::Yes, DoServerSideRedirect::No, ExpectSwap::Yes);
    73607476}
    73617477
     
    73637479{
    73647480    // We expect a swap because the redirect doesn't have COOP=same-origin.
    7365     runCOOPProcessSwapTest("same-origin", "same-origin", IsSameOrigin::Yes, DoServerSideRedirect::Yes, ExpectSwap::Yes);
     7481    runCOOPProcessSwapTest("same-origin", nullptr, "same-origin", nullptr, IsSameOrigin::Yes, DoServerSideRedirect::Yes, ExpectSwap::Yes);
     7482}
     7483
     7484TEST(ProcessSwap, NavigatingSameOriginFromCOOPAndCOEPSameOriginToCOOPAndCOEPSameOriginWithRedirect)
     7485{
     7486    // We expect a swap because the redirect doesn't have COOP=same-origin and COEP=require-corp.
     7487    runCOOPProcessSwapTest("same-origin", "require-corp", "same-origin", "require-corp", IsSameOrigin::Yes, DoServerSideRedirect::Yes, ExpectSwap::Yes);
    73667488}
    73677489
    73687490TEST(ProcessSwap, NavigatingSameOriginWithoutCOOPWithRedirect)
    73697491{
    7370     runCOOPProcessSwapTest(nullptr, nullptr, IsSameOrigin::Yes, DoServerSideRedirect::Yes, ExpectSwap::No);
     7492    runCOOPProcessSwapTest(nullptr, nullptr, nullptr, nullptr, IsSameOrigin::Yes, DoServerSideRedirect::Yes, ExpectSwap::No);
    73717493}
    73727494
    73737495TEST(ProcessSwap, NavigatingCrossOriginToCOOPSameOrigin)
    73747496{
    7375     runCOOPProcessSwapTest(nullptr, "same-origin", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7497    runCOOPProcessSwapTest(nullptr, nullptr, "same-origin", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
    73767498}
    73777499
    73787500TEST(ProcessSwap, NavigatingCrossOriginToCOOPSameOrigin2)
    73797501{
    7380     runCOOPProcessSwapTest("unsafe-none", "same-origin", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7502    runCOOPProcessSwapTest("unsafe-none", nullptr, "same-origin", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7503}
     7504
     7505TEST(ProcessSwap, NavigatingCrossOriginToCOOPSameOrigin3)
     7506{
     7507    runCOOPProcessSwapTest("unsafe-none", nullptr, "same-origin", "unsafe-none", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7508}
     7509
     7510TEST(ProcessSwap, NavigatingCrossOriginToCOOPSameOrigin4)
     7511{
     7512    runCOOPProcessSwapTest("unsafe-none", "unsafe-none", "same-origin", "unsafe-none", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7513}
     7514
     7515TEST(ProcessSwap, NavigatingCrossOriginToCOOPAndCOEPSameOrigin)
     7516{
     7517    runCOOPProcessSwapTest(nullptr, nullptr, "same-origin", "require-corp", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
    73817518}
    73827519
    73837520TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOrigin)
    73847521{
    7385     runCOOPProcessSwapTest("same-origin", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7522    runCOOPProcessSwapTest("same-origin", nullptr, nullptr, nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
    73867523}
    73877524
    73887525TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOrigin2)
    73897526{
    7390     runCOOPProcessSwapTest("same-origin", "unsafe-none", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7527    runCOOPProcessSwapTest("same-origin", nullptr, "unsafe-none", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7528}
     7529
     7530TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOrigin3)
     7531{
     7532    runCOOPProcessSwapTest("same-origin", "unsafe-none", "unsafe-none", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7533}
     7534
     7535TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOrigin4)
     7536{
     7537    runCOOPProcessSwapTest("same-origin", "unsafe-none", "unsafe-none", "unsafe-none", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7538}
     7539
     7540TEST(ProcessSwap, NavigatingCrossOriginFromCOOPAndCOEPSameOrigin)
     7541{
     7542    runCOOPProcessSwapTest("same-origin", "require-corp", nullptr, nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
    73917543}
    73927544
    73937545TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOriginToCOOPSameOrigin)
    73947546{
    7395     runCOOPProcessSwapTest("same-origin", "same-origin", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7547    runCOOPProcessSwapTest("same-origin", nullptr, "same-origin", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7548}
     7549
     7550TEST(ProcessSwap, NavigatingCrossOriginFromCOOPAndCOEPSameOriginToCOOPAndCOEPSameOrigin)
     7551{
     7552    runCOOPProcessSwapTest("same-origin", "require-corp", "same-origin", "require-corp", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7553}
     7554
     7555TEST(ProcessSwap, NavigatingCrossOriginFromCOOPAndCOEPSameOriginToCOOPSameOrigin)
     7556{
     7557    runCOOPProcessSwapTest("same-origin", "require-corp", "same-origin", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
     7558}
     7559
     7560TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOriginToCOOPAndCOEPSameOrigin)
     7561{
     7562    runCOOPProcessSwapTest("same-origin", nullptr, "same-origin", "require-corp", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::Yes);
    73967563}
    73977564
    73987565TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOriginAllowPopup)
    73997566{
    7400     runCOOPProcessSwapTest("same-origin-allow-popup", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::No);
     7567    runCOOPProcessSwapTest("same-origin-allow-popup", nullptr, nullptr, nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::No);
    74017568}
    74027569
    74037570TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOriginAllowPopup2)
    74047571{
    7405     runCOOPProcessSwapTest("same-origin-allow-popup", "unsafe-none", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::No);
    7406 }
     7572    runCOOPProcessSwapTest("same-origin-allow-popup", nullptr, "unsafe-none", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::No);
     7573}
     7574
     7575TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOriginAllowPopup3)
     7576{
     7577    runCOOPProcessSwapTest("same-origin-allow-popup", "unsafe-none", "unsafe-none", nullptr, IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::No);
     7578}
     7579
     7580TEST(ProcessSwap, NavigatingCrossOriginFromCOOPSameOriginAllowPopup4)
     7581{
     7582    runCOOPProcessSwapTest("same-origin-allow-popup", "unsafe-none", "unsafe-none", "unsafe-none", IsSameOrigin::No, DoServerSideRedirect::No, ExpectSwap::No);
     7583}
Note: See TracChangeset for help on using the changeset viewer.