<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[199091] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/199091">199091</a></dd>
<dt>Author</dt> <dd>bburg@apple.com</dd>
<dt>Date</dt> <dd>2016-04-05 20:23:18 -0700 (Tue, 05 Apr 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Automation: add support for getting, deleting, and adding cookies
https://bugs.webkit.org/show_bug.cgi?id=156090
<rdar://problem/25477678>
Reviewed by Timothy Hatcher.
Add protocol commands for manipulating cookies with respect to a given page.
Implement all but the addSingleCookie command, which needs a new WebCore API.
* UIProcess/Automation/Automation.json:
Copy the Page domain Cookie object. Add new commands.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::getAllCookies):
(WebKit::buildObjectForCookie): Copied from InspectorPageAgent.
(WebKit::buildArrayForCookies): Copied from InspectorPageAgent.
(WebKit::WebAutomationSession::didGetCookiesForFrame):
(WebKit::WebAutomationSession::deleteSingleCookie):
(WebKit::WebAutomationSession::didDeleteCookie):
(WebKit::WebAutomationSession::addSingleCookie): Added a stub for now.
(WebKit::WebAutomationSession::deleteAllCookies):
This command can use the WebCookieManager supplement directly instead of
proxying through AutomationSession. It doesn't block until the delete is
performed like the other methods do, but this shouldn't be a problem.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.messages.in:
* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::getCookiesForFrame):
(WebKit::WebAutomationSessionProxy::deleteCookie):
* WebProcess/Automation/WebAutomationSessionProxy.h:
* WebProcess/Automation/WebAutomationSessionProxy.messages.in:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationAutomationjson">trunk/Source/WebKit2/UIProcess/Automation/Automation.json</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessionh">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessionmessagesin">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxycpp">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxyh">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxymessagesin">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (199090 => 199091)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-04-06 01:37:07 UTC (rev 199090)
+++ trunk/Source/WebKit2/ChangeLog        2016-04-06 03:23:18 UTC (rev 199091)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2016-04-05 Brian Burg <bburg@apple.com>
+
+ Web Automation: add support for getting, deleting, and adding cookies
+ https://bugs.webkit.org/show_bug.cgi?id=156090
+ <rdar://problem/25477678>
+
+ Reviewed by Timothy Hatcher.
+
+ Add protocol commands for manipulating cookies with respect to a given page.
+ Implement all but the addSingleCookie command, which needs a new WebCore API.
+
+ * UIProcess/Automation/Automation.json:
+ Copy the Page domain Cookie object. Add new commands.
+
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::WebAutomationSession::getAllCookies):
+ (WebKit::buildObjectForCookie): Copied from InspectorPageAgent.
+ (WebKit::buildArrayForCookies): Copied from InspectorPageAgent.
+ (WebKit::WebAutomationSession::didGetCookiesForFrame):
+ (WebKit::WebAutomationSession::deleteSingleCookie):
+ (WebKit::WebAutomationSession::didDeleteCookie):
+ (WebKit::WebAutomationSession::addSingleCookie): Added a stub for now.
+ (WebKit::WebAutomationSession::deleteAllCookies):
+ This command can use the WebCookieManager supplement directly instead of
+ proxying through AutomationSession. It doesn't block until the delete is
+ performed like the other methods do, but this shouldn't be a problem.
+
+ * UIProcess/Automation/WebAutomationSession.h:
+ * UIProcess/Automation/WebAutomationSession.messages.in:
+ * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+ (WebKit::WebAutomationSessionProxy::getCookiesForFrame):
+ (WebKit::WebAutomationSessionProxy::deleteCookie):
+ * WebProcess/Automation/WebAutomationSessionProxy.h:
+ * WebProcess/Automation/WebAutomationSessionProxy.messages.in:
+
</ins><span class="cx"> 2016-04-05 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Fix Range requests when not using the NetworkCache with NetworkSession
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationAutomationjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/Automation.json (199090 => 199091)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/Automation.json        2016-04-06 01:37:07 UTC (rev 199090)
+++ trunk/Source/WebKit2/UIProcess/Automation/Automation.json        2016-04-06 03:23:18 UTC (rev 199091)
</span><span class="lines">@@ -187,6 +187,21 @@
</span><span class="cx"> { "name": "key", "$ref": "VirtualKey", "optional": true, "description": "A virtual key to be used to perform the specified interaction." },
</span><span class="cx"> { "name": "text", "type": "string", "optional": true, "description": "A unicode string to be delivered to the page. The sequence of key events is determined by splitting the string at grapheme cluster boundaries." }
</span><span class="cx"> ]
</span><ins>+ },
+ {
+ "id": "Cookie",
+ "type": "object",
+ "properties": [
+ { "name": "name", "type": "string", "description": "Cookie name." },
+ { "name": "value", "type": "string", "description": "Cookie value." },
+ { "name": "domain", "type": "string", "description": "Cookie domain. If empty, the domain is inherited from the relevant browsing context." },
+ { "name": "path", "type": "string", "description": "Cookie path." },
+ { "name": "expires", "type": "number", "description": "Cookie expires." },
+ { "name": "size", "type": "integer", "description": "Cookie size." },
+ { "name": "httpOnly", "type": "boolean", "description": "True if cookie is http-only." },
+ { "name": "secure", "type": "boolean", "description": "True if cookie is secure." },
+ { "name": "session", "type": "boolean", "description": "True in case of session cookie." }
+ ]
</ins><span class="cx"> }
</span><span class="cx"> ],
</span><span class="cx"> "commands": [
</span><span class="lines">@@ -410,6 +425,43 @@
</span><span class="cx"> { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
</span><span class="cx"> { "name": "userInput", "type": "string", "description": "The text to enter in the prompt." }
</span><span class="cx"> ]
</span><ins>+ },
+ {
+ "name": "getAllCookies",
+ "description": "Returns all cookies visible to the specified browsing context.",
+ "parameters": [
+ { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." }
+ ],
+ "returns": [
+ { "name": "cookies", "type": "array", "items": { "$ref": "Cookie" }, "description": "Array of cookie objects." }
+ ],
+ "async": true
+ },
+ {
+ "name": "deleteSingleCookie",
+ "description": "Deletes a cookie with the given name if visible to the specified browsing context.",
+ "parameters": [
+ { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
+ { "name": "cookieName", "type": "string", "description": "Name of the cookie to remove." }
+ ],
+ "async": true
+ },
+ {
+ "name": "addSingleCookie",
+ "description": "Add a cookie to cookie storage for the specified browsing context.",
+ "parameters": [
+ { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." },
+ { "name": "cookie", "$ref": "Cookie", "description": "The cookie that should be added to storage." }
+ ],
+ "async": true
+ },
+ {
+ "name": "deleteAllCookies",
+ "description": "Delete all cookies that are visible to the specified browsing context.",
+ "parameters": [
+ { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context." }
+ ],
+ "async": true
</ins><span class="cx"> }
</span><span class="cx"> ]
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (199090 => 199091)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2016-04-06 01:37:07 UTC (rev 199090)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2016-04-06 03:23:18 UTC (rev 199091)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include "AutomationProtocolObjects.h"
</span><span class="cx"> #include "WebAutomationSessionMessages.h"
</span><span class="cx"> #include "WebAutomationSessionProxyMessages.h"
</span><ins>+#include "WebCookieManagerProxy.h"
</ins><span class="cx"> #include "WebProcessPool.h"
</span><span class="cx"> #include <JavaScriptCore/InspectorBackendDispatcher.h>
</span><span class="cx"> #include <JavaScriptCore/InspectorFrontendRouter.h>
</span><span class="lines">@@ -657,6 +658,118 @@
</span><span class="cx"> m_client->setUserInputForCurrentJavaScriptPromptOnPage(this, page, promptValue);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebAutomationSession::getAllCookies(ErrorString& errorString, const String& browsingContextHandle, Ref<GetAllCookiesCallback>&& callback)
+{
+ WebPageProxy* page = webPageProxyForHandle(browsingContextHandle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ WebFrameProxy* mainFrame = page->mainFrame();
+ ASSERT(mainFrame);
+ if (!mainFrame)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ uint64_t callbackID = m_nextGetCookiesCallbackID++;
+ m_getCookieCallbacks.set(callbackID, WTFMove(callback));
+
+ page->process().send(Messages::WebAutomationSessionProxy::GetCookiesForFrame(mainFrame->frameID(), callbackID), 0);
+}
+
+static Ref<Inspector::Protocol::Automation::Cookie> buildObjectForCookie(const WebCore::Cookie& cookie)
+{
+ return Inspector::Protocol::Automation::Cookie::create()
+ .setName(cookie.name)
+ .setValue(cookie.value)
+ .setDomain(cookie.domain)
+ .setPath(cookie.path)
+ .setExpires(cookie.expires)
+ .setSize((cookie.name.length() + cookie.value.length()))
+ .setHttpOnly(cookie.httpOnly)
+ .setSecure(cookie.secure)
+ .setSession(cookie.session)
+ .release();
+}
+
+static Ref<Inspector::Protocol::Array<Inspector::Protocol::Automation::Cookie>> buildArrayForCookies(Vector<WebCore::Cookie>& cookiesList)
+{
+ auto cookies = Inspector::Protocol::Array<Inspector::Protocol::Automation::Cookie>::create();
+
+ for (const auto& cookie : cookiesList)
+ cookies->addItem(buildObjectForCookie(cookie));
+
+ return cookies;
+}
+
+void WebAutomationSession::didGetCookiesForFrame(uint64_t callbackID, Vector<WebCore::Cookie> cookies, const String& errorType)
+{
+ auto callback = m_getCookieCallbacks.take(callbackID);
+ if (!callback)
+ return;
+
+ if (!errorType.isEmpty()) {
+ callback->sendFailure(errorType);
+ return;
+ }
+
+ callback->sendSuccess(buildArrayForCookies(cookies));
+}
+
+void WebAutomationSession::deleteSingleCookie(ErrorString& errorString, const String& browsingContextHandle, const String& cookieName, Ref<DeleteSingleCookieCallback>&& callback)
+{
+ WebPageProxy* page = webPageProxyForHandle(browsingContextHandle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ WebFrameProxy* mainFrame = page->mainFrame();
+ ASSERT(mainFrame);
+ if (!mainFrame)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ uint64_t callbackID = m_nextDeleteCookieCallbackID++;
+ m_deleteCookieCallbacks.set(callbackID, WTFMove(callback));
+
+ page->process().send(Messages::WebAutomationSessionProxy::DeleteCookie(mainFrame->frameID(), cookieName, callbackID), 0);
+}
+
+void WebAutomationSession::didDeleteCookie(uint64_t callbackID, const String& errorType)
+{
+ auto callback = m_deleteCookieCallbacks.take(callbackID);
+ if (!callback)
+ return;
+
+ if (!errorType.isEmpty()) {
+ callback->sendFailure(errorType);
+ return;
+ }
+
+ callback->sendSuccess();
+}
+
+void WebAutomationSession::addSingleCookie(ErrorString& errorString, const String& browsingContextHandle, const Inspector::InspectorObject& cookie, Ref<AddSingleCookieCallback>&& callback)
+{
+ // FIXME: Implementing this command requires a new CookieJar API <https://webkit.org/b/156091>
+ UNUSED_PARAM(browsingContextHandle);
+ // FIXME: if the incoming cookie's domain is the string '(inherit)',
+ // then it should be inherited from the main frame's domain.
+ UNUSED_PARAM(cookie);
+ UNUSED_PARAM(callback);
+
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(NotImplemented);
+}
+
+void WebAutomationSession::deleteAllCookies(ErrorString& errorString, const String& browsingContextHandle, Ref<DeleteAllCookiesCallback>&& callback)
+{
+ WebPageProxy* page = webPageProxyForHandle(browsingContextHandle);
+ if (!page)
+ FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+ WebCore::URL activeURL = WebCore::URL(WebCore::URL(), page->pageLoadState().activeURL());
+ ASSERT(activeURL.isValid());
+
+ WebCookieManagerProxy* cookieManager = m_processPool->supplement<WebCookieManagerProxy>();
+ cookieManager->deleteCookiesForHostname(activeURL.host());
+}
+
</ins><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> static WebEvent::Modifiers protocolModifierToWebEventModifier(Inspector::Protocol::Automation::KeyModifier modifier)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h (199090 => 199091)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h        2016-04-06 01:37:07 UTC (rev 199090)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h        2016-04-06 03:23:18 UTC (rev 199091)
</span><span class="lines">@@ -46,11 +46,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><ins>+class IntPoint;
</ins><span class="cx"> class IntRect;
</span><del>-}
</del><span class="cx">
</span><del>-namespace WebCore {
-class IntPoint;
</del><ins>+struct Cookie;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if USE(APPKIT)
</span><span class="lines">@@ -117,7 +116,10 @@
</span><span class="cx"> void acceptCurrentJavaScriptDialog(Inspector::ErrorString&, const String& browsingContextHandle) override;
</span><span class="cx"> void messageOfCurrentJavaScriptDialog(Inspector::ErrorString&, const String& browsingContextHandle, String* text) override;
</span><span class="cx"> void setUserInputForCurrentJavaScriptPrompt(Inspector::ErrorString&, const String& browsingContextHandle, const String& text) override;
</span><del>-
</del><ins>+ void getAllCookies(Inspector::ErrorString&, const String& browsingContextHandle, Ref<GetAllCookiesCallback>&&) override;
+ void deleteSingleCookie(Inspector::ErrorString&, const String& browsingContextHandle, const String& cookieName, Ref<DeleteSingleCookieCallback>&&) override;
+ void addSingleCookie(Inspector::ErrorString&, const String& browsingContextHandle, const Inspector::InspectorObject& cookie, Ref<AddSingleCookieCallback>&&) override;
+ void deleteAllCookies(Inspector::ErrorString&, const String& browsingContextHandle, Ref<DeleteAllCookiesCallback>&&) override;
</ins><span class="cx"> #if USE(APPKIT)
</span><span class="cx"> bool wasEventSynthesizedForAutomation(NSEvent *);
</span><span class="cx"> #endif
</span><span class="lines">@@ -140,6 +142,8 @@
</span><span class="cx"> void didResolveParentFrame(uint64_t callbackID, uint64_t frameID, const String& errorType);
</span><span class="cx"> void didComputeElementLayout(uint64_t callbackID, WebCore::IntRect, const String& errorType);
</span><span class="cx"> void didTakeScreenshot(uint64_t callbackID, const ShareableBitmap::Handle&, const String& errorType);
</span><ins>+ void didGetCookiesForFrame(uint64_t callbackID, Vector<WebCore::Cookie>, const String& errorType);
+ void didDeleteCookie(uint64_t callbackID, const String& errorType);
</ins><span class="cx">
</span><span class="cx"> // Platform-specific helper methods.
</span><span class="cx"> void platformSimulateMouseInteraction(WebPageProxy&, const WebCore::IntPoint& viewPosition, Inspector::Protocol::Automation::MouseInteraction, Inspector::Protocol::Automation::MouseButton, WebEvent::Modifiers);
</span><span class="lines">@@ -186,6 +190,12 @@
</span><span class="cx"> uint64_t m_nextScreenshotCallbackID { 1 };
</span><span class="cx"> HashMap<uint64_t, RefPtr<Inspector::AutomationBackendDispatcherHandler::TakeScreenshotCallback>> m_screenshotCallbacks;
</span><span class="cx">
</span><ins>+ uint64_t m_nextGetCookiesCallbackID { 1 };
+ HashMap<uint64_t, RefPtr<Inspector::AutomationBackendDispatcherHandler::GetAllCookiesCallback>> m_getCookieCallbacks;
+
+ uint64_t m_nextDeleteCookieCallbackID { 1 };
+ HashMap<uint64_t, RefPtr<Inspector::AutomationBackendDispatcherHandler::DeleteSingleCookieCallback>> m_deleteCookieCallbacks;
+
</ins><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><span class="cx"> Inspector::FrontendChannel* m_remoteChannel { nullptr };
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessionmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in (199090 => 199091)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in        2016-04-06 01:37:07 UTC (rev 199090)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in        2016-04-06 03:23:18 UTC (rev 199091)
</span><span class="lines">@@ -29,4 +29,7 @@
</span><span class="cx"> DidComputeElementLayout(uint64_t callbackID, WebCore::IntRect rect, String errorType)
</span><span class="cx">
</span><span class="cx"> DidTakeScreenshot(uint64_t callbackID, WebKit::ShareableBitmap::Handle imageDataHandle, String errorType)
</span><ins>+
+ DidGetCookiesForFrame(uint64_t callbackID, Vector<WebCore::Cookie> cookies, String errorType)
+ DidDeleteCookie(uint64_t callbackID, String errorType)
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp (199090 => 199091)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp        2016-04-06 01:37:07 UTC (rev 199090)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp        2016-04-06 03:23:18 UTC (rev 199091)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include <JavaScriptCore/JSRetainPtr.h>
</span><span class="cx"> #include <JavaScriptCore/JSStringRefPrivate.h>
</span><span class="cx"> #include <JavaScriptCore/OpaqueJSString.h>
</span><ins>+#include <WebCore/CookieJar.h>
</ins><span class="cx"> #include <WebCore/DOMWindow.h>
</span><span class="cx"> #include <WebCore/Frame.h>
</span><span class="cx"> #include <WebCore/FrameTree.h>
</span><span class="lines">@@ -492,4 +493,38 @@
</span><span class="cx"> WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidTakeScreenshot(callbackID, handle, String()), 0);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebAutomationSessionProxy::getCookiesForFrame(uint64_t frameID, uint64_t callbackID)
+{
+ String frameNotFoundErrorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::FrameNotFound);
+
+ WebFrame* frame = WebProcess::singleton().webFrame(frameID);
+ if (!frame || !frame->coreFrame() || !frame->coreFrame()->document()) {
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidGetCookiesForFrame(callbackID, Vector<WebCore::Cookie>(), frameNotFoundErrorType), 0);
+ return;
+ }
+
+ // This returns the same list of cookies as when evaluating `document.cookies` in JavaScript.
+ WebCore::Document* document = frame->coreFrame()->document();
+ Vector<WebCore::Cookie> foundCookies;
+ WebCore::getRawCookies(document, document->cookieURL(), foundCookies);
+
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidGetCookiesForFrame(callbackID, foundCookies, String()), 0);
+}
+
+void WebAutomationSessionProxy::deleteCookie(uint64_t frameID, String cookieName, uint64_t callbackID)
+{
+ String frameNotFoundErrorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::FrameNotFound);
+
+ WebFrame* frame = WebProcess::singleton().webFrame(frameID);
+ if (!frame || !frame->coreFrame() || !frame->coreFrame()->document()) {
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidDeleteCookie(callbackID, frameNotFoundErrorType), 0);
+ return;
+ }
+
+ WebCore::Document* document = frame->coreFrame()->document();
+ WebCore::deleteCookie(document, document->cookieURL(), cookieName);
+
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidDeleteCookie(callbackID, String()), 0);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h (199090 => 199091)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h        2016-04-06 01:37:07 UTC (rev 199090)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h        2016-04-06 03:23:18 UTC (rev 199091)
</span><span class="lines">@@ -66,6 +66,8 @@
</span><span class="cx"> void focusFrame(uint64_t frameID);
</span><span class="cx"> void computeElementLayout(uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool useViewportCoordinates, uint64_t callbackID);
</span><span class="cx"> void takeScreenshot(uint64_t pageID, uint64_t callbackID);
</span><ins>+ void getCookiesForFrame(uint64_t frameID, uint64_t callbackID);
+ void deleteCookie(uint64_t frameID, String cookieName, uint64_t callbackID);
</ins><span class="cx">
</span><span class="cx"> String m_sessionIdentifier;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in (199090 => 199091)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in        2016-04-06 01:37:07 UTC (rev 199090)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in        2016-04-06 03:23:18 UTC (rev 199091)
</span><span class="lines">@@ -33,4 +33,7 @@
</span><span class="cx"> ComputeElementLayout(uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool useViewportCoordinates, uint64_t callbackID)
</span><span class="cx">
</span><span class="cx"> TakeScreenshot(uint64_t pageID, uint64_t callbackID)
</span><ins>+
+ GetCookiesForFrame(uint64_t frameID, uint64_t callbackID)
+ DeleteCookie(uint64_t frameID, String cookieName, uint64_t callbackID)
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>