Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
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: - https://w3c.github.io/webappsec-permissions-policy/ * 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:]): Canonical link: https://commits.webkit.org/241165@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
551 additions
and 108 deletions.
- +23 −0 LayoutTests/imported/w3c/ChangeLog
- +3 −1 ...s/imported/w3c/web-platform-tests/IndexedDB/serialize-sharedarraybuffer-throws.https-expected.txt
- +20 −20 ...tform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https-expected.txt
- +1 −1 LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-opener-policy/coep.https-expected.txt
- +3 −0 ...1/imported/w3c/web-platform-tests/IndexedDB/serialize-sharedarraybuffer-throws.https-expected.txt
- +29 −0 Source/WebCore/ChangeLog
- +1 −0 Source/WebCore/Headers.cmake
- +4 −0 Source/WebCore/WebCore.xcodeproj/project.pbxproj
- +34 −0 Source/WebCore/dom/CrossOriginMode.h
- +12 −0 Source/WebCore/dom/ScriptExecutionContext.cpp
- +4 −0 Source/WebCore/dom/ScriptExecutionContext.h
- +11 −2 Source/WebCore/loader/DocumentLoader.cpp
- +1 −1 Source/WebCore/loader/EmptyClients.cpp
- +1 −1 Source/WebCore/loader/EmptyFrameLoaderClient.h
- +2 −2 Source/WebCore/loader/FrameLoader.cpp
- +1 −1 Source/WebCore/loader/FrameLoader.h
- +1 −1 Source/WebCore/loader/FrameLoaderClient.h
- +15 −0 Source/WebCore/loader/FrameLoaderTypes.h
- +2 −3 Source/WebCore/page/DOMWindow.cpp
- +0 −2 Source/WebCore/page/DOMWindow.idl
- +1 −3 Source/WebCore/workers/WorkerGlobalScope.cpp
- +62 −0 Source/WebKit/ChangeLog
- +1 −0 Source/WebKit/Scripts/webkit/messages.py
- +5 −0 Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h
- +3 −0 Source/WebKit/Shared/WebProcessCreationParameters.cpp
- +2 −0 Source/WebKit/Shared/WebProcessCreationParameters.h
- +1 −0 Source/WebKit/UIProcess/Launcher/ProcessLauncher.h
- +2 −0 Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm
- +2 −2 Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
- +1 −1 Source/WebKit/UIProcess/ProvisionalPageProxy.h
- +1 −1 Source/WebKit/UIProcess/SuspendedPageProxy.cpp
- +20 −17 Source/WebKit/UIProcess/WebPageProxy.cpp
- +2 −2 Source/WebKit/UIProcess/WebPageProxy.h
- +1 −1 Source/WebKit/UIProcess/WebPageProxy.messages.in
- +4 −3 Source/WebKit/UIProcess/WebProcessPool.cpp
- +2 −1 Source/WebKit/UIProcess/WebProcessPool.h
- +10 −4 Source/WebKit/UIProcess/WebProcessProxy.cpp
- +7 −2 Source/WebKit/UIProcess/WebProcessProxy.h
- +3 −3 Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
- +1 −1 Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
- +3 −0 Source/WebKit/WebProcess/WebProcess.cpp
- +12 −0 Source/WebKitLegacy/mac/ChangeLog
- +1 −1 Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
- +1 −1 Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
- +12 −0 Source/WebKitLegacy/win/ChangeLog
- +1 −1 Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp
- +1 −1 Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h
- +16 −0 Tools/ChangeLog
- +205 −28 Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,3 +1,5 @@ | ||
|
||
FAIL IndexedDB: Attempting to serialize a SharedArrayBuffer should throw assert_throws_dom: function "() => { | ||
rq = objStore.put({sab: sab}, 'key'); | ||
}" 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,3 @@ | ||
|
||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (C) 2021 Apple Inc. All Rights Reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace WebCore { | ||
|
||
// Cross-Origin isolation via COOP+COEP headers. | ||
enum class CrossOriginMode : bool { Shared, Isolated }; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.