Cap lifetime of persistent cookies created client-side through document.cookie
[WebKit-https.git] / Source / WebCore / testing / Internals.cpp
index 8685487..69b3094 100644 (file)
@@ -48,6 +48,7 @@
 #include "Chrome.h"
 #include "ClientOrigin.h"
 #include "ComposedTreeIterator.h"
+#include "CookieJar.h"
 #include "Cursor.h"
 #include "DOMRect.h"
 #include "DOMRectList.h"
@@ -4761,4 +4762,17 @@ std::optional<HEVCParameterSet> Internals::parseHEVCCodecParameters(const String
     return WebCore::parseHEVCCodecParameters(codecString);
 }
 
+auto Internals::getCookies() const -> Vector<CookieData>
+{
+    auto* document = contextDocument();
+    if (!document)
+        return { };
+
+    Vector<Cookie> cookies;
+    getRawCookies(*document, document->cookieURL(), cookies);
+    return WTF::map(cookies, [](auto& cookie) {
+        return CookieData { cookie };
+    });
+}
+
 } // namespace WebCore