Title: [245930] branches/safari-607-branch/Source/WebKit

Diff

Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (245929 => 245930)


--- branches/safari-607-branch/Source/WebKit/ChangeLog	2019-05-31 00:30:25 UTC (rev 245929)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog	2019-05-31 00:30:28 UTC (rev 245930)
@@ -1,5 +1,41 @@
 2019-05-30  Kocsen Chung  <[email protected]>
 
+        Apply patch. rdar://problem/50857668
+
+    2019-05-30  Chris Dumez  <[email protected]>
+
+            TestWebKitAPI.ProcessSwap.UseSessionCookiesAfterProcessSwapInNonDefaultPersistentSession is failing on safari-607-branch
+            <rdar://problem/49980530>
+
+            Reviewed by Brady Eidson.
+
+            On the safari-607-branch banch, we need to send a WebProcess::AddWebsiteDataStore() IPC to the WebContent
+            process before it does any load for a non-default data store. If we fail to do so then the WebContent
+            process will fall back to using the default session for the loads.
+
+            This is what was happening for this API test. The cookie was getting set for session 2 but then it
+            would later try to read the cookie from session 1 (default one) after the process swap, and would
+            thus fail to get the cookie it expected.
+
+            The issue was that we would send the WebProcess::AddWebsiteDataStore() IPC too late, when committing
+            the provisional process (in WebPageProxy::swapToWebProcess()). By this point, the provisional load
+            would have already started in the provisional process and used the wrong session. To address the issue,
+            we now send the WebProcess::AddWebsiteDataStore() IPC as soon as we create the ProvisionalPageProxy.
+
+            * UIProcess/WebProcessProxy.cpp:
+            (WebKit::WebProcessProxy::sendPageDataStore):
+            (WebKit::WebProcessProxy::addProvisionalPageProxy):
+            (WebKit::WebProcessProxy::removeProvisionalPageProxy):
+            (WebKit::WebProcessProxy::addExistingWebPage):
+            (WebKit::WebProcessProxy::removeWebPage):
+            (WebKit::WebProcessProxy::destroyDataStoreIfUnused):
+            (WebKit::WebProcessProxy::hasPageUsingSession const):
+            * UIProcess/WebProcessProxy.h:
+            (WebKit::WebProcessProxy::addProvisionalPageProxy): Deleted.
+            (WebKit::WebProcessProxy::removeProvisionalPageProxy): Deleted.
+
+2019-05-30  Kocsen Chung  <[email protected]>
+
         Cherry-pick r245284. rdar://problem/51264857
 
     Protect current WebFrame during form submission

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp (245929 => 245930)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp	2019-05-31 00:30:25 UTC (rev 245929)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp	2019-05-31 00:30:28 UTC (rev 245930)
@@ -456,6 +456,31 @@
     return webPage;
 }
 
+void WebProcessProxy::sendPageDataStore(WebPageProxy& webPage)
+{
+    auto sessionID = webPage.sessionID();
+    if (sessionID.isEphemeral())
+        send(Messages::WebProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::privateSessionParameters(sessionID)), 0);
+    else if (sessionID != PAL::SessionID::defaultSessionID())
+        send(Messages::WebProcess::AddWebsiteDataStore(webPage.websiteDataStore().parameters()), 0);
+}
+
+void WebProcessProxy::addProvisionalPageProxy(ProvisionalPageProxy& provisionalPage)
+{
+    ASSERT(!m_provisionalPages.contains(&provisionalPage));
+    m_provisionalPages.add(&provisionalPage);
+
+    sendPageDataStore(provisionalPage.page());
+}
+
+void WebProcessProxy::removeProvisionalPageProxy(ProvisionalPageProxy& provisionalPage)
+{
+    ASSERT(m_provisionalPages.contains(&provisionalPage));
+    m_provisionalPages.remove(&provisionalPage);
+
+    destroyDataStoreIfUnused(provisionalPage.page().sessionID());
+}
+
 void WebProcessProxy::addExistingWebPage(WebPageProxy& webPage, uint64_t pageID, BeginsUsingDataStore beginsUsingDataStore)
 {
     ASSERT(!m_pageMap.contains(pageID));
@@ -465,11 +490,7 @@
     if (beginsUsingDataStore == BeginsUsingDataStore::Yes)
         m_processPool->pageBeginUsingWebsiteDataStore(webPage);
 
-    auto sessionID = webPage.sessionID();
-    if (sessionID.isEphemeral())
-        send(Messages::WebProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::privateSessionParameters(sessionID)), 0);
-    else if (sessionID != PAL::SessionID::defaultSessionID())
-        send(Messages::WebProcess::AddWebsiteDataStore(webPage.websiteDataStore().parameters()), 0);
+    sendPageDataStore(webPage);
 
     m_pageMap.set(pageID, &webPage);
     globalPageMap().set(pageID, &webPage);
@@ -498,9 +519,7 @@
     if (endsUsingDataStore == EndsUsingDataStore::Yes)
         m_processPool->pageEndUsingWebsiteDataStore(webPage);
 
-    auto sessionID = webPage.sessionID();
-    if (sessionID != PAL::SessionID::defaultSessionID() && !hasPageUsingSession(sessionID))
-        send(Messages::WebProcess::DestroySession(sessionID), 0);
+    destroyDataStoreIfUnused(webPage.sessionID());
 
     updateBackgroundResponsivenessTimer();
 
@@ -507,6 +526,12 @@
     maybeShutDown();
 }
 
+void WebProcessProxy::destroyDataStoreIfUnused(PAL::SessionID sessionID)
+{
+    if (sessionID != PAL::SessionID::defaultSessionID() && !hasPageUsingSession(sessionID))
+        send(Messages::WebProcess::DestroySession(sessionID), 0);
+}
+
 bool WebProcessProxy::hasPageUsingSession(PAL::SessionID sessionID) const
 {
     for (auto& page : m_pageMap.values()) {
@@ -513,6 +538,10 @@
         if (page->sessionID() == sessionID)
             return true;
     }
+    for (auto* provisionalPage : m_provisionalPages) {
+        if (provisionalPage->page().sessionID() == sessionID)
+            return true;
+    }
     return false;
 }
 

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.h (245929 => 245930)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.h	2019-05-31 00:30:25 UTC (rev 245929)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.h	2019-05-31 00:30:28 UTC (rev 245930)
@@ -132,8 +132,8 @@
     enum class EndsUsingDataStore : bool { No, Yes };
     void removeWebPage(WebPageProxy&, uint64_t pageID, EndsUsingDataStore);
 
-    void addProvisionalPageProxy(ProvisionalPageProxy& provisionalPage) { ASSERT(!m_provisionalPages.contains(&provisionalPage)); m_provisionalPages.add(&provisionalPage); }
-    void removeProvisionalPageProxy(ProvisionalPageProxy& provisionalPage) { ASSERT(m_provisionalPages.contains(&provisionalPage)); m_provisionalPages.remove(&provisionalPage); }
+    void addProvisionalPageProxy(ProvisionalPageProxy&);
+    void removeProvisionalPageProxy(ProvisionalPageProxy&);
 
     typename WebPageProxyMap::ValuesConstIteratorRange pages() const { return m_pageMap.values(); }
     unsigned pageCount() const { return m_pageMap.size(); }
@@ -283,6 +283,9 @@
     void didDestroyFrame(uint64_t);
     void didDestroyUserGestureToken(uint64_t);
 
+    void sendPageDataStore(WebPageProxy&);
+    void destroyDataStoreIfUnused(PAL::SessionID);
+
     bool canBeAddedToWebProcessCache() const;
     void shouldTerminate(bool& shouldTerminate);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to