Title: [216261] trunk/Source/WebKit2
Revision
216261
Author
[email protected]
Date
2017-05-05 12:31:21 -0700 (Fri, 05 May 2017)

Log Message

Web Automation: cookie-related commands don't work correctly
https://bugs.webkit.org/show_bug.cgi?id=171713
<rdar://problem/29829930>

Reviewed by Alexey Proskuryakov.

Commands that use WebCookieManager directly should complete when
the manager's completion handler is called. Otherwise, this will race
with subsequent accesses to cookies via the web process (document.cookie).

Also, these commands need to use the active browsing context's session ID.
They currently use the process pool's storage session, which is wrong
since we specially configure automation instances with an ephemeral store.

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::addSingleCookie):
(WebKit::WebAutomationSession::deleteAllCookies):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (216260 => 216261)


--- trunk/Source/WebKit2/ChangeLog	2017-05-05 19:26:35 UTC (rev 216260)
+++ trunk/Source/WebKit2/ChangeLog	2017-05-05 19:31:21 UTC (rev 216261)
@@ -1,3 +1,23 @@
+2017-05-05  Brian Burg  <[email protected]>
+
+        Web Automation: cookie-related commands don't work correctly
+        https://bugs.webkit.org/show_bug.cgi?id=171713
+        <rdar://problem/29829930>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Commands that use WebCookieManager directly should complete when
+        the manager's completion handler is called. Otherwise, this will race
+        with subsequent accesses to cookies via the web process (document.cookie).
+
+        Also, these commands need to use the active browsing context's session ID.
+        They currently use the process pool's storage session, which is wrong
+        since we specially configure automation instances with an ephemeral store.
+
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::addSingleCookie):
+        (WebKit::WebAutomationSession::deleteAllCookies):
+
 2017-05-05  Chris Dumez  <[email protected]>
 
         Rename webProcessDidCrashWithReason callback to webProcessDidTerminate and stop calling webProcessDidCrash for client terminations

Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (216260 => 216261)


--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp	2017-05-05 19:26:35 UTC (rev 216260)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp	2017-05-05 19:31:21 UTC (rev 216261)
@@ -819,9 +819,12 @@
 
     // FIXME: Using activeURL here twice is basically saying "this is always in the context of the main document"
     // which probably isn't accurate.
-    cookieManager->setCookies(WebCore::SessionID::defaultSessionID(), { cookie }, activeURL, activeURL, [](CallbackBase::Error){});
-
-    callback->sendSuccess();
+    cookieManager->setCookies(page->websiteDataStore().sessionID(), { cookie }, activeURL, activeURL, [callback = callback.copyRef()](CallbackBase::Error error) {
+        if (error == CallbackBase::Error::None)
+            callback->sendSuccess();
+        else
+            callback->sendFailure(STRING_FOR_PREDEFINED_ERROR_NAME(InternalError));
+    });
 }
 
 void WebAutomationSession::deleteAllCookies(ErrorString& errorString, const String& browsingContextHandle)
@@ -834,7 +837,7 @@
     ASSERT(activeURL.isValid());
 
     WebCookieManagerProxy* cookieManager = m_processPool->supplement<WebCookieManagerProxy>();
-    cookieManager->deleteCookiesForHostname(WebCore::SessionID::defaultSessionID(), activeURL.host());
+    cookieManager->deleteCookiesForHostname(page->websiteDataStore().sessionID(), activeURL.host());
 }
 
 #if USE(APPKIT) || PLATFORM(GTK)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to