Stop calling Page::setSessionID() from WebKit2
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Sep 2019 00:38:46 +0000 (00:38 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Sep 2019 00:38:46 +0000 (00:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201888

Patch by Chris Dumez <cdumez@apple.com> on 2019-09-17
Reviewed by Alex Christensen.

Stop calling Page::setSessionID() from WebKit2 since Page's sessionID can never change when
using WebKit2 (We process-swap and create a new Page in a new process when changing data
store). Instead, we now pass the sessionID ID when constructing the Page, as part of the
PageConfiguration structure.

Source/WebCore:

* editing/markup.cpp:
(WebCore::createPageForSanitizingWebContent):
* loader/EmptyClients.cpp:
(WebCore::pageConfigurationWithEmptyClients):
* loader/EmptyClients.h:
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::setSessionID):
* page/PageConfiguration.cpp:
(WebCore::PageConfiguration::PageConfiguration):
* page/PageConfiguration.h:
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::dataChanged):
* workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::createPageForServiceWorker):
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):

Source/WebKit:

* Shared/WebsitePoliciesData.cpp:
(WebKit::WebsitePoliciesData::applyToDocumentLoader):
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::installServiceWorker):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_textAutoSizingAdjustmentTimer):
(WebKit::WebPage::setSessionID): Deleted.
* WebProcess/WebPage/WebPage.h:

Source/WebKitLegacy/mac:

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250006 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/markup.cpp
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/PageConfiguration.cpp
Source/WebCore/page/PageConfiguration.h
Source/WebCore/page/PerformanceObserver.idl
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebsitePoliciesData.cpp
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/win/WebView.cpp

index 98405f1..aaf8fa4 100644 (file)
@@ -1,3 +1,32 @@
+2019-09-17  Chris Dumez  <cdumez@apple.com>
+
+        Stop calling Page::setSessionID() from WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=201888
+
+        Reviewed by Alex Christensen.
+
+        Stop calling Page::setSessionID() from WebKit2 since Page's sessionID can never change when
+        using WebKit2 (We process-swap and create a new Page in a new process when changing data
+        store). Instead, we now pass the sessionID ID when constructing the Page, as part of the
+        PageConfiguration structure.
+
+        * editing/markup.cpp:
+        (WebCore::createPageForSanitizingWebContent):
+        * loader/EmptyClients.cpp:
+        (WebCore::pageConfigurationWithEmptyClients):
+        * loader/EmptyClients.h:
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        (WebCore::Page::setSessionID):
+        * page/PageConfiguration.cpp:
+        (WebCore::PageConfiguration::PageConfiguration):
+        * page/PageConfiguration.h:
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::dataChanged):
+        * workers/service/context/ServiceWorkerThreadProxy.cpp:
+        (WebCore::createPageForServiceWorker):
+        (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
+
 2019-09-17  Mark Lam  <mark.lam@apple.com>
 
         Use constexpr instead of const in symbol definitions that are obviously constexpr.
index 0882f1a..124a5ab 100644 (file)
@@ -176,7 +176,7 @@ void removeSubresourceURLAttributes(Ref<DocumentFragment>&& fragment, WTF::Funct
 
 std::unique_ptr<Page> createPageForSanitizingWebContent()
 {
-    auto pageConfiguration = pageConfigurationWithEmptyClients();
+    auto pageConfiguration = pageConfigurationWithEmptyClients(PAL::SessionID::defaultSessionID());
     
     auto page = makeUnique<Page>(WTFMove(pageConfiguration));
     page->setIsForSanitizingWebContent();
index 51f84d5..2f66385 100644 (file)
@@ -70,6 +70,7 @@
 #include "UserContentProvider.h"
 #include "VisitedLinkStore.h"
 #include <JavaScriptCore/HeapInlines.h>
+#include <pal/SessionID.h>
 #include <wtf/NeverDestroyed.h>
 
 #if ENABLE(CONTENT_EXTENSIONS)
@@ -547,9 +548,10 @@ class EmptyStorageSessionProvider : public StorageSessionProvider {
     NetworkStorageSession* storageSession() const final { return nullptr; }
 };
 
-PageConfiguration pageConfigurationWithEmptyClients()
+PageConfiguration pageConfigurationWithEmptyClients(PAL::SessionID sessionID)
 {
     PageConfiguration pageConfiguration {
+        sessionID,
         makeUniqueRef<EmptyEditorClient>(),
         SocketProvider::create(),
         LibWebRTCProvider::create(),
index d639396..617a161 100644 (file)
@@ -204,6 +204,6 @@ class EmptyChromeClient : public ChromeClient {
 };
 
 DiagnosticLoggingClient& emptyDiagnosticLoggingClient();
-WEBCORE_EXPORT PageConfiguration pageConfigurationWithEmptyClients();
+WEBCORE_EXPORT PageConfiguration pageConfigurationWithEmptyClients(PAL::SessionID);
 
 }
index 1dce5d8..4538773 100644 (file)
@@ -263,7 +263,7 @@ Page::Page(PageConfiguration&& pageConfiguration)
     , m_storageNamespaceProvider(*WTFMove(pageConfiguration.storageNamespaceProvider))
     , m_userContentProvider(*WTFMove(pageConfiguration.userContentProvider))
     , m_visitedLinkStore(*WTFMove(pageConfiguration.visitedLinkStore))
-    , m_sessionID(PAL::SessionID::defaultSessionID())
+    , m_sessionID(pageConfiguration.sessionID)
 #if ENABLE(VIDEO)
     , m_playbackControlsManagerUpdateTimer(*this, &Page::playbackControlsManagerUpdateTimerFired)
 #endif
@@ -2466,9 +2466,12 @@ PAL::SessionID Page::sessionID() const
     return m_sessionID;
 }
 
+// This is only called by WebKitLegacy.
 void Page::setSessionID(PAL::SessionID sessionID)
 {
     ASSERT(sessionID.isValid());
+    ASSERT(m_sessionID == PAL::SessionID::legacyPrivateSessionID() || m_sessionID == PAL::SessionID::defaultSessionID());
+    ASSERT(sessionID == PAL::SessionID::legacyPrivateSessionID() || sessionID == PAL::SessionID::defaultSessionID());
 
 #if ENABLE(INDEXED_DATABASE)
     if (sessionID != m_sessionID)
index dbbaa29..2d33d76 100644 (file)
@@ -51,8 +51,9 @@
 
 namespace WebCore {
 
-PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider, Ref<BackForwardClient>&& backForwardClient, Ref<CookieJar>&& cookieJar)
-    : editorClient(WTFMove(editorClient))
+PageConfiguration::PageConfiguration(PAL::SessionID sessionID, UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider, Ref<BackForwardClient>&& backForwardClient, Ref<CookieJar>&& cookieJar)
+    : sessionID(sessionID)
+    , editorClient(WTFMove(editorClient))
     , socketProvider(WTFMove(socketProvider))
     , libWebRTCProvider(WTFMove(libWebRTCProvider))
     , backForwardClient(WTFMove(backForwardClient))
index 07f5e16..e5d7aaa 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include <pal/SessionID.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/Optional.h>
 #include <wtf/RefPtr.h>
@@ -67,10 +68,11 @@ class SpeechSynthesisClient;
 class PageConfiguration {
     WTF_MAKE_NONCOPYABLE(PageConfiguration); WTF_MAKE_FAST_ALLOCATED;
 public:
-    WEBCORE_EXPORT PageConfiguration(UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&, Ref<BackForwardClient>&&, Ref<CookieJar>&&);
+    WEBCORE_EXPORT PageConfiguration(PAL::SessionID, UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&, Ref<BackForwardClient>&&, Ref<CookieJar>&&);
     WEBCORE_EXPORT ~PageConfiguration();
     PageConfiguration(PageConfiguration&&);
 
+    PAL::SessionID sessionID;
     AlternativeTextClient* alternativeTextClient { nullptr };
     ChromeClient* chromeClient { nullptr };
 #if ENABLE(CONTEXT_MENUS)
index 87ede75..2cf95d0 100644 (file)
@@ -36,7 +36,7 @@
 ] interface PerformanceObserver {
     [MayThrowException] void observe(PerformanceObserverInit options);
     void disconnect();
-    static readonly attribute FrozenArray<DOMString> supportedEntryTypes;
+    [CachedAttribute] static readonly attribute FrozenArray<DOMString> supportedEntryTypes;
 };
 
 dictionary PerformanceObserverInit {
index f6ddf1b..693cb34 100644 (file)
@@ -467,7 +467,7 @@ EncodedDataStatus SVGImage::dataChanged(bool allDataReceived)
         return EncodedDataStatus::Complete;
 
     if (allDataReceived) {
-        auto pageConfiguration = pageConfigurationWithEmptyClients();
+        auto pageConfiguration = pageConfigurationWithEmptyClients(PAL::SessionID::defaultSessionID());
         m_chromeClient = makeUnique<SVGImageChromeClient>(this);
         pageConfiguration.chromeClient = m_chromeClient.get();
 
index 9e728c3..61745a7 100644 (file)
@@ -54,10 +54,9 @@ URL static inline topOriginURL(const SecurityOrigin& origin)
     return url;
 }
 
-static inline UniqueRef<Page> createPageForServiceWorker(PageConfiguration&& configuration, const ServiceWorkerContextData& data, SecurityOrigin::StorageBlockingPolicy storageBlockingPolicy, PAL::SessionID sessionID)
+static inline UniqueRef<Page> createPageForServiceWorker(PageConfiguration&& configuration, const ServiceWorkerContextData& data, SecurityOrigin::StorageBlockingPolicy storageBlockingPolicy)
 {
     auto page = makeUniqueRef<Page>(WTFMove(configuration));
-    page->setSessionID(sessionID);
 
     auto& mainFrame = page->mainFrame();
     mainFrame.loader().initForSynthesizedDocument({ });
@@ -97,7 +96,7 @@ static HashSet<ServiceWorkerThreadProxy*>& allServiceWorkerThreadProxies()
 }
 
 ServiceWorkerThreadProxy::ServiceWorkerThreadProxy(PageConfiguration&& pageConfiguration, const ServiceWorkerContextData& data, PAL::SessionID sessionID, String&& userAgent, CacheStorageProvider& cacheStorageProvider, SecurityOrigin::StorageBlockingPolicy storageBlockingPolicy)
-    : m_page(createPageForServiceWorker(WTFMove(pageConfiguration), data, storageBlockingPolicy, data.sessionID))
+    : m_page(createPageForServiceWorker(WTFMove(pageConfiguration), data, storageBlockingPolicy))
     , m_document(*m_page->mainFrame().document())
     , m_serviceWorkerThread(ServiceWorkerThread::create(data, sessionID, WTFMove(userAgent), *this, *this, idbConnectionProxy(m_document), m_document->socketProvider()))
     , m_cacheStorageProvider(cacheStorageProvider)
index 294557f..193dd22 100644 (file)
@@ -1,3 +1,24 @@
+2019-09-17  Chris Dumez  <cdumez@apple.com>
+
+        Stop calling Page::setSessionID() from WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=201888
+
+        Reviewed by Alex Christensen.
+
+        Stop calling Page::setSessionID() from WebKit2 since Page's sessionID can never change when
+        using WebKit2 (We process-swap and create a new Page in a new process when changing data
+        store). Instead, we now pass the sessionID ID when constructing the Page, as part of the
+        PageConfiguration structure.
+
+        * Shared/WebsitePoliciesData.cpp:
+        (WebKit::WebsitePoliciesData::applyToDocumentLoader):
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::installServiceWorker):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_textAutoSizingAdjustmentTimer):
+        (WebKit::WebPage::setSessionID): Deleted.
+        * WebProcess/WebPage/WebPage.h:
+
 2019-09-17  Mark Lam  <mark.lam@apple.com>
 
         Use constexpr instead of const in symbol definitions that are obviously constexpr.
index 3a06056..a21cc95 100644 (file)
@@ -270,13 +270,6 @@ void WebsitePoliciesData::applyToDocumentLoader(WebsitePoliciesData&& websitePol
         return;
 
     documentLoader.applyPoliciesToSettings();
-
-    auto* page = frame->page();
-    if (!page)
-        return;
-
-    if (websitePolicies.websiteDataStoreParameters)
-        page->setSessionID(websitePolicies.websiteDataStoreParameters->networkSessionParameters.sessionID);
 }
 
 }
index e633c77..d3e972c 100644 (file)
@@ -125,7 +125,7 @@ void WebSWContextManagerConnection::installServiceWorker(const ServiceWorkerCont
 {
     LOG(ServiceWorker, "WebSWContextManagerConnection::installServiceWorker for worker %s", data.serviceWorkerIdentifier.loggingString().utf8().data());
 
-    auto pageConfiguration = pageConfigurationWithEmptyClients();
+    auto pageConfiguration = pageConfigurationWithEmptyClients(WebProcess::singleton().sessionID());
 
 #if ENABLE(INDEXED_DATABASE)
     pageConfiguration.databaseProvider = WebDatabaseProvider::getOrCreate(m_pageGroupID);
index d430d09..029b24d 100644 (file)
@@ -443,6 +443,7 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
 #endif
 
     PageConfiguration pageConfiguration(
+        WebProcess::singleton().sessionID(),
         makeUniqueRef<WebEditorClient>(this),
         WebSocketProvider::create(),
         makeUniqueRef<WebKit::LibWebRTCProvider>(),
@@ -503,8 +504,6 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
 
     m_page = makeUnique<Page>(WTFMove(pageConfiguration));
 
-    setSessionID(WebProcess::singleton().sessionID());
-
     updatePreferences(parameters.store);
 
     m_backgroundColor = parameters.backgroundColor;
@@ -3200,11 +3199,6 @@ void WebPage::setLayerHostingMode(LayerHostingMode layerHostingMode)
         pluginView->setLayerHostingMode(m_layerHostingMode);
 }
 
-void WebPage::setSessionID(PAL::SessionID sessionID)
-{
-    m_page->setSessionID(sessionID);
-}
-
 void WebPage::didReceivePolicyDecision(FrameIdentifier frameID, uint64_t listenerID, PolicyCheckIdentifier identifier, PolicyAction policyAction, uint64_t navigationID, const DownloadID& downloadID, Optional<WebsitePoliciesData>&& websitePolicies)
 {
     WebFrame* frame = WebProcess::singleton().webFrame(frameID);
index 4428f3a..3a7d6e9 100644 (file)
@@ -296,8 +296,6 @@ public:
     PAL::SessionID sessionID() const { return m_page->sessionID(); }
     bool usesEphemeralSession() const { return m_page->usesEphemeralSession(); }
 
-    void setSessionID(PAL::SessionID);
-
     void setSize(const WebCore::IntSize&);
     const WebCore::IntSize& size() const { return m_viewSize; }
     WebCore::IntRect bounds() const { return WebCore::IntRect(WebCore::IntPoint(), size()); }
index 4b7a27f..db3e2ae 100644 (file)
@@ -1,3 +1,18 @@
+2019-09-17  Chris Dumez  <cdumez@apple.com>
+
+        Stop calling Page::setSessionID() from WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=201888
+
+        Reviewed by Alex Christensen.
+
+        Stop calling Page::setSessionID() from WebKit2 since Page's sessionID can never change when
+        using WebKit2 (We process-swap and create a new Page in a new process when changing data
+        store). Instead, we now pass the sessionID ID when constructing the Page, as part of the
+        PageConfiguration structure.
+
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+
 2019-09-09  Alex Christensen  <achristensen@webkit.org>
 
         Disable TLS 1.0 and 1.1 in WebSockets
index 96da6a4..5e7f771 100644 (file)
@@ -1432,6 +1432,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
 
     auto storageProvider = PageStorageSessionProvider::create();
     PageConfiguration pageConfiguration(
+        [[self preferences] privateBrowsingEnabled] ? PAL::SessionID::legacyPrivateSessionID() : PAL::SessionID::defaultSessionID(),
         makeUniqueRef<WebEditorClient>(self),
         SocketProvider::create(),
         LibWebRTCProvider::create(),
@@ -1700,6 +1701,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
 
     auto storageProvider = PageStorageSessionProvider::create();
     PageConfiguration pageConfiguration(
+        [[self preferences] privateBrowsingEnabled] ? PAL::SessionID::legacyPrivateSessionID() : PAL::SessionID::defaultSessionID(),
         makeUniqueRef<WebEditorClient>(self),
         SocketProvider::create(),
         LibWebRTCProvider::create(),
index f3d8af4..d9a4210 100644 (file)
@@ -3101,6 +3101,7 @@ HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupN
 
     auto storageProvider = PageStorageSessionProvider::create();
     PageConfiguration configuration(
+        PAL::SessionID::defaultSessionID(),
         makeUniqueRef<WebEditorClient>(this),
         SocketProvider::create(),
         makeUniqueRef<LibWebRTCProvider>(),