Diff
Modified: trunk/Source/WTF/ChangeLog (286639 => 286640)
--- trunk/Source/WTF/ChangeLog 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WTF/ChangeLog 2021-12-08 04:24:38 UTC (rev 286640)
@@ -1,3 +1,17 @@
+2021-12-07 Wenson Hsieh <[email protected]>
+
+ Add support for `navigator.requestCookieConsent()` behind a disabled feature flag
+ https://bugs.webkit.org/show_bug.cgi?id=233890
+ rdar://86117718
+
+ Reviewed by Darin Adler.
+
+ Add the new feature flag (off by default). Note that this is also only an internal feature flag for the time
+ being (rather than an experimental feature flag), such that it cannot (yet) be turned on by non-Apple internal
+ users.
+
+ * Scripts/Preferences/WebPreferencesInternal.yaml:
+
2021-12-07 Sihui Liu <[email protected]>
Fetch and remove file system data via WKWebsiteDataStore
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml (286639 => 286640)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml 2021-12-08 04:24:38 UTC (rev 286640)
@@ -176,6 +176,19 @@
WebKit:
default: false
+CookieConsentAPIEnabled:
+ type: bool
+ humanReadableName: "Cookie Consent API"
+ humanReadableDescription: "Enable cookie consent API"
+ exposed: [ WebKit ]
+ defaultValue:
+ WebCore:
+ default: false
+ WebKitLegacy:
+ default: false
+ WebKit:
+ default: false
+
DOMPasteAccessRequestsEnabled:
type: bool
humanReadableName: "DOM Paste Access Requests"
Modified: trunk/Source/WebCore/CMakeLists.txt (286639 => 286640)
--- trunk/Source/WebCore/CMakeLists.txt 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/CMakeLists.txt 2021-12-08 04:24:38 UTC (rev 286640)
@@ -27,6 +27,7 @@
"${WEBCORE_DIR}/Modules/beacon"
"${WEBCORE_DIR}/Modules/cache"
"${WEBCORE_DIR}/Modules/contact-picker"
+ "${WEBCORE_DIR}/Modules/cookie-consent"
"${WEBCORE_DIR}/Modules/credentialmanagement"
"${WEBCORE_DIR}/Modules/encryptedmedia"
"${WEBCORE_DIR}/Modules/encryptedmedia/legacy"
@@ -256,6 +257,9 @@
Modules/contact-picker/ContactsSelectOptions.idl
Modules/contact-picker/Navigator+Contacts.idl
+ Modules/cookie-consent/Navigator+CookieConsent.idl
+ Modules/cookie-consent/RequestCookieConsentOptions.idl
+
Modules/credentialmanagement/BasicCredential.idl
Modules/credentialmanagement/CredentialCreationOptions.idl
Modules/credentialmanagement/CredentialRequestOptions.idl
Modified: trunk/Source/WebCore/ChangeLog (286639 => 286640)
--- trunk/Source/WebCore/ChangeLog 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/ChangeLog 2021-12-08 04:24:38 UTC (rev 286640)
@@ -1,3 +1,54 @@
+2021-12-07 Wenson Hsieh <[email protected]>
+
+ Add support for `navigator.requestCookieConsent()` behind a disabled feature flag
+ https://bugs.webkit.org/show_bug.cgi?id=233890
+ rdar://86117718
+
+ Reviewed by Darin Adler.
+
+ Add plumbing to support a new (internal-for-the-time-being) navigator API, `requestCookieConsent()`. This
+ returns a promise indicating whether or not the user (or the UA, on behalf of the user) consents to usage of
+ cookies that are not strictly necessary for page performance.
+
+ Paired with this web-facing API, we also introduce corresponding private WKUIDelegate methods that are invoked
+ as a result of calling `navigator.requestCookieConsent();`, which a WebKit embedder may implement in order to
+ present UI or otherwise respond appropriately to the request. See WebKit ChangeLog for more details.
+
+ Tests: CookieConsent.BasicDecisionHandler
+ CookieConsent.NotEnabled
+ CookieConsent.ThrowsExceptionWithoutDelegate
+
+ * CMakeLists.txt:
+ * DerivedSources-input.xcfilelist:
+ * DerivedSources-output.xcfilelist:
+ * DerivedSources.make:
+ * Headers.cmake:
+ * Modules/cookie-consent/CookieConsentDecisionResult.h: Added.
+ * Modules/cookie-consent/Navigator+CookieConsent.idl: Added.
+ * Modules/cookie-consent/NavigatorCookieConsent.cpp: Added.
+
+ Add a new partial interface on Navigator that implements the new API by calling into the chrome client hook (see
+ WebKit changes for more details). Note that in the case where the consent delegate method is not implemented by
+ the client, we will reject the promise with a `NotSupportedError`.
+
+ (WebCore::NavigatorCookieConsent::requestCookieConsent):
+ (WebCore::NavigatorCookieConsent::from):
+ * Modules/cookie-consent/NavigatorCookieConsent.h: Added.
+ (WebCore::RequestCookieConsentOptions::RequestCookieConsentOptions):
+ * Modules/cookie-consent/RequestCookieConsentOptions.h: Added.
+ * Modules/cookie-consent/RequestCookieConsentOptions.idl: Added.
+ * Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp:
+ * Modules/filesystemaccess/WorkerFileSystemStorageConnection.h:
+
+ Add some missing includes to fix the unified source build on Windows.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * loader/EmptyClients.cpp:
+ (WebCore::EmptyChromeClient::requestCookieConsent):
+ * loader/EmptyClients.h:
+ * page/ChromeClient.h:
+
2021-12-07 Cameron McCormack <[email protected]>
Remove expandAroundIdeographs static variables
Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (286639 => 286640)
--- trunk/Source/WebCore/DerivedSources-input.xcfilelist 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist 2021-12-08 04:24:38 UTC (rev 286640)
@@ -232,6 +232,8 @@
$(PROJECT_DIR)/Modules/contact-picker/ContactsManager.idl
$(PROJECT_DIR)/Modules/contact-picker/ContactsSelectOptions.idl
$(PROJECT_DIR)/Modules/contact-picker/Navigator+Contacts.idl
+$(PROJECT_DIR)/Modules/cookie-consent/Navigator+CookieConsent.idl
+$(PROJECT_DIR)/Modules/cookie-consent/RequestCookieConsentOptions.idl
$(PROJECT_DIR)/Modules/credentialmanagement/BasicCredential.idl
$(PROJECT_DIR)/Modules/credentialmanagement/CredentialCreationOptions.idl
$(PROJECT_DIR)/Modules/credentialmanagement/CredentialRequestOptions.idl
Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (286639 => 286640)
--- trunk/Source/WebCore/DerivedSources-output.xcfilelist 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist 2021-12-08 04:24:38 UTC (rev 286640)
@@ -1647,6 +1647,8 @@
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSNavigator+Clipboard.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSNavigator+Contacts.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSNavigator+Contacts.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSNavigator+CookieConsent.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSNavigator+CookieConsent.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSNavigator+Credentials.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSNavigator+Credentials.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSNavigator+EME.cpp
@@ -2089,6 +2091,8 @@
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRemotePlaybackAvailabilityCallback.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRequestAnimationFrameCallback.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRequestAnimationFrameCallback.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRequestCookieConsentOptions.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSRequestCookieConsentOptions.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserver.cpp
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserver.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSResizeObserverBoxOptions.cpp
Modified: trunk/Source/WebCore/DerivedSources.make (286639 => 286640)
--- trunk/Source/WebCore/DerivedSources.make 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/DerivedSources.make 2021-12-08 04:24:38 UTC (rev 286640)
@@ -254,6 +254,8 @@
$(WebCore)/Modules/contact-picker/ContactsManager.idl \
$(WebCore)/Modules/contact-picker/ContactsSelectOptions.idl \
$(WebCore)/Modules/contact-picker/Navigator+Contacts.idl \
+ $(WebCore)/Modules/cookie-consent/Navigator+CookieConsent.idl \
+ $(WebCore)/Modules/cookie-consent/RequestCookieConsentOptions.idl \
$(WebCore)/Modules/credentialmanagement/BasicCredential.idl \
$(WebCore)/Modules/credentialmanagement/CredentialCreationOptions.idl \
$(WebCore)/Modules/credentialmanagement/CredentialRequestOptions.idl \
Modified: trunk/Source/WebCore/Headers.cmake (286639 => 286640)
--- trunk/Source/WebCore/Headers.cmake 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/Headers.cmake 2021-12-08 04:24:38 UTC (rev 286640)
@@ -153,6 +153,8 @@
Modules/contact-picker/ContactProperty.h
Modules/contact-picker/ContactsRequestData.h
+ Modules/cookie-consent/CookieConsentDecisionResult.h
+
Modules/encryptedmedia/CDMClient.h
Modules/encryptedmedia/MediaKeySystemClient.h
Modules/encryptedmedia/MediaKeySystemController.h
Added: trunk/Source/WebCore/Modules/cookie-consent/CookieConsentDecisionResult.h (0 => 286640)
--- trunk/Source/WebCore/Modules/cookie-consent/CookieConsentDecisionResult.h (rev 0)
+++ trunk/Source/WebCore/Modules/cookie-consent/CookieConsentDecisionResult.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -0,0 +1,51 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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
+
+#include <wtf/EnumTraits.h>
+
+namespace WebCore {
+
+enum class CookieConsentDecisionResult : uint8_t {
+ NotSupported,
+ Consent,
+ Dissent,
+};
+
+} // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::CookieConsentDecisionResult> {
+ using values = EnumValues<
+ WebCore::CookieConsentDecisionResult,
+ WebCore::CookieConsentDecisionResult::NotSupported,
+ WebCore::CookieConsentDecisionResult::Consent,
+ WebCore::CookieConsentDecisionResult::Dissent
+ >;
+};
+
+} // namespace WTF
Added: trunk/Source/WebCore/Modules/cookie-consent/Navigator+CookieConsent.idl (0 => 286640)
--- trunk/Source/WebCore/Modules/cookie-consent/Navigator+CookieConsent.idl (rev 0)
+++ trunk/Source/WebCore/Modules/cookie-consent/Navigator+CookieConsent.idl 2021-12-08 04:24:38 UTC (rev 286640)
@@ -0,0 +1,31 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+[
+ EnabledBySetting=CookieConsentAPIEnabled,
+ ImplementedBy=NavigatorCookieConsent,
+] partial interface Navigator {
+ Promise<boolean> requestCookieConsent(optional RequestCookieConsentOptions options);
+};
Added: trunk/Source/WebCore/Modules/cookie-consent/NavigatorCookieConsent.cpp (0 => 286640)
--- trunk/Source/WebCore/Modules/cookie-consent/NavigatorCookieConsent.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/cookie-consent/NavigatorCookieConsent.cpp 2021-12-08 04:24:38 UTC (rev 286640)
@@ -0,0 +1,82 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#include "config.h"
+#include "NavigatorCookieConsent.h"
+
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "CookieConsentDecisionResult.h"
+#include "ExceptionCode.h"
+#include "JSDOMPromiseDeferred.h"
+#include "Navigator.h"
+#include "Page.h"
+#include "RequestCookieConsentOptions.h"
+
+namespace WebCore {
+
+void NavigatorCookieConsent::requestCookieConsent(Navigator& navigator, std::optional<RequestCookieConsentOptions>&& options, Ref<DeferredPromise>&& promise)
+{
+ from(navigator).requestCookieConsent(WTFMove(options), WTFMove(promise));
+}
+
+void NavigatorCookieConsent::requestCookieConsent(std::optional<RequestCookieConsentOptions>&& options, Ref<DeferredPromise>&& promise)
+{
+ // FIXME: Support the 'More info' option.
+ UNUSED_PARAM(options);
+
+ RefPtr frame = m_navigator.frame();
+ if (!frame || !frame->isMainFrame() || !frame->page()) {
+ promise->reject(NotAllowedError);
+ return;
+ }
+
+ frame->page()->chrome().client().requestCookieConsent([promise = WTFMove(promise)] (CookieConsentDecisionResult result) {
+ switch (result) {
+ case CookieConsentDecisionResult::NotSupported:
+ promise->reject(NotSupportedError);
+ break;
+ case CookieConsentDecisionResult::Consent:
+ promise->resolve<IDLBoolean>(true);
+ break;
+ case CookieConsentDecisionResult::Dissent:
+ promise->resolve<IDLBoolean>(false);
+ break;
+ }
+ });
+}
+
+NavigatorCookieConsent& NavigatorCookieConsent::from(Navigator& navigator)
+{
+ if (auto supplement = static_cast<NavigatorCookieConsent*>(Supplement<Navigator>::from(&navigator, supplementName())))
+ return *supplement;
+
+ auto newSupplement = makeUnique<NavigatorCookieConsent>(navigator);
+ auto supplement = newSupplement.get();
+ provideTo(&navigator, supplementName(), WTFMove(newSupplement));
+ return *supplement;
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/Modules/cookie-consent/NavigatorCookieConsent.h (0 => 286640)
--- trunk/Source/WebCore/Modules/cookie-consent/NavigatorCookieConsent.h (rev 0)
+++ trunk/Source/WebCore/Modules/cookie-consent/NavigatorCookieConsent.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -0,0 +1,59 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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
+
+#include "Supplementable.h"
+#include <wtf/Forward.h>
+#include <wtf/IsoMalloc.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class DeferredPromise;
+class Navigator;
+
+struct RequestCookieConsentOptions;
+
+class NavigatorCookieConsent final : public Supplement<Navigator> {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ explicit NavigatorCookieConsent(Navigator& navigator)
+ : m_navigator(navigator)
+ {
+ }
+
+ static void requestCookieConsent(Navigator&, std::optional<RequestCookieConsentOptions>&&, Ref<DeferredPromise>&&);
+
+private:
+ static NavigatorCookieConsent& from(Navigator&);
+ static const char* supplementName() { return "NavigatorCookieConsent"; }
+
+ void requestCookieConsent(std::optional<RequestCookieConsentOptions>&&, Ref<DeferredPromise>&&);
+
+ Navigator& m_navigator;
+};
+
+} // namespace WebCore
Added: trunk/Source/WebCore/Modules/cookie-consent/RequestCookieConsentOptions.h (0 => 286640)
--- trunk/Source/WebCore/Modules/cookie-consent/RequestCookieConsentOptions.h (rev 0)
+++ trunk/Source/WebCore/Modules/cookie-consent/RequestCookieConsentOptions.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -0,0 +1,36 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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
+
+#include "VoidCallback.h"
+
+namespace WebCore {
+
+struct RequestCookieConsentOptions {
+ RefPtr<VoidCallback> moreInfo;
+};
+
+} // namespace WebCore
Added: trunk/Source/WebCore/Modules/cookie-consent/RequestCookieConsentOptions.idl (0 => 286640)
--- trunk/Source/WebCore/Modules/cookie-consent/RequestCookieConsentOptions.idl (rev 0)
+++ trunk/Source/WebCore/Modules/cookie-consent/RequestCookieConsentOptions.idl 2021-12-08 04:24:38 UTC (rev 286640)
@@ -0,0 +1,28 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+dictionary RequestCookieConsentOptions {
+ VoidCallback? moreInfo;
+};
Modified: trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp (286639 => 286640)
--- trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp 2021-12-08 04:24:38 UTC (rev 286640)
@@ -26,6 +26,7 @@
#include "config.h"
#include "WorkerFileSystemStorageConnection.h"
+#include "FileSystemSyncAccessHandle.h"
#include "WorkerGlobalScope.h"
#include "WorkerLoaderProxy.h"
#include "WorkerThread.h"
Modified: trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.h (286639 => 286640)
--- trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -32,6 +32,7 @@
namespace WebCore {
+class FileSystemSyncAccessHandle;
class WorkerGlobalScope;
class WorkerThread;
Modified: trunk/Source/WebCore/Sources.txt (286639 => 286640)
--- trunk/Source/WebCore/Sources.txt 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/Sources.txt 2021-12-08 04:24:38 UTC (rev 286640)
@@ -68,6 +68,7 @@
Modules/cache/WorkerCacheStorageConnection.cpp
Modules/contact-picker/ContactsManager.cpp
Modules/contact-picker/NavigatorContacts.cpp
+Modules/cookie-consent/NavigatorCookieConsent.cpp
Modules/credentialmanagement/BasicCredential.cpp
Modules/credentialmanagement/CredentialsContainer.cpp
Modules/credentialmanagement/NavigatorCredentials.cpp
@@ -3673,6 +3674,7 @@
JSRemotePlayback.cpp
JSRemotePlaybackAvailabilityCallback.cpp
JSRequestAnimationFrameCallback.cpp
+JSRequestCookieConsentOptions.cpp
JSResizeObserver.cpp
JSResizeObserverBoxOptions.cpp
JSResizeObserverCallback.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (286639 => 286640)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-08 04:24:38 UTC (rev 286640)
@@ -5450,6 +5450,9 @@
F344C75311294D9D00F26EEE /* InspectorFrontendClientLocal.h in Headers */ = {isa = PBXBuildFile; fileRef = F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */; settings = {ATTRIBUTES = (Private, ); }; };
F3ABFE0C130E9DA000E7F7D1 /* InstrumentingAgents.h in Headers */ = {isa = PBXBuildFile; fileRef = F3ABFE0B130E9DA000E7F7D1 /* InstrumentingAgents.h */; };
F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSErrorHandler.h */; };
+ F4034F9D275C4789003A81F8 /* CookieConsentDecisionResult.h in Headers */ = {isa = PBXBuildFile; fileRef = F4034F9C275C4783003A81F8 /* CookieConsentDecisionResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ F4034FAC275EAD6E003A81F8 /* RequestCookieConsentOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = F4034F8F275C1686003A81F8 /* RequestCookieConsentOptions.h */; };
+ F4034FAE275EAD76003A81F8 /* NavigatorCookieConsent.h in Headers */ = {isa = PBXBuildFile; fileRef = F4034F8D275C087B003A81F8 /* NavigatorCookieConsent.h */; };
F403E7872363B58C00044550 /* EnterKeyHint.h in Headers */ = {isa = PBXBuildFile; fileRef = F403E7852363B58C00044550 /* EnterKeyHint.h */; settings = {ATTRIBUTES = (Private, ); }; };
F40DAAEC25D9F25E0011B4FA /* PasteboardContext.h in Headers */ = {isa = PBXBuildFile; fileRef = F40DAAEB25D9F25E0011B4FA /* PasteboardContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
F40DAAEF25D9F3BF0011B4FA /* PagePasteboardContext.h in Headers */ = {isa = PBXBuildFile; fileRef = F40DAAEE25D9F3BF0011B4FA /* PagePasteboardContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -17595,6 +17598,12 @@
F3ABFE0B130E9DA000E7F7D1 /* InstrumentingAgents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstrumentingAgents.h; sourceTree = "<group>"; };
F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorHandler.cpp; sourceTree = "<group>"; };
F3D461471161D53200CA0D09 /* JSErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorHandler.h; sourceTree = "<group>"; };
+ F4034F8C275C087B003A81F8 /* NavigatorCookieConsent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NavigatorCookieConsent.cpp; path = "cookie-consent/NavigatorCookieConsent.cpp"; sourceTree = "<group>"; };
+ F4034F8D275C087B003A81F8 /* NavigatorCookieConsent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NavigatorCookieConsent.h; path = "cookie-consent/NavigatorCookieConsent.h"; sourceTree = "<group>"; };
+ F4034F8E275C087C003A81F8 /* Navigator+CookieConsent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "Navigator+CookieConsent.idl"; path = "cookie-consent/Navigator+CookieConsent.idl"; sourceTree = "<group>"; };
+ F4034F8F275C1686003A81F8 /* RequestCookieConsentOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RequestCookieConsentOptions.h; path = "cookie-consent/RequestCookieConsentOptions.h"; sourceTree = "<group>"; };
+ F4034F91275C1686003A81F8 /* RequestCookieConsentOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; name = RequestCookieConsentOptions.idl; path = "cookie-consent/RequestCookieConsentOptions.idl"; sourceTree = "<group>"; };
+ F4034F9C275C4783003A81F8 /* CookieConsentDecisionResult.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CookieConsentDecisionResult.h; path = "cookie-consent/CookieConsentDecisionResult.h"; sourceTree = "<group>"; };
F403E7852363B58C00044550 /* EnterKeyHint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnterKeyHint.h; sourceTree = "<group>"; };
F403E7862363B58C00044550 /* EnterKeyHint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnterKeyHint.cpp; sourceTree = "<group>"; };
F40DAAEB25D9F25E0011B4FA /* PasteboardContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteboardContext.h; sourceTree = "<group>"; };
@@ -25810,6 +25819,7 @@
832150791F27E96B0095B136 /* beacon */,
41380C1E1F34366000155FDA /* cache */,
E596DD23251902D600C275A7 /* contact-picker */,
+ F4034F8B275C0867003A81F8 /* cookie-consent */,
57C7A6881E56946D00C67D71 /* credentialmanagement */,
CDA98DBD16014E0800FEA3B1 /* encryptedmedia */,
83FB33651F508A1700986E54 /* entriesapi */,
@@ -31217,6 +31227,19 @@
path = mac;
sourceTree = "<group>";
};
+ F4034F8B275C0867003A81F8 /* cookie-consent */ = {
+ isa = PBXGroup;
+ children = (
+ F4034F9C275C4783003A81F8 /* CookieConsentDecisionResult.h */,
+ F4034F8E275C087C003A81F8 /* Navigator+CookieConsent.idl */,
+ F4034F8C275C087B003A81F8 /* NavigatorCookieConsent.cpp */,
+ F4034F8D275C087B003A81F8 /* NavigatorCookieConsent.h */,
+ F4034F8F275C1686003A81F8 /* RequestCookieConsentOptions.h */,
+ F4034F91275C1686003A81F8 /* RequestCookieConsentOptions.idl */,
+ );
+ name = "cookie-consent";
+ sourceTree = "<group>";
+ };
F440E769233D93620063F9AB /* Clipboard */ = {
isa = PBXGroup;
children = (
@@ -33053,7 +33076,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
- 7B582DD82716F55B004B92D0 /* (null) in Headers */,
7CD0E2B81F80A4820016A4CE /* AbortController.h in Headers */,
7CD0E2BF1F80A56E0016A4CE /* AbortSignal.h in Headers */,
46B95195207D633400A7D2DD /* AbstractDOMWindow.h in Headers */,
@@ -33604,6 +33626,7 @@
FD31602912B0267600C1A359 /* ConvolverNode.h in Headers */,
83F28C0024DB1DE1005BA6F6 /* ConvolverOptions.h in Headers */,
D8B6152F1032495100C8554A /* Cookie.h in Headers */,
+ F4034F9D275C4789003A81F8 /* CookieConsentDecisionResult.h in Headers */,
E1424C94164B52C800F32D40 /* CookieJar.h in Headers */,
7A5699702086C619000E0433 /* CookieRequestHeaderFieldProxy.h in Headers */,
33D0212D131DB37B004091A8 /* CookieStorage.h in Headers */,
@@ -36038,6 +36061,7 @@
8321507E1F27EA1B0095B136 /* NavigatorBeacon.h in Headers */,
F440E77A233D94D70063F9AB /* NavigatorClipboard.h in Headers */,
E596DD29251903D200C275A7 /* NavigatorContacts.h in Headers */,
+ F4034FAE275EAD76003A81F8 /* NavigatorCookieConsent.h in Headers */,
372D3E57216578AE00C5E021 /* NavigatorCredentials.h in Headers */,
9711460414EF009A00674FD9 /* NavigatorGeolocation.h in Headers */,
6B507A24234BF34100BE7C62 /* NavigatorIsLoggedIn.h in Headers */,
@@ -36612,6 +36636,7 @@
071C00342707D95500D027C7 /* ReplayKitCaptureSource.h in Headers */,
46DD6E1F26E7DBE7008C1F4C /* ReportingEndpointsCache.h in Headers */,
4998AEC613F9D0EA0090B1AA /* RequestAnimationFrameCallback.h in Headers */,
+ F4034FAC275EAD6E003A81F8 /* RequestCookieConsentOptions.h in Headers */,
F55B3DD01251F12D003EF269 /* ResetInputType.h in Headers */,
58B2F9F42232D45300938D63 /* ResizeObservation.h in Headers */,
58B2F9F52232D45800938D63 /* ResizeObserver.h in Headers */,
Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (286639 => 286640)
--- trunk/Source/WebCore/loader/EmptyClients.cpp 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp 2021-12-08 04:24:38 UTC (rev 286640)
@@ -35,6 +35,7 @@
#include "CacheStorageProvider.h"
#include "ColorChooser.h"
#include "ContextMenuClient.h"
+#include "CookieConsentDecisionResult.h"
#include "CookieJar.h"
#include "DOMPasteAccess.h"
#include "DataListSuggestionPicker.h"
@@ -584,6 +585,11 @@
{
}
+void EmptyChromeClient::requestCookieConsent(CompletionHandler<void(CookieConsentDecisionResult)>&& completion)
+{
+ completion(CookieConsentDecisionResult::NotSupported);
+}
+
void EmptyFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction&, const ResourceRequest&, FormState*, const String&, PolicyCheckIdentifier, FramePolicyFunction&&)
{
}
Modified: trunk/Source/WebCore/loader/EmptyClients.h (286639 => 286640)
--- trunk/Source/WebCore/loader/EmptyClients.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/loader/EmptyClients.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -218,6 +218,8 @@
bool shouldNotifyOnFormChanges() final { return false; }
RefPtr<Icon> createIconForFiles(const Vector<String>& /* filenames */) final { return nullptr; }
+
+ void requestCookieConsent(CompletionHandler<void(CookieConsentDecisionResult)>&&) final;
};
DiagnosticLoggingClient& emptyDiagnosticLoggingClient();
Modified: trunk/Source/WebCore/page/ChromeClient.h (286639 => 286640)
--- trunk/Source/WebCore/page/ChromeClient.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebCore/page/ChromeClient.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -142,6 +142,7 @@
struct ViewportArguments;
struct WindowFeatures;
+enum class CookieConsentDecisionResult : uint8_t;
enum class RouteSharingPolicy : uint8_t;
class ChromeClient {
@@ -619,6 +620,8 @@
virtual void abortApplePayAMSUISession() { }
#endif
+ virtual void requestCookieConsent(CompletionHandler<void(CookieConsentDecisionResult)>&&) = 0;
+
protected:
virtual ~ChromeClient() = default;
};
Modified: trunk/Source/WebKit/ChangeLog (286639 => 286640)
--- trunk/Source/WebKit/ChangeLog 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/ChangeLog 2021-12-08 04:24:38 UTC (rev 286640)
@@ -1,3 +1,33 @@
+2021-12-07 Wenson Hsieh <[email protected]>
+
+ Add support for `navigator.requestCookieConsent()` behind a disabled feature flag
+ https://bugs.webkit.org/show_bug.cgi?id=233890
+ rdar://86117718
+
+ Reviewed by Darin Adler.
+
+ Add plumbing for an async `requestCookieConsent()` method on ChromeClient that plumbs through the WebKit2 client
+ layer, into a new private (for the time being) UI delegate method. If the new delegate method is not implemented
+ (or there is no UI delegate at all), we immediately invoke the decision handler with a result of `NotSupported`,
+ allowing us to reject the promise with a `NotSupportedError`.
+
+ See WebCore ChangeLog for more details.
+
+ * UIProcess/API/APIUIClient.h:
+ (API::UIClient::requestCookieConsent):
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+ * UIProcess/Cocoa/UIDelegate.h:
+ * UIProcess/Cocoa/UIDelegate.mm:
+ (WebKit::UIDelegate::setDelegate):
+ (WebKit::UIDelegate::UIClient::requestCookieConsent):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::requestCookieConsent):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::requestCookieConsent):
+ * WebProcess/WebCoreSupport/WebChromeClient.h:
+
2021-12-07 Devin Rousso <[email protected]>
Add a `DOMPasteAccessCategory` to control which pasteboard the WebProcess is granted access to when pasting
Modified: trunk/Source/WebKit/UIProcess/API/APIUIClient.h (286639 => 286640)
--- trunk/Source/WebKit/UIProcess/API/APIUIClient.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/UIProcess/API/APIUIClient.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -30,6 +30,7 @@
#include "WebEvent.h"
#include "WebHitTestResultData.h"
#include "WebPageProxy.h"
+#include <WebCore/CookieConsentDecisionResult.h>
#include <WebCore/FloatRect.h>
#include <wtf/CompletionHandler.h>
@@ -144,6 +145,7 @@
virtual void checkUserMediaPermissionForOrigin(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionCheckProxy& request) { request.deny(); }
virtual void decidePolicyForNotificationPermissionRequest(WebKit::WebPageProxy&, SecurityOrigin&, CompletionHandler<void(bool allowed)>&& completionHandler) { completionHandler(false); }
virtual void requestStorageAccessConfirm(WebKit::WebPageProxy&, WebKit::WebFrameProxy*, const WebCore::RegistrableDomain& requestingDomain, const WebCore::RegistrableDomain& currentDomain, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); }
+ virtual void requestCookieConsent(CompletionHandler<void(WebCore::CookieConsentDecisionResult)>&& completionHandler) { completionHandler(WebCore::CookieConsentDecisionResult::NotSupported); }
// Printing.
virtual float headerHeight(WebKit::WebPageProxy&, WebKit::WebFrameProxy&) { return 0; }
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (286639 => 286640)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -177,6 +177,8 @@
- (void)_webView:(WKWebView *)webView startXRSessionWithCompletionHandler:(void (^)(id))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));
- (void)_webView:(WKWebView *)webView requestNotificationPermissionForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(macos(10.13.4), ios(WK_IOS_TBA));
+- (void)_webView:(WKWebView *)webView requestCookieConsentWithMoreInfoHandler:(void (^)(void))moreInfoHandler decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
#if TARGET_OS_IPHONE
- (BOOL)_webView:(WKWebView *)webView shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element WK_API_AVAILABLE(ios(9.0));
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h (286639 => 286640)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -106,6 +106,7 @@
bool takeFocus(WebPageProxy*, WKFocusDirection) final;
void handleAutoplayEvent(WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final;
void decidePolicyForNotificationPermissionRequest(WebPageProxy&, API::SecurityOrigin&, CompletionHandler<void(bool allowed)>&&) final;
+ void requestCookieConsent(CompletionHandler<void(WebCore::CookieConsentDecisionResult)>&&) final;
#if PLATFORM(MAC)
void showPage(WebPageProxy*) final;
@@ -270,6 +271,7 @@
bool webViewStartXRSessionWithCompletionHandler : 1;
#endif
bool webViewRequestNotificationPermissionForSecurityOriginDecisionHandler : 1;
+ bool webViewRequestCookieConsentWithMoreInfoHandlerDecisionHandler : 1;
} m_delegateMethods;
};
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (286639 => 286640)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2021-12-08 04:24:38 UTC (rev 286640)
@@ -197,6 +197,7 @@
m_delegateMethods.webViewStartXRSessionWithCompletionHandler = [delegate respondsToSelector:@selector(_webView:startXRSessionWithCompletionHandler:)];
#endif
m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)];
+ m_delegateMethods.webViewRequestCookieConsentWithMoreInfoHandlerDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestCookieConsentWithMoreInfoHandler:decisionHandler:)];
}
#if ENABLE(CONTEXT_MENUS)
@@ -641,6 +642,24 @@
}).get()];
}
+void UIDelegate::UIClient::requestCookieConsent(CompletionHandler<void(WebCore::CookieConsentDecisionResult)>&& completion)
+{
+ if (!m_uiDelegate)
+ return completion(WebCore::CookieConsentDecisionResult::NotSupported);
+
+ if (!m_uiDelegate->m_delegateMethods.webViewRequestCookieConsentWithMoreInfoHandlerDecisionHandler)
+ return completion(WebCore::CookieConsentDecisionResult::NotSupported);
+
+ auto delegate = m_uiDelegate->m_delegate.get();
+ if (!delegate)
+ return completion(WebCore::CookieConsentDecisionResult::NotSupported);
+
+ // FIXME: Add support for the 'more info' handler.
+ [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate->m_webView.get().get() requestCookieConsentWithMoreInfoHandler:nil decisionHandler:makeBlockPtr([completion = WTFMove(completion)] (BOOL decision) mutable {
+ completion(decision ? WebCore::CookieConsentDecisionResult::Consent : WebCore::CookieConsentDecisionResult::Dissent);
+ }).get()];
+}
+
#if PLATFORM(MAC)
bool UIDelegate::UIClient::canRunModal() const
{
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (286639 => 286640)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-12-08 04:24:38 UTC (rev 286640)
@@ -11024,6 +11024,11 @@
}
#endif
+void WebPageProxy::requestCookieConsent(CompletionHandler<void(CookieConsentDecisionResult)>&& completion)
+{
+ m_uiClient->requestCookieConsent(WTFMove(completion));
+}
+
} // namespace WebKit
#undef WEBPAGEPROXY_RELEASE_LOG
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (286639 => 286640)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -265,6 +265,7 @@
class ValidationBubble;
enum class AutoplayEvent : uint8_t;
+enum class CookieConsentDecisionResult : uint8_t;
enum class CreateNewGroupForHighlight : bool;
enum class DOMPasteAccessCategory : uint8_t;
enum class DOMPasteAccessResponse : uint8_t;
@@ -2032,6 +2033,8 @@
void clearNotifications(const Vector<uint64_t>& notificationIDs);
void didDestroyNotification(uint64_t notificationID);
+ void requestCookieConsent(CompletionHandler<void(WebCore::CookieConsentDecisionResult)>&&);
+
private:
WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&);
void platformInitialize();
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (286639 => 286640)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-12-08 04:24:38 UTC (rev 286640)
@@ -616,4 +616,6 @@
StartApplePayAMSUISession(URL originatingURL, struct WebCore::ApplePayAMSUIRequest request) -> (std::optional<bool> result) Async
AbortApplePayAMSUISession()
#endif
+
+ RequestCookieConsent() -> (enum:uint8_t WebCore::CookieConsentDecisionResult result) Async
}
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (286639 => 286640)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp 2021-12-08 04:24:38 UTC (rev 286640)
@@ -1559,4 +1559,9 @@
#endif // ENABLE(APPLE_PAY_AMS_UI)
+void WebChromeClient::requestCookieConsent(CompletionHandler<void(WebCore::CookieConsentDecisionResult)>&& completion)
+{
+ m_page.sendWithAsyncReply(Messages::WebPageProxy::RequestCookieConsent(), WTFMove(completion));
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (286639 => 286640)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -31,6 +31,7 @@
namespace WebCore {
class HTMLImageElement;
class RegistrableDomain;
+enum class CookieConsentDecisionResult : uint8_t;
enum class StorageAccessPromptWasShown : bool;
enum class StorageAccessWasGranted : bool;
}
@@ -462,6 +463,8 @@
void abortApplePayAMSUISession() final;
#endif
+ void requestCookieConsent(CompletionHandler<void(WebCore::CookieConsentDecisionResult)>&&) final;
+
mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
mutable bool m_cachedMainFrameHasVerticalScrollbar { false };
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (286639 => 286640)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2021-12-08 04:24:38 UTC (rev 286640)
@@ -1,3 +1,17 @@
+2021-12-07 Wenson Hsieh <[email protected]>
+
+ Add support for `navigator.requestCookieConsent()` behind a disabled feature flag
+ https://bugs.webkit.org/show_bug.cgi?id=233890
+ rdar://86117718
+
+ Reviewed by Darin Adler.
+
+ Add an implementation stub for the new chrome client hook, `requestCookieConsent()`.
+
+ * WebCoreSupport/WebChromeClient.h:
+ * WebCoreSupport/WebChromeClient.mm:
+ (WebChromeClient::requestCookieConsent):
+
2021-12-07 Devin Rousso <[email protected]>
Add a `DOMPasteAccessCategory` to control which pasteboard the WebProcess is granted access to when pasting
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h (286639 => 286640)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -257,6 +257,8 @@
RefPtr<PAL::WebGPU::GPU> createGPUForWebGPU() const final;
+ void requestCookieConsent(CompletionHandler<void(WebCore::CookieConsentDecisionResult)>&&) final;
+
#if ENABLE(VIDEO_PRESENTATION_MODE)
bool m_mockVideoPresentationModeEnabled { false };
#endif
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm (286639 => 286640)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm 2021-12-08 04:24:38 UTC (rev 286640)
@@ -58,6 +58,7 @@
#import <WebCore/ColorChooser.h>
#import <WebCore/ContextMenu.h>
#import <WebCore/ContextMenuController.h>
+#import <WebCore/CookieConsentDecisionResult.h>
#import <WebCore/Cursor.h>
#import <WebCore/DataListSuggestionPicker.h>
#import <WebCore/DeprecatedGlobalSettings.h>
@@ -1166,3 +1167,8 @@
return nullptr;
#endif
}
+
+void WebChromeClient::requestCookieConsent(CompletionHandler<void(CookieConsentDecisionResult)>&& completion)
+{
+ completion(CookieConsentDecisionResult::NotSupported);
+}
Modified: trunk/Source/WebKitLegacy/win/ChangeLog (286639 => 286640)
--- trunk/Source/WebKitLegacy/win/ChangeLog 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKitLegacy/win/ChangeLog 2021-12-08 04:24:38 UTC (rev 286640)
@@ -1,3 +1,17 @@
+2021-12-07 Wenson Hsieh <[email protected]>
+
+ Add support for `navigator.requestCookieConsent()` behind a disabled feature flag
+ https://bugs.webkit.org/show_bug.cgi?id=233890
+ rdar://86117718
+
+ Reviewed by Darin Adler.
+
+ Add an implementation stub for the new chrome client hook, `requestCookieConsent()`.
+
+ * WebCoreSupport/WebChromeClient.cpp:
+ (WebChromeClient::requestCookieConsent):
+ * WebCoreSupport/WebChromeClient.h:
+
2021-12-07 Devin Rousso <[email protected]>
Add a `DOMPasteAccessCategory` to control which pasteboard the WebProcess is granted access to when pasting
Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp (286639 => 286640)
--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.cpp 2021-12-08 04:24:38 UTC (rev 286640)
@@ -38,6 +38,7 @@
#include "WebView.h"
#include <WebCore/BString.h>
#include <WebCore/ContextMenu.h>
+#include <WebCore/CookieConsentDecisionResult.h>
#include <WebCore/Cursor.h>
#include <WebCore/FileChooser.h>
#include <WebCore/FileIconLoader.h>
@@ -875,3 +876,8 @@
return false;
#endif
}
+
+void WebChromeClient::requestCookieConsent(CompletionHandler<void(CookieConsentDecisionResult)>&& completion)
+{
+ completion(CookieConsentDecisionResult::NotSupported);
+}
Modified: trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h (286639 => 286640)
--- trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Source/WebKitLegacy/win/WebCoreSupport/WebChromeClient.h 2021-12-08 04:24:38 UTC (rev 286640)
@@ -183,6 +183,8 @@
void didFinishLoadingImageForElement(WebCore::HTMLImageElement&) final;
+ void requestCookieConsent(CompletionHandler<void(WebCore::CookieConsentDecisionResult)>&&);
+
private:
COMPtr<IWebUIDelegate> uiDelegate();
Modified: trunk/Tools/ChangeLog (286639 => 286640)
--- trunk/Tools/ChangeLog 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Tools/ChangeLog 2021-12-08 04:24:38 UTC (rev 286640)
@@ -1,3 +1,21 @@
+2021-12-07 Wenson Hsieh <[email protected]>
+
+ Add support for `navigator.requestCookieConsent()` behind a disabled feature flag
+ https://bugs.webkit.org/show_bug.cgi?id=233890
+ rdar://86117718
+
+ Reviewed by Darin Adler.
+
+ Add several new API tests that enable the feature flag and exercise the API.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit/CookieConsent.mm: Added.
+ (-[CookieConsentDelegate _webView:requestCookieConsentWithMoreInfoHandler:decisionHandler:]):
+ (TestWebKitAPI::createWebViewForTestingCookieConsent):
+ (TestWebKitAPI::checkForString):
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebKit/cookie-consent-basic.html: Added.
+
2021-12-07 Yousuke Kimoto <[email protected]>
[webkitcorepy] Fail to install python module when a working directory is not on C drive on Windows
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (286639 => 286640)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-12-08 03:59:13 UTC (rev 286639)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-12-08 04:24:38 UTC (rev 286640)
@@ -997,6 +997,8 @@
F4010B8024DA24AC00A876E2 /* NavigationSwipeTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4010B7F24DA24AC00A876E2 /* NavigationSwipeTests.mm */; };
F4010B8324DA267F00A876E2 /* PoseAsClass.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4010B8124DA267F00A876E2 /* PoseAsClass.mm */; };
F402F56C23ECC2FB00865549 /* UIWKInteractionViewProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = F402F56B23ECC2FB00865549 /* UIWKInteractionViewProtocol.mm */; };
+ F4034FA1275D5402003A81F8 /* CookieConsent.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4034FA0275D5402003A81F8 /* CookieConsent.mm */; };
+ F4034FA3275D5AC6003A81F8 /* cookie-consent-basic.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4034FA2275D5449003A81F8 /* cookie-consent-basic.html */; };
F407FE391F1D0DFC0017CF25 /* enormous.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = F407FE381F1D0DE60017CF25 /* enormous.svg */; };
F4094CC725545BD5003D73E3 /* DisplayListTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4094CC625545BD5003D73E3 /* DisplayListTests.cpp */; };
F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; };
@@ -1265,6 +1267,7 @@
A13D1AD624AD468F003F92A8 /* context-menu-control-click.html in Copy Resources */,
5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */,
CD0BD0A81F79982D001AB2CF /* ContextMenuImgWithVideo.html in Copy Resources */,
+ F4034FA3275D5AC6003A81F8 /* cookie-consent-basic.html in Copy Resources */,
5C2936961D5C00ED00DEAB1E /* CookieMessage.html in Copy Resources */,
9B1F6F791F90559E00B55744 /* copy-html.html in Copy Resources */,
9B62630C1F8C25C8007EE29B /* copy-url.html in Copy Resources */,
@@ -2925,6 +2928,8 @@
F4010B8124DA267F00A876E2 /* PoseAsClass.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PoseAsClass.mm; path = ../TestRunnerShared/cocoa/PoseAsClass.mm; sourceTree = "<group>"; };
F4010B8224DA267F00A876E2 /* PoseAsClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PoseAsClass.h; path = ../TestRunnerShared/cocoa/PoseAsClass.h; sourceTree = "<group>"; };
F402F56B23ECC2FB00865549 /* UIWKInteractionViewProtocol.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = UIWKInteractionViewProtocol.mm; sourceTree = "<group>"; };
+ F4034FA0275D5402003A81F8 /* CookieConsent.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieConsent.mm; sourceTree = "<group>"; };
+ F4034FA2275D5449003A81F8 /* cookie-consent-basic.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "cookie-consent-basic.html"; sourceTree = "<group>"; };
F407FE381F1D0DE60017CF25 /* enormous.svg */ = {isa = PBXFileReference; lastKnownFileType = text; path = enormous.svg; sourceTree = "<group>"; };
F4094CC625545BD5003D73E3 /* DisplayListTests.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayListTests.cpp; sourceTree = "<group>"; };
F4106C6821ACBF84004B89A1 /* WKWebViewFirstResponderTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewFirstResponderTests.mm; sourceTree = "<group>"; };
@@ -3272,6 +3277,7 @@
C1F7B7382449083F00124557 /* AGXCompilerService.mm */,
C15CBB2F23F1FF1A00300CC7 /* BacklightLevelNotification.mm */,
C1692DC923D10DAE006E88F7 /* Battery.mm */,
+ F4034FA0275D5402003A81F8 /* CookieConsent.mm */,
C13D82D82416F13200A62793 /* EnableAccessibility.mm */,
1C81802625FB09E200608B3E /* FontRegistrySandboxCheck.mm */,
E394AE6E23F2303E005B4936 /* GrantAccessToMobileAssets.mm */,
@@ -4594,6 +4600,7 @@
1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */,
9B270FED1DDC25FD002D53F3 /* closed-shadow-tree-test.html */,
5C9E56861DF9148E00C9EE33 /* contentBlockerCheck.html */,
+ F4034FA2275D5449003A81F8 /* cookie-consent-basic.html */,
2DDD4DA3270B8B3300659A61 /* cube.usdz */,
290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */,
118153432208B7AC00B2CCD2 /* deferred-script-load.html */,
@@ -5408,6 +5415,7 @@
8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */,
CD0BD0A61F79924D001AB2CF /* ContextMenuImgWithVideo.mm in Sources */,
A1C142C224AA7B2E00444207 /* ContextMenuMouseEvents.mm in Sources */,
+ F4034FA1275D5402003A81F8 /* CookieConsent.mm in Sources */,
7CCE7EAC1A411A3400447C4C /* Counters.cpp in Sources */,
7AEAD47F1E20116C00416EFE /* CrossPartitionFileSchemeAccess.mm in Sources */,
7CCE7EDB1A411A9200447C4C /* CSSParser.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/CookieConsent.mm (0 => 286640)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/CookieConsent.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/CookieConsent.mm 2021-12-08 04:24:38 UTC (rev 286640)
@@ -0,0 +1,102 @@
+/*
+ * 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#import "config.h"
+
+#import "TestWKWebView.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WebKitPrivate.h>
+#import <WebKit/_WKInternalDebugFeature.h>
+
+@interface CookieConsentDelegate : NSObject<WKUIDelegatePrivate>
+@property (nonatomic) BOOL decision;
+@end
+
+@implementation CookieConsentDelegate
+
+- (void)_webView:(WKWebView *)webView requestCookieConsentWithMoreInfoHandler:(void (^)(void))moreInfoHandler decisionHandler:(void (^)(BOOL))decisionHandler
+{
+ decisionHandler(self.decision);
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+static RetainPtr<TestWKWebView> createWebViewForTestingCookieConsent()
+{
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ for (_WKInternalDebugFeature *feature in WKPreferences._internalDebugFeatures) {
+ if ([feature.key isEqualToString:@"CookieConsentAPIEnabled"]) {
+ [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature];
+ break;
+ }
+ }
+ return adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 400, 400) configuration:configuration.get()]);
+}
+
+static void checkForString(TestWKWebView *webView, NSString *expectedString)
+{
+ auto contentsAsString = RetainPtr { webView.contentsAsString };
+ BOOL containsString = [contentsAsString containsString:expectedString];
+ EXPECT_TRUE(containsString);
+ if (!containsString)
+ NSLog(@"Expected: \"%@\" to contain: \"%@\"", contentsAsString.get(), expectedString);
+}
+
+TEST(CookieConsent, BasicDecisionHandler)
+{
+ auto webView = createWebViewForTestingCookieConsent();
+ auto delegate = adoptNS([[CookieConsentDelegate alloc] init]);
+ [delegate setDecision:YES];
+ [webView setUIDelegate:delegate.get()];
+ [webView synchronouslyLoadTestPageNamed:@"cookie-consent-basic"];
+ [webView waitForNextPresentationUpdate];
+ checkForString(webView.get(), @"returned: true");
+
+ [delegate setDecision:NO];
+ [webView _killWebContentProcessAndResetState];
+ [webView synchronouslyLoadTestPageNamed:@"cookie-consent-basic"];
+ [webView waitForNextPresentationUpdate];
+ checkForString(webView.get(), @"returned: false");
+}
+
+TEST(CookieConsent, NotEnabled)
+{
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)]);
+ [webView synchronouslyLoadTestPageNamed:@"cookie-consent-basic"];
+ [webView waitForNextPresentationUpdate];
+ checkForString(webView.get(), @"not enabled");
+}
+
+TEST(CookieConsent, ThrowsExceptionWithoutDelegate)
+{
+ auto webView = createWebViewForTestingCookieConsent();
+ [webView synchronouslyLoadTestPageNamed:@"cookie-consent-basic"];
+ [webView waitForNextPresentationUpdate];
+ checkForString(webView.get(), @"threw exception: NotSupportedError: The operation is not supported");
+}
+
+} // namespace TestWebKitAPI
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/cookie-consent-basic.html (0 => 286640)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/cookie-consent-basic.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/cookie-consent-basic.html 2021-12-08 04:24:38 UTC (rev 286640)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<meta charset="utf8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<head>
+<script>
+addEventListener("DOMContentLoaded", async () => {
+ const output = document.getElementById("output");
+ if (!navigator.requestCookieConsent) {
+ output.textContent = "not enabled";
+ return;
+ }
+
+ try {
+ let consent = await navigator.requestCookieConsent();
+ output.textContent = `returned: ${consent}`;
+ } catch (e) {
+ output.textContent = `threw exception: ${e}`;
+ }
+});
+</script>
+</head>
+<body>
+<pre>navigator.requestCookieConsent()</pre>
+<pre>↪ <code id="output"></code></pre>
+</body>
+</html>