Diff
Modified: trunk/Source/WTF/ChangeLog (287411 => 287412)
--- trunk/Source/WTF/ChangeLog 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WTF/ChangeLog 2021-12-23 21:50:28 UTC (rev 287412)
@@ -1,3 +1,44 @@
+2021-12-23 Brady Eidson <beid...@apple.com>
+
+ Add WTF::UUID class which is natively a 128-bit integer
+ https://bugs.webkit.org/show_bug.cgi?id=234571
+
+ Reviewed by Alex Christensen.
+
+ This patch adds a new WTF::UUID class.
+
+ For now, it is simply a wrapper around a 128-bit integer, and creating a new one primes that integer with
+ cryptographically random data.
+
+ It can be encoded/decoded as well as used as a HashKey.
+
+ And it will be a great utility to use as a unique object identifier for objects that logically exist
+ in multiple processes.
+
+ On that note, it also changes "UUIDIdentifier" to use this new UUID class instead of a v4 UUID string.
+
+ * wtf/Identified.h:
+ (WTF::UUIDIdentified::UUIDIdentified):
+
+ * wtf/UUID.cpp:
+ (WTF::UUID::UUID):
+ (WTF::UUID::toVector const):
+ (WTF::UUID::hash const):
+
+ * wtf/UUID.h:
+ (WTF::UUID::create):
+ (WTF::UUID::UUID):
+ (WTF::UUID::operator== const):
+ (WTF::UUID::data const):
+ (WTF::UUID::isHashTableDeletedValue const):
+ (WTF::UUIDHash::hash):
+ (WTF::UUIDHash::equal):
+ (WTF::HashTraits<UUID>::emptyValue):
+ (WTF::HashTraits<UUID>::constructDeletedValue):
+ (WTF::HashTraits<UUID>::isDeletedValue):
+ (WTF::UUID::encode const):
+ (WTF::UUID::decode):
+
2021-12-23 Sihui Liu <sihui_...@apple.com>
Ensure file handles used in FileSystemAccess API are closed
Modified: trunk/Source/WTF/wtf/Identified.h (287411 => 287412)
--- trunk/Source/WTF/wtf/Identified.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WTF/wtf/Identified.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -106,22 +106,14 @@
};
template <typename T>
-class UUIDIdentified : public IdentifiedBase<String, T> {
+class UUIDIdentified : public IdentifiedBase<UUID, T> {
protected:
UUIDIdentified()
- : IdentifiedBase<String, T>(createCanonicalUUIDString())
+ : IdentifiedBase<UUID, T>(UUID::create())
{
}
- UUIDIdentified(const UUIDIdentified& other)
- : IdentifiedBase<String, T>(other.isolatedCopy())
- {
- }
-
- explicit UUIDIdentified(const String& identifier)
- : IdentifiedBase<String, T>(identifier.isolatedCopy())
- {
- }
+ UUIDIdentified(const UUIDIdentified&) = default;
};
} // namespace WTF
Modified: trunk/Source/WTF/wtf/UUID.cpp (287411 => 287412)
--- trunk/Source/WTF/wtf/UUID.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WTF/wtf/UUID.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -42,6 +42,17 @@
namespace WTF {
+UUID::UUID()
+{
+ static_assert(sizeof(m_data) == 16);
+ cryptographicallyRandomValues(reinterpret_cast<unsigned char*>(&m_data), 16);
+}
+
+unsigned UUID::hash() const
+{
+ return StringHasher::hashMemory(reinterpret_cast<const unsigned char*>(&m_data), 16);
+}
+
String createCanonicalUUIDString()
{
unsigned randomData[4];
Modified: trunk/Source/WTF/wtf/UUID.h (287411 => 287412)
--- trunk/Source/WTF/wtf/UUID.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WTF/wtf/UUID.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -30,6 +30,7 @@
#pragma once
+#include <wtf/Int128.h>
#include <wtf/text/WTFString.h>
namespace WTF {
@@ -36,6 +37,93 @@
class StringView;
+class UUID {
+WTF_MAKE_FAST_ALLOCATED;
+public:
+ static UUID create()
+ {
+ return UUID { };
+ }
+
+ explicit UUID(Span<const uint8_t, 16> span)
+ {
+ memcpy(&m_data, span.data(), 16);
+ }
+
+ explicit UUID(UInt128Impl&& data)
+ : m_data(data)
+ {
+ }
+
+ UUID(const UUID&) = default;
+
+ Span<const uint8_t, 16> toSpan() const
+ {
+ return Span<const uint8_t, 16> { reinterpret_cast<const uint8_t*>(&m_data), 16 };
+ }
+
+ UUID& operator=(const UUID&) = default;
+ bool operator==(const UUID& other) const { return m_data == other.m_data; }
+
+ template<class Encoder> void encode(Encoder&) const;
+ template<class Decoder> static std::optional<UUID> decode(Decoder&);
+
+ explicit UUID(HashTableDeletedValueType)
+ : m_data(1)
+ {
+ }
+
+ explicit UUID(HashTableEmptyValueType)
+ : m_data(0)
+ {
+ }
+
+ bool isHashTableDeletedValue() const { return m_data == 1; }
+ WTF_EXPORT_PRIVATE unsigned hash() const;
+
+private:
+ WTF_EXPORT_PRIVATE UUID();
+
+ UInt128Impl m_data;
+};
+
+struct UUIDHash {
+ static unsigned hash(const UUID& key) { return key.hash(); }
+ static bool equal(const UUID& a, const UUID& b) { return a == b; }
+ static const bool safeToCompareToEmptyOrDeleted = true;
+};
+
+template<> struct HashTraits<UUID> : GenericHashTraits<UUID> {
+ static UUID emptyValue() { return UUID { HashTableEmptyValue }; }
+ static void constructDeletedValue(UUID& slot) { slot = UUID { HashTableDeletedValue }; }
+ static bool isDeletedValue(const UUID& value) { return value.isHashTableDeletedValue(); }
+};
+template<> struct DefaultHash<UUID> : UUIDHash { };
+
+template<class Encoder>
+void UUID::encode(Encoder& encoder) const
+{
+ encoder << UInt128High64(m_data) << UInt128Low64(m_data);
+}
+
+template<class Decoder>
+std::optional<UUID> UUID::decode(Decoder& decoder)
+{
+ std::optional<uint64_t> high;
+ decoder >> high;
+ if (!high)
+ return std::nullopt;
+
+ std::optional<uint64_t> low;
+ decoder >> low;
+ if (!low)
+ return std::nullopt;
+
+ return { UUID {
+ MakeUInt128(*high, *low),
+ } };
+}
+
// Creates a UUID that consists of 32 hexadecimal digits and returns its canonical form.
// The canonical form is displayed in 5 groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.
// The hexadecimal values "a" through "f" are output as lower case characters.
@@ -52,5 +140,6 @@
}
+using WTF::UUID;
using WTF::createCanonicalUUIDString;
using WTF::bootSessionUUIDString;
Modified: trunk/Source/WebCore/ChangeLog (287411 => 287412)
--- trunk/Source/WebCore/ChangeLog 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebCore/ChangeLog 2021-12-23 21:50:28 UTC (rev 287412)
@@ -1,3 +1,15 @@
+2021-12-23 Brady Eidson <beid...@apple.com>
+
+ Add WTF::UUID class which is natively a 128-bit integer
+ https://bugs.webkit.org/show_bug.cgi?id=234571
+
+ Reviewed by Alex Christensen.
+
+ No new tests (Refactor, covered by existing tests)
+
+ * Modules/notifications/NotificationData.h:
+ (WebCore::NotificationData::decode):
+
2021-12-23 Sam Weinig <wei...@apple.com>
Encapsulate gradient color stops into a self contained class
Modified: trunk/Source/WebCore/Modules/notifications/NotificationData.h (287411 => 287412)
--- trunk/Source/WebCore/Modules/notifications/NotificationData.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebCore/Modules/notifications/NotificationData.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -26,6 +26,7 @@
#pragma once
#include <optional>
+#include <wtf/UUID.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -43,7 +44,7 @@
String language;
WebCore::NotificationDirection direction;
String originString;
- String notificationID;
+ UUID notificationID;
};
template<class Encoder>
@@ -90,7 +91,7 @@
if (!originString)
return std::nullopt;
- std::optional<String> notificationID;
+ std::optional<UUID> notificationID;
decoder >> notificationID;
if (!notificationID)
return std::nullopt;
Modified: trunk/Source/WebKit/ChangeLog (287411 => 287412)
--- trunk/Source/WebKit/ChangeLog 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/ChangeLog 2021-12-23 21:50:28 UTC (rev 287412)
@@ -1,3 +1,73 @@
+2021-12-23 Brady Eidson <beid...@apple.com>
+
+ Add WTF::UUID class which is natively a 128-bit integer
+ https://bugs.webkit.org/show_bug.cgi?id=234571
+
+ Reviewed by Alex Christensen.
+
+ Notifications - which are UUID identified - are now addressed by a UUID object instead of a v4 UUID string.
+
+ * NetworkProcess/Notifications/NetworkNotificationManager.cpp:
+ (WebKit::NetworkNotificationManager::cancelNotification):
+ (WebKit::NetworkNotificationManager::clearNotifications):
+ (WebKit::NetworkNotificationManager::didDestroyNotification):
+ * NetworkProcess/Notifications/NetworkNotificationManager.h:
+
+ * Scripts/webkit/messages.py:
+ (forward_declarations_and_headers_for_replies):
+ (headers_for_type):
+
+ * Shared/Notifications/NotificationManagerMessageHandler.h:
+ * Shared/Notifications/NotificationManagerMessageHandler.messages.in:
+
+ * UIProcess/API/C/WKNotification.cpp:
+ (WKNotificationCopyCoreIDForTesting):
+ * UIProcess/API/C/WKNotification.h:
+
+ * UIProcess/API/C/WKNotificationManager.cpp:
+ (WKNotificationManagerProviderDidClickNotification_b):
+ * UIProcess/API/C/WKNotificationManager.h:
+
+ * UIProcess/Notifications/WebNotification.h:
+ (WebKit::WebNotification::coreNotificationID const):
+
+ * UIProcess/Notifications/WebNotificationManagerMessageHandler.cpp:
+ (WebKit::WebNotificationManagerMessageHandler::cancelNotification):
+ (WebKit::WebNotificationManagerMessageHandler::clearNotifications):
+ (WebKit::WebNotificationManagerMessageHandler::didDestroyNotification):
+ * UIProcess/Notifications/WebNotificationManagerMessageHandler.h:
+
+ * UIProcess/Notifications/WebNotificationManagerProxy.cpp:
+ (WebKit::WebNotificationManagerProxy::cancel):
+ (WebKit::WebNotificationManagerProxy::didDestroyNotification):
+ (WebKit::pageIDsMatch):
+ (WebKit::pageAndNotificationIDsMatch):
+ (WebKit::WebNotificationManagerProxy::clearNotifications):
+ (WebKit::WebNotificationManagerProxy::providerDidClickNotification):
+ (WebKit::WebNotificationManagerProxy::providerDidCloseNotifications):
+ * UIProcess/Notifications/WebNotificationManagerProxy.h:
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::cancelNotification):
+ (WebKit::WebPageProxy::clearNotifications):
+ (WebKit::WebPageProxy::didDestroyNotification):
+ * UIProcess/WebPageProxy.h:
+
+ * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+ (WKBundleCopyWebNotificationID):
+ * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
+
+ * WebProcess/InjectedBundle/InjectedBundle.cpp:
+ (WebKit::InjectedBundle::webNotificationID):
+ * WebProcess/InjectedBundle/InjectedBundle.h:
+
+ * WebProcess/Notifications/WebNotificationManager.cpp:
+ (WebKit::WebNotificationManager::didShowNotification):
+ (WebKit::WebNotificationManager::didClickNotification):
+ (WebKit::WebNotificationManager::didCloseNotifications):
+ * WebProcess/Notifications/WebNotificationManager.h:
+ * WebProcess/Notifications/WebNotificationManager.messages.in:
+
2021-12-23 Sihui Liu <sihui_...@apple.com>
Ensure file handles used in FileSystemAccess API are closed
Modified: trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp (287411 => 287412)
--- trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -114,19 +114,19 @@
// sendMessageWithReply<WebPushD::MessageType::EchoTwice>(WTFMove(completionHandler), String("FIXME: Do useful work here"));
}
-void NetworkNotificationManager::cancelNotification(const String&)
+void NetworkNotificationManager::cancelNotification(const UUID&)
{
if (!m_connection)
return;
}
-void NetworkNotificationManager::clearNotifications(const Vector<String>&)
+void NetworkNotificationManager::clearNotifications(const Vector<UUID>&)
{
if (!m_connection)
return;
}
-void NetworkNotificationManager::didDestroyNotification(const String&)
+void NetworkNotificationManager::didDestroyNotification(const UUID&)
{
if (!m_connection)
return;
Modified: trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h (287411 => 287412)
--- trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/NetworkProcess/Notifications/NetworkNotificationManager.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -60,9 +60,9 @@
void requestSystemNotificationPermission(const String& originString, CompletionHandler<void(bool)>&&) final;
void showNotification(const WebCore::NotificationData&) final;
- void cancelNotification(const String& notificationID) final;
- void clearNotifications(const Vector<String>& notificationIDs) final;
- void didDestroyNotification(const String& notificationID) final;
+ void cancelNotification(const UUID& notificationID) final;
+ void clearNotifications(const Vector<UUID>& notificationIDs) final;
+ void didDestroyNotification(const UUID& notificationID) final;
void maybeSendConnectionConfiguration() const;
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (287411 => 287412)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2021-12-23 21:50:28 UTC (rev 287412)
@@ -457,6 +457,7 @@
'MachSendRight',
'MediaTime',
'String',
+ 'UUID',
])
no_forward_declaration_types = types_that_cannot_be_forward_declared()
@@ -751,6 +752,7 @@
'Seconds': ['<wtf/Seconds.h>'],
'String': ['<wtf/text/WTFString.h>'],
'URL': ['<wtf/URLHash.h>'],
+ 'UUID': ['<wtf/UUID.h>'],
'WallTime': ['<wtf/WallTime.h>'],
'WebCore::ArcData': ['<WebCore/InlinePathData.h>'],
'WebCore::AutoplayEventFlags': ['<WebCore/AutoplayEvent.h>'],
Modified: trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.h (287411 => 287412)
--- trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -28,6 +28,7 @@
#include "MessageReceiver.h"
#include "WebPageProxyIdentifier.h"
#include <WebCore/NotificationDirection.h>
+#include <wtf/UUID.h>
namespace WebCore {
struct NotificationData;
@@ -41,9 +42,9 @@
virtual void requestSystemNotificationPermission(const String& securityOrigin, CompletionHandler<void(bool)>&&) = 0;
virtual void showNotification(const WebCore::NotificationData&) = 0;
- virtual void cancelNotification(const String& notificationID) = 0;
- virtual void clearNotifications(const Vector<String>& notificationIDs) = 0;
- virtual void didDestroyNotification(const String& notificationID) = 0;
+ virtual void cancelNotification(const UUID& notificationID) = 0;
+ virtual void clearNotifications(const Vector<UUID>& notificationIDs) = 0;
+ virtual void didDestroyNotification(const UUID& notificationID) = 0;
private:
// IPC::MessageReceiver
Modified: trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.messages.in (287411 => 287412)
--- trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.messages.in 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/Shared/Notifications/NotificationManagerMessageHandler.messages.in 2021-12-23 21:50:28 UTC (rev 287412)
@@ -23,7 +23,7 @@
messages -> NotificationManagerMessageHandler NotRefCounted {
RequestSystemNotificationPermission(String originIdentifier) -> (bool allowed) Async
ShowNotification(struct WebCore::NotificationData notificationData)
- CancelNotification(String notificationID)
- ClearNotifications(Vector<String> notificationIDs)
- DidDestroyNotification(String notificationID)
+ CancelNotification(UUID notificationID)
+ ClearNotifications(Vector<UUID> notificationIDs)
+ DidDestroyNotification(UUID notificationID)
}
Modified: trunk/Source/WebKit/UIProcess/API/C/WKNotification.cpp (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/API/C/WKNotification.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/API/C/WKNotification.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -28,6 +28,7 @@
#include "APISecurityOrigin.h"
#include "WKAPICast.h"
+#include "WKData.h"
#include "WKString.h"
#include "WebNotification.h"
#include <WebCore/NotificationDirection.h>
@@ -88,7 +89,9 @@
return toImpl(notification)->notificationID();
}
-WKStringRef WKNotificationCopyCoreIDForTesting(WKNotificationRef notification)
+WKDataRef WKNotificationCopyCoreIDForTesting(WKNotificationRef notification)
{
- return toCopiedAPI(toImpl(notification)->coreNotificationID());
+ auto identifier = toImpl(notification)->coreNotificationID();
+ auto span = identifier.toSpan();
+ return WKDataCreate(span.data(), span.size());
}
Modified: trunk/Source/WebKit/UIProcess/API/C/WKNotification.h (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/API/C/WKNotification.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/API/C/WKNotification.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -42,7 +42,7 @@
WK_EXPORT WKStringRef WKNotificationCopyDir(WKNotificationRef notification);
WK_EXPORT WKSecurityOriginRef WKNotificationGetSecurityOrigin(WKNotificationRef notification);
WK_EXPORT uint64_t WKNotificationGetID(WKNotificationRef notification);
-WK_EXPORT WKStringRef WKNotificationCopyCoreIDForTesting(WKNotificationRef notification);
+WK_EXPORT WKDataRef WKNotificationCopyCoreIDForTesting(WKNotificationRef notification);
#ifdef __cplusplus
}
Modified: trunk/Source/WebKit/UIProcess/API/C/WKNotificationManager.cpp (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/API/C/WKNotificationManager.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/API/C/WKNotificationManager.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -27,6 +27,7 @@
#include "WKNotificationManager.h"
#include "APIArray.h"
+#include "APIData.h"
#include "WKAPICast.h"
#include "WebNotification.h"
#include "WebNotificationManagerProxy.h"
@@ -54,9 +55,13 @@
toImpl(managerRef)->providerDidClickNotification(notificationID);
}
-void WKNotificationManagerProviderDidClickNotification_b(WKNotificationManagerRef managerRef, WKStringRef notificationID)
+void WKNotificationManagerProviderDidClickNotification_b(WKNotificationManagerRef managerRef, WKDataRef identifier)
{
- toImpl(managerRef)->providerDidClickNotification(toWTFString(notificationID));
+ auto span = toImpl(identifier)->dataReference();
+ if (span.size() != 16)
+ return;
+
+ toImpl(managerRef)->providerDidClickNotification(UUID { Span<const uint8_t, 16> { span.data(), 16 } });
}
void WKNotificationManagerProviderDidCloseNotifications(WKNotificationManagerRef managerRef, WKArrayRef notificationIDs)
Modified: trunk/Source/WebKit/UIProcess/API/C/WKNotificationManager.h (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/API/C/WKNotificationManager.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/API/C/WKNotificationManager.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -38,7 +38,7 @@
WK_EXPORT void WKNotificationManagerProviderDidShowNotification(WKNotificationManagerRef managerRef, uint64_t notificationID);
WK_EXPORT void WKNotificationManagerProviderDidClickNotification(WKNotificationManagerRef managerRef, uint64_t notificationID);
-WK_EXPORT void WKNotificationManagerProviderDidClickNotification_b(WKNotificationManagerRef managerRef, WKStringRef notificationID);
+WK_EXPORT void WKNotificationManagerProviderDidClickNotification_b(WKNotificationManagerRef managerRef, WKDataRef notificationID);
WK_EXPORT void WKNotificationManagerProviderDidCloseNotifications(WKNotificationManagerRef managerRef, WKArrayRef notificationIDs);
WK_EXPORT void WKNotificationManagerProviderDidUpdateNotificationPolicy(WKNotificationManagerRef managerRef, WKSecurityOriginRef origin, bool allowed);
WK_EXPORT void WKNotificationManagerProviderDidRemoveNotificationPolicies(WKNotificationManagerRef managerRef, WKArrayRef origins);
Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotification.h (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/Notifications/WebNotification.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotification.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -55,7 +55,7 @@
API::SecurityOrigin* origin() const { return m_origin.get(); }
uint64_t notificationID() const { return identifier(); }
- const String& coreNotificationID() const { return m_coreNotificationID; }
+ const UUID& coreNotificationID() const { return m_coreNotificationID; }
WebPageProxyIdentifier pageIdentifier() const { return m_pageIdentifier; }
@@ -69,7 +69,7 @@
String m_lang;
WebCore::NotificationDirection m_dir;
RefPtr<API::SecurityOrigin> m_origin;
- String m_coreNotificationID;
+ UUID m_coreNotificationID;
WebPageProxyIdentifier m_pageIdentifier;
};
Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.cpp (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -45,17 +45,17 @@
m_webPageProxy.showNotification(data);
}
-void WebNotificationManagerMessageHandler::cancelNotification(const String& notificationID)
+void WebNotificationManagerMessageHandler::cancelNotification(const UUID& notificationID)
{
m_webPageProxy.cancelNotification(notificationID);
}
-void WebNotificationManagerMessageHandler::clearNotifications(const Vector<String>& notificationIDs)
+void WebNotificationManagerMessageHandler::clearNotifications(const Vector<UUID>& notificationIDs)
{
m_webPageProxy.clearNotifications(notificationIDs);
}
-void WebNotificationManagerMessageHandler::didDestroyNotification(const String& notificationID)
+void WebNotificationManagerMessageHandler::didDestroyNotification(const UUID& notificationID)
{
m_webPageProxy.didDestroyNotification(notificationID);
}
Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.h (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -38,9 +38,9 @@
void requestSystemNotificationPermission(const String&, CompletionHandler<void(bool)>&&) final;
void showNotification(const WebCore::NotificationData&) final;
- void cancelNotification(const String& notificationID) final;
- void clearNotifications(const Vector<String>& notificationIDs) final;
- void didDestroyNotification(const String& notificationID) final;
+ void cancelNotification(const UUID& notificationID) final;
+ void clearNotifications(const Vector<UUID>& notificationIDs) final;
+ void didDestroyNotification(const UUID& notificationID) final;
WebPageProxy& m_webPageProxy;
};
Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -96,13 +96,13 @@
m_provider->show(*webPage, notification.get());
}
-void WebNotificationManagerProxy::cancel(WebPageProxy* webPage, const String& pageNotificationID)
+void WebNotificationManagerProxy::cancel(WebPageProxy* webPage, const UUID& pageNotificationID)
{
if (auto webNotification = m_notifications.get(pageNotificationID))
m_provider->cancel(*webNotification);
}
-void WebNotificationManagerProxy::didDestroyNotification(WebPageProxy* webPage, const String& pageNotificationID)
+void WebNotificationManagerProxy::didDestroyNotification(WebPageProxy* webPage, const UUID& pageNotificationID)
{
if (auto webNotification = m_notifications.take(pageNotificationID)) {
m_globalNotificationMap.remove(webNotification->notificationID());
@@ -110,12 +110,12 @@
}
}
-static bool pageIDsMatch(WebPageProxyIdentifier pageID, const String&, WebPageProxyIdentifier desiredPageID, const Vector<String>&)
+static bool pageIDsMatch(WebPageProxyIdentifier pageID, const UUID&, WebPageProxyIdentifier desiredPageID, const Vector<UUID>&)
{
return pageID == desiredPageID;
}
-static bool pageAndNotificationIDsMatch(WebPageProxyIdentifier pageID, const String& pageNotificationID, WebPageProxyIdentifier desiredPageID, const Vector<String>& desiredPageNotificationIDs)
+static bool pageAndNotificationIDsMatch(WebPageProxyIdentifier pageID, const UUID& pageNotificationID, WebPageProxyIdentifier desiredPageID, const Vector<UUID>& desiredPageNotificationIDs)
{
return pageID == desiredPageID && desiredPageNotificationIDs.contains(pageNotificationID);
}
@@ -122,15 +122,15 @@
void WebNotificationManagerProxy::clearNotifications(WebPageProxy* webPage)
{
- clearNotifications(webPage, Vector<String>(), pageIDsMatch);
+ clearNotifications(webPage, Vector<UUID>(), pageIDsMatch);
}
-void WebNotificationManagerProxy::clearNotifications(WebPageProxy* webPage, const Vector<String>& pageNotificationIDs)
+void WebNotificationManagerProxy::clearNotifications(WebPageProxy* webPage, const Vector<UUID>& pageNotificationIDs)
{
clearNotifications(webPage, pageNotificationIDs, pageAndNotificationIDsMatch);
}
-void WebNotificationManagerProxy::clearNotifications(WebPageProxy* webPage, const Vector<String>& pageNotificationIDs, NotificationFilterFunction filterFunction)
+void WebNotificationManagerProxy::clearNotifications(WebPageProxy* webPage, const Vector<UUID>& pageNotificationIDs, NotificationFilterFunction filterFunction)
{
auto targetPageProxyID = webPage->identifier();
@@ -139,7 +139,7 @@
for (auto notification : m_notifications.values()) {
auto pageProxyID = notification->pageIdentifier();
- String coreNotificationID = notification->coreNotificationID();
+ auto coreNotificationID = notification->coreNotificationID();
if (!filterFunction(pageProxyID, coreNotificationID, targetPageProxyID, pageNotificationIDs))
continue;
@@ -193,7 +193,7 @@
webPage->process().send(Messages::WebNotificationManager::DidClickNotification(it->value), 0);
}
-void WebNotificationManagerProxy::providerDidClickNotification(const String& coreNotificationID)
+void WebNotificationManagerProxy::providerDidClickNotification(const UUID& coreNotificationID)
{
auto notification = m_notifications.get(coreNotificationID);
if (!notification)
@@ -208,14 +208,14 @@
void WebNotificationManagerProxy::providerDidCloseNotifications(API::Array* globalNotificationIDs)
{
- HashMap<WebPageProxy*, Vector<String>> pageNotificationIDs;
+ HashMap<WebPageProxy*, Vector<UUID>> pageNotificationIDs;
size_t size = globalNotificationIDs->size();
for (size_t i = 0; i < size; ++i) {
- // The passed array might have uint64_t identifiers or String identifiers.
+ // The passed array might have uint64_t identifiers or UUID data identifiers.
// Handle both.
- String coreNotificationID;
+ std::optional<UUID> coreNotificationID;
auto* intValue = globalNotificationIDs->at<API::UInt64>(i);
if (intValue) {
auto it = m_globalNotificationMap.find(intValue->value());
@@ -224,16 +224,20 @@
coreNotificationID = it->value;
} else {
- auto* stringValue = globalNotificationIDs->at<API::String>(i);
- if (!stringValue)
+ auto* dataValue = globalNotificationIDs->at<API::Data>(i);
+ if (!dataValue)
continue;
- coreNotificationID = stringValue->string();
+ auto span = dataValue->dataReference();
+ if (span.size() != 16)
+ continue;
+
+ coreNotificationID = UUID { Span<const uint8_t, 16> { span.data(), 16 } };
}
- ASSERT(!coreNotificationID.isEmpty());
+ ASSERT(coreNotificationID);
- auto notification = m_notifications.take(coreNotificationID);
+ auto notification = m_notifications.take(*coreNotificationID);
if (!notification)
continue;
@@ -240,7 +244,7 @@
if (WebPageProxy* webPage = WebProcessProxy::webPage(notification->pageIdentifier())) {
auto pageIt = pageNotificationIDs.find(webPage);
if (pageIt == pageNotificationIDs.end()) {
- Vector<String> newVector;
+ Vector<UUID> newVector;
newVector.reserveInitialCapacity(size);
pageIt = pageNotificationIDs.add(webPage, WTFMove(newVector)).iterator;
}
Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.h (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -31,6 +31,7 @@
#include "WebPageProxyIdentifier.h"
#include <WebCore/NotificationClient.h>
#include <wtf/HashMap.h>
+#include <wtf/UUID.h>
#include <wtf/text/StringHash.h>
namespace WebCore {
@@ -60,14 +61,14 @@
HashMap<String, bool> notificationPermissions();
void show(WebPageProxy*, const WebCore::NotificationData&);
- void cancel(WebPageProxy*, const String& pageNotificationID);
+ void cancel(WebPageProxy*, const UUID& pageNotificationID);
void clearNotifications(WebPageProxy*);
- void clearNotifications(WebPageProxy*, const Vector<String>& pageNotificationIDs);
- void didDestroyNotification(WebPageProxy*, const String& pageNotificationID);
+ void clearNotifications(WebPageProxy*, const Vector<UUID>& pageNotificationIDs);
+ void didDestroyNotification(WebPageProxy*, const UUID& pageNotificationID);
void providerDidShowNotification(uint64_t notificationID);
void providerDidClickNotification(uint64_t notificationID);
- void providerDidClickNotification(const String& notificationID);
+ void providerDidClickNotification(const UUID& notificationID);
void providerDidCloseNotifications(API::Array* notificationIDs);
void providerDidUpdateNotificationPolicy(const API::SecurityOrigin*, bool allowed);
void providerDidRemoveNotificationPolicies(API::Array* origins);
@@ -78,8 +79,8 @@
private:
explicit WebNotificationManagerProxy(WebProcessPool*);
- typedef bool (*NotificationFilterFunction)(WebPageProxyIdentifier pageID, const String& pageNotificationID, WebPageProxyIdentifier desiredPageID, const Vector<String>& desiredPageNotificationIDs);
- void clearNotifications(WebPageProxy*, const Vector<String>& pageNotificationIDs, NotificationFilterFunction);
+ typedef bool (*NotificationFilterFunction)(WebPageProxyIdentifier pageID, const UUID& pageNotificationID, WebPageProxyIdentifier desiredPageID, const Vector<UUID>& desiredPageNotificationIDs);
+ void clearNotifications(WebPageProxy*, const Vector<UUID>& pageNotificationIDs, NotificationFilterFunction);
// WebContextSupplement
void processPoolDestroyed() override;
@@ -88,8 +89,8 @@
std::unique_ptr<API::NotificationProvider> m_provider;
- HashMap<uint64_t, String> m_globalNotificationMap;
- HashMap<String, Ref<WebNotification>> m_notifications;
+ HashMap<uint64_t, UUID> m_globalNotificationMap;
+ HashMap<UUID, Ref<WebNotification>> m_notifications;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -8750,17 +8750,17 @@
m_process->processPool().supplement<WebNotificationManagerProxy>()->show(this, notificationData);
}
-void WebPageProxy::cancelNotification(const String& notificationID)
+void WebPageProxy::cancelNotification(const UUID& notificationID)
{
m_process->processPool().supplement<WebNotificationManagerProxy>()->cancel(this, notificationID);
}
-void WebPageProxy::clearNotifications(const Vector<String>& notificationIDs)
+void WebPageProxy::clearNotifications(const Vector<UUID>& notificationIDs)
{
m_process->processPool().supplement<WebNotificationManagerProxy>()->clearNotifications(this, notificationIDs);
}
-void WebPageProxy::didDestroyNotification(const String& notificationID)
+void WebPageProxy::didDestroyNotification(const UUID& notificationID)
{
m_process->processPool().supplement<WebNotificationManagerProxy>()->didDestroyNotification(this, notificationID);
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (287411 => 287412)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -2033,9 +2033,9 @@
#endif
void showNotification(const WebCore::NotificationData&);
- void cancelNotification(const String& notificationID);
- void clearNotifications(const Vector<String>& notificationIDs);
- void didDestroyNotification(const String& notificationID);
+ void cancelNotification(const UUID& notificationID);
+ void clearNotifications(const Vector<UUID>& notificationIDs);
+ void didDestroyNotification(const UUID& notificationID);
void requestCookieConsent(CompletionHandler<void(WebCore::CookieConsentDecisionResult)>&&);
void classifyModalContainerControls(Vector<String>&& texts, CompletionHandler<void(Vector<WebCore::ModalContainerControlType>&&)>&&);
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp (287411 => 287412)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -34,6 +34,7 @@
#include "WKAPICast.h"
#include "WKBundleAPICast.h"
#include "WKBundlePrivate.h"
+#include "WKData.h"
#include "WKMutableArray.h"
#include "WKMutableDictionary.h"
#include "WKNumber.h"
@@ -206,13 +207,14 @@
WebKit::toImpl(bundleRef)->removeAllWebNotificationPermissions(WebKit::toImpl(pageRef));
}
-WKStringRef WKBundleCopyWebNotificationID(WKBundleRef bundleRef, JSContextRef context, JSValueRef notification)
+WKDataRef WKBundleCopyWebNotificationID(WKBundleRef bundleRef, JSContextRef context, JSValueRef notification)
{
auto identifier = WebKit::toImpl(bundleRef)->webNotificationID(context, notification);
if (!identifier)
return nullptr;
- return WebKit::toCopiedAPI(*identifier);
+ auto span = identifier->toSpan();
+ return WKDataCreate(span.data(), span.size());
}
void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundleRef, WKBundlePageRef pageRef, bool enabled)
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h (287411 => 287412)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -52,7 +52,7 @@
WK_EXPORT void WKBundleSetUserStyleSheetLocationForTesting(WKBundleRef bundle, WKStringRef location);
WK_EXPORT void WKBundleSetWebNotificationPermission(WKBundleRef bundle, WKBundlePageRef page, WKStringRef originStringRef, bool allowed);
WK_EXPORT void WKBundleRemoveAllWebNotificationPermissions(WKBundleRef bundle, WKBundlePageRef page);
-WK_EXPORT WKStringRef WKBundleCopyWebNotificationID(WKBundleRef bundle, JSContextRef context, JSValueRef notification);
+WK_EXPORT WKDataRef WKBundleCopyWebNotificationID(WKBundleRef bundle, JSContextRef context, JSValueRef notification);
WK_EXPORT WKDataRef WKBundleCreateWKDataFromUInt8Array(WKBundleRef bundle, JSContextRef context, JSValueRef data);
WK_EXPORT void WKBundleSetAsynchronousSpellCheckingEnabledForTesting(WKBundleRef bundleRef, bool enabled);
// Returns array of dictionaries. Dictionary keys are document identifiers, values are document URLs.
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp (287411 => 287412)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -310,7 +310,7 @@
#endif
}
-std::optional<String> InjectedBundle::webNotificationID(JSContextRef jsContext, JSValueRef jsNotification)
+std::optional<UUID> InjectedBundle::webNotificationID(JSContextRef jsContext, JSValueRef jsNotification)
{
#if ENABLE(NOTIFICATIONS)
WebCore::Notification* notification = JSNotification::toWrapped(toJS(jsContext)->vm(), toJS(toJS(jsContext), jsNotification));
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h (287411 => 287412)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -34,6 +34,7 @@
#include <WebCore/UserScriptTypes.h>
#include <wtf/RefPtr.h>
#include <wtf/RetainPtr.h>
+#include <wtf/UUID.h>
#include <wtf/text/WTFString.h>
#if USE(GLIB)
@@ -106,7 +107,7 @@
void setUserStyleSheetLocation(const String&);
void setWebNotificationPermission(WebPage*, const String& originString, bool allowed);
void removeAllWebNotificationPermissions(WebPage*);
- std::optional<String> webNotificationID(JSContextRef, JSValueRef);
+ std::optional<UUID> webNotificationID(JSContextRef, JSValueRef);
Ref<API::Data> createWebDataFromUint8Array(JSContextRef, JSValueRef);
typedef HashMap<uint64_t, String> DocumentIDToURLMap;
Modified: trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp (287411 => 287412)
--- trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -183,7 +183,7 @@
#endif
}
-void WebNotificationManager::didShowNotification(const String& notificationID)
+void WebNotificationManager::didShowNotification(const UUID& notificationID)
{
#if ENABLE(NOTIFICATIONS)
RefPtr<Notification> notification = m_notificationIDMap.get(notificationID);
@@ -196,7 +196,7 @@
#endif
}
-void WebNotificationManager::didClickNotification(const String& notificationID)
+void WebNotificationManager::didClickNotification(const UUID& notificationID)
{
#if ENABLE(NOTIFICATIONS)
RefPtr<Notification> notification = m_notificationIDMap.get(notificationID);
@@ -211,7 +211,7 @@
#endif
}
-void WebNotificationManager::didCloseNotifications(const Vector<String>& notificationIDs)
+void WebNotificationManager::didCloseNotifications(const Vector<UUID>& notificationIDs)
{
#if ENABLE(NOTIFICATIONS)
size_t count = notificationIDs.size();
Modified: trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.h (287411 => 287412)
--- trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -32,6 +32,7 @@
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
+#include <wtf/UUID.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
@@ -75,15 +76,15 @@
// Implemented in generated WebNotificationManagerMessageReceiver.cpp
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
- void didShowNotification(const String& notificationID);
- void didClickNotification(const String& notificationID);
- void didCloseNotifications(const Vector<String>& notificationIDs);
+ void didShowNotification(const UUID& notificationID);
+ void didClickNotification(const UUID& notificationID);
+ void didCloseNotifications(const Vector<UUID>& notificationIDs);
void didRemoveNotificationDecisions(const Vector<String>& originStrings);
WebProcess& m_process;
#if ENABLE(NOTIFICATIONS)
- typedef HashMap<String, RefPtr<WebCore::Notification>> NotificationIDMap;
+ typedef HashMap<UUID, RefPtr<WebCore::Notification>> NotificationIDMap;
NotificationIDMap m_notificationIDMap;
HashMap<String, bool> m_permissionsMap;
Modified: trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.messages.in (287411 => 287412)
--- trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.messages.in 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Source/WebKit/WebProcess/Notifications/WebNotificationManager.messages.in 2021-12-23 21:50:28 UTC (rev 287412)
@@ -21,9 +21,9 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
messages -> WebNotificationManager NotRefCounted {
- DidShowNotification(String notificationID);
- DidClickNotification(String notificationID);
- DidCloseNotifications(Vector<String> notificationIDs);
+ DidShowNotification(UUID notificationID);
+ DidClickNotification(UUID notificationID);
+ DidCloseNotifications(Vector<UUID> notificationIDs);
DidUpdateNotificationDecision(String originString, bool allowed);
DidRemoveNotificationDecisions(Vector<String> originStrings);
}
Modified: trunk/Tools/ChangeLog (287411 => 287412)
--- trunk/Tools/ChangeLog 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Tools/ChangeLog 2021-12-23 21:50:28 UTC (rev 287412)
@@ -1,3 +1,41 @@
+2021-12-23 Brady Eidson <beid...@apple.com>
+
+ Add WTF::UUID class which is natively a 128-bit integer
+ https://bugs.webkit.org/show_bug.cgi?id=234571
+
+ Reviewed by Alex Christensen.
+
+ Notifications - which are UUID identified - are now addressed by a UUID object instead of a v4 UUID string.
+
+ The way our C-API vends that UUID object is through a data object, so change WKTR to account for that.
+
+ * WebKitTestRunner/DataFunctions.h: Copied from Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.h.
+ (WTR::dataValue):
+ (WTR::dataToUUID):
+ (WTR::uuidToData):
+
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+ (WTR::InjectedBundle::postSimulateWebNotificationClick):
+ (WTR::postPageMessage):
+ * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::simulateWebNotificationClick):
+ * WebKitTestRunner/TestController.h:
+
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+
+ * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+
+ * WebKitTestRunner/WebNotificationProvider.cpp:
+ (WTR::WebNotificationProvider::showWebNotification):
+ (WTR::WebNotificationProvider::closeWebNotification):
+ (WTR::WebNotificationProvider::removeNotificationManager):
+ (WTR::WebNotificationProvider::simulateWebNotificationClick):
+ (WTR::WebNotificationProvider::reset):
+ * WebKitTestRunner/WebNotificationProvider.h:
+
2021-12-23 Sam Weinig <wei...@apple.com>
Encapsulate gradient color stops into a self contained class
Copied: trunk/Tools/WebKitTestRunner/DataFunctions.h (from rev 287411, trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerMessageHandler.h) (0 => 287412)
--- trunk/Tools/WebKitTestRunner/DataFunctions.h (rev 0)
+++ trunk/Tools/WebKitTestRunner/DataFunctions.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -0,0 +1,55 @@
+/*
+ * 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 <WebKit/WKData.h>
+#include <WebKit/WKRetainPtr.h>
+#include <wtf/UUID.h>
+
+namespace WTR {
+
+WKDataRef dataValue(WKTypeRef);
+UUID dataToUUID(WKDataRef);
+WKRetainPtr<WKDataRef> uuidToData(const UUID&);
+
+inline WKDataRef dataValue(WKTypeRef value)
+{
+ return value && WKGetTypeID(value) == WKDataGetTypeID() ? static_cast<WKDataRef>(value) : nullptr;
+}
+
+inline UUID dataToUUID(WKDataRef data)
+{
+ RELEASE_ASSERT(WKDataGetSize(data) == 16);
+ return UUID { Span<const uint8_t, 16> { WKDataGetBytes(data), 16 } };
+}
+
+inline WKRetainPtr<WKDataRef> uuidToData(const UUID& uuid)
+{
+ auto span = uuid.toSpan();
+ return adoptWK(WKDataCreate(span.data(), span.size()));
+}
+
+} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (287411 => 287412)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -663,7 +663,7 @@
WKBundlePagePostSynchronousMessageForTesting(page()->page(), toWK("SetViewSize").get(), body.get(), 0);
}
-void InjectedBundle::postSimulateWebNotificationClick(WKStringRef notificationID)
+void InjectedBundle::postSimulateWebNotificationClick(WKDataRef notificationID)
{
postPageMessage("SimulateWebNotificationClick", notificationID);
}
@@ -941,6 +941,12 @@
WKBundlePagePostMessage(page, toWK(name).get(), value);
}
+void postPageMessage(const char* name, WKDataRef value)
+{
+ if (auto page = InjectedBundle::singleton().pageRef())
+ WKBundlePagePostMessage(page, toWK(name).get(), value);
+}
+
void postSynchronousPageMessage(const char* name)
{
postSynchronousPageMessage(name, WKRetainPtr<WKTypeRef> { });
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (287411 => 287412)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -94,7 +94,7 @@
void postSetBackingScaleFactor(double);
void postSetWindowIsKey(bool);
void postSetViewSize(double width, double height);
- void postSimulateWebNotificationClick(WKStringRef notificationID);
+ void postSimulateWebNotificationClick(WKDataRef notificationID);
void postSetAddsVisitedLinks(bool);
// Geolocation.
@@ -228,6 +228,7 @@
void postPageMessage(const char* name, bool value);
void postPageMessage(const char* name, const char* value);
void postPageMessage(const char* name, WKStringRef value);
+void postPageMessage(const char* name, WKDataRef value);
void postPageMessage(const char* name, const void* value) = delete;
void postSynchronousPageMessage(const char* name);
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (287411 => 287412)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -2346,7 +2346,7 @@
m_currentInvocation->didRemoveSwipeSnapshot();
}
-void TestController::simulateWebNotificationClick(WKStringRef notificationID)
+void TestController::simulateWebNotificationClick(WKDataRef notificationID)
{
m_webNotificationProvider.simulateWebNotificationClick(mainWebView()->page(), notificationID);
}
Modified: trunk/Tools/WebKitTestRunner/TestController.h (287411 => 287412)
--- trunk/Tools/WebKitTestRunner/TestController.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -125,7 +125,7 @@
bool beforeUnloadReturnValue() const { return m_beforeUnloadReturnValue; }
void setBeforeUnloadReturnValue(bool value) { m_beforeUnloadReturnValue = value; }
- void simulateWebNotificationClick(WKStringRef notificationID);
+ void simulateWebNotificationClick(WKDataRef notificationID);
// Geolocation.
void setGeolocationPermission(bool);
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (287411 => 287412)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -27,6 +27,7 @@
#include "config.h"
#include "TestInvocation.h"
+#include "DataFunctions.h"
#include "DictionaryFunctions.h"
#include "PlatformWebView.h"
#include "TestController.h"
@@ -390,7 +391,7 @@
}
if (WKStringIsEqualToUTF8CString(messageName, "SimulateWebNotificationClick")) {
- WKStringRef notificationID = stringValue(messageBody);
+ WKDataRef notificationID = dataValue(messageBody);
TestController::singleton().simulateWebNotificationClick(notificationID);
return;
}
Modified: trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (287411 => 287412)
--- trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj 2021-12-23 21:50:28 UTC (rev 287412)
@@ -327,6 +327,7 @@
4430AE171F82C4EE0099915A /* GeneratedTouchesDebugWindow.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GeneratedTouchesDebugWindow.mm; sourceTree = "<group>"; };
4430AE181F82C4EF0099915A /* GeneratedTouchesDebugWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedTouchesDebugWindow.h; sourceTree = "<group>"; };
49AEEF692407278200C87E4C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 510E2F3827741F8300809333 /* DataFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataFunctions.h; sourceTree = "<group>"; };
5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CyclicRedundancyCheck.cpp; sourceTree = "<group>"; };
5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; };
5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PixelDumpSupport.cpp; sourceTree = "<group>"; };
@@ -942,6 +943,7 @@
isa = PBXGroup;
children = (
378D442213346D00006A777B /* config.h */,
+ 510E2F3827741F8300809333 /* DataFunctions.h */,
9338D1BE250BD9DD00E827F6 /* DictionaryFunctions.h */,
BC99A4841208901A007E9F08 /* StringFunctions.h */,
9B36A270209453A0003E0651 /* WhatToDump.h */,
Modified: trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp (287411 => 287412)
--- trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp 2021-12-23 21:50:28 UTC (rev 287412)
@@ -26,6 +26,7 @@
#include "config.h"
#include "WebNotificationProvider.h"
+#include "DataFunctions.h"
#include "StringFunctions.h"
#include <WebKit/WKMutableArray.h>
#include <WebKit/WKNotification.h>
@@ -95,7 +96,7 @@
uint64_t identifier = WKNotificationGetID(notification);
auto coreIdentifier = adoptWK(WKNotificationCopyCoreIDForTesting(notification));
- auto addResult = m_owningManager.set(toWTFString(coreIdentifier.get()), notificationManager);
+ auto addResult = m_owningManager.set(dataToUUID(coreIdentifier.get()), notificationManager);
ASSERT_UNUSED(addResult, addResult.isNewEntry);
WKNotificationManagerProviderDidShowNotification(notificationManager, identifier);
@@ -103,9 +104,9 @@
void WebNotificationProvider::closeWebNotification(WKNotificationRef notification)
{
- auto identifier = toWTFString(adoptWK(WKNotificationCopyCoreIDForTesting(notification)).get());
+ auto identifier = adoptWK(WKNotificationCopyCoreIDForTesting(notification));
- auto notificationManager = m_owningManager.take(identifier);
+ auto notificationManager = m_owningManager.take(dataToUUID(identifier.get()));
ASSERT(notificationManager);
ASSERT(m_knownManagers.contains(notificationManager));
@@ -126,7 +127,7 @@
auto protectedManager = m_knownManagers.take(manager);
ASSERT(protectedManager);
- auto toRemove = Vector<String> { };
+ auto toRemove = Vector<UUID> { };
for (auto& iterator : m_owningManager) {
if (iterator.value != manager)
continue;
@@ -135,7 +136,7 @@
auto array = adoptWK(WKMutableArrayCreate());
for (auto& identifier : toRemove) {
- WKArrayAppendItem(array.get(), toWK(identifier).get());
+ WKArrayAppendItem(array.get(), uuidToData(identifier).get());
m_owningManager.remove(identifier);
}
@@ -148,9 +149,9 @@
return WKMutableDictionaryCreate();
}
-void WebNotificationProvider::simulateWebNotificationClick(WKPageRef, WKStringRef notificationID)
+void WebNotificationProvider::simulateWebNotificationClick(WKPageRef, WKDataRef notificationID)
{
- auto identifier = toWTFString(notificationID);
+ auto identifier = dataToUUID(notificationID);
ASSERT(m_owningManager.contains(identifier));
WKNotificationManagerProviderDidClickNotification_b(m_owningManager.get(identifier), notificationID);
@@ -160,7 +161,7 @@
{
for (auto iterator : m_owningManager) {
auto array = adoptWK(WKMutableArrayCreate());
- WKArrayAppendItem(array.get(), toWK(iterator.key).get());
+ WKArrayAppendItem(array.get(), uuidToData(iterator.key).get());
WKNotificationManagerProviderDidCloseNotifications(iterator.value, array.get());
}
Modified: trunk/Tools/WebKitTestRunner/WebNotificationProvider.h (287411 => 287412)
--- trunk/Tools/WebKitTestRunner/WebNotificationProvider.h 2021-12-23 21:35:00 UTC (rev 287411)
+++ trunk/Tools/WebKitTestRunner/WebNotificationProvider.h 2021-12-23 21:50:28 UTC (rev 287412)
@@ -31,6 +31,7 @@
#include <WebKit/WKRetainPtr.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
+#include <wtf/UUID.h>
#include <wtf/text/StringHash.h>
namespace WTR {
@@ -47,12 +48,12 @@
void removeNotificationManager(WKNotificationManagerRef);
WKDictionaryRef notificationPermissions();
- void simulateWebNotificationClick(WKPageRef, WKStringRef notificationID);
+ void simulateWebNotificationClick(WKPageRef, WKDataRef notificationID);
void reset();
private:
HashSet<WKRetainPtr<WKNotificationManagerRef>> m_knownManagers;
- HashMap<String, WKNotificationManagerRef> m_owningManager;
+ HashMap<UUID, WKNotificationManagerRef> m_owningManager;
};
}