Changeset 249575 in webkit


Ignore:
Timestamp:
Sep 6, 2019 9:19:50 AM (5 years ago)
Author:
achristensen@apple.com
Message:

When disabling legacy private browsing for testing, change the SessionID back to what it was, not the defaultSessionID
https://bugs.webkit.org/show_bug.cgi?id=201480

Reviewed by Youenn Fablet.

Source/WebCore:

No change in behavior, but this blocks bug 200050 which will make WebKitTestRunner use a persistent, non-default session.
Without this change, that change causes lots of test failures because we are switching from the legacy private browsing session
to the default session instead of the session we were using.

  • page/Page.cpp:

(WebCore::Page::enableLegacyPrivateBrowsing): Deleted.

  • page/Page.h:
  • page/PageGroup.cpp:

(WebCore::PageGroup::addPage):
(WebCore::PageGroup::setSessionIDForTesting):
(WebCore::PageGroup::enableLegacyPrivateBrowsingForTesting): Deleted.

  • page/PageGroup.h:
  • storage/StorageNamespaceProvider.cpp:

(WebCore::StorageNamespaceProvider::setSessionIDForTesting):
(WebCore::StorageNamespaceProvider::enableLegacyPrivateBrowsingForTesting): Deleted.

  • storage/StorageNamespaceProvider.h:

Source/WebKit:

  • WebProcess/InjectedBundle/InjectedBundle.cpp:

(WebKit::InjectedBundle::setPrivateBrowsingEnabled):

  • WebProcess/InjectedBundle/InjectedBundle.h:

Source/WebKitLegacy/mac:

  • WebView/WebView.mm:

(-[WebView _preferencesChanged:]):

Source/WebKitLegacy/win:

  • WebView.cpp:

(WebView::notifyPreferencesChanged):

Tools:

  • WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:

(WTR::InjectedBundle::beginTesting):

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setPrivateBrowsingEnabled):

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r249574 r249575  
     12019-09-06  Alex Christensen  <achristensen@webkit.org>
     2
     3        When disabling legacy private browsing for testing, change the SessionID back to what it was, not the defaultSessionID
     4        https://bugs.webkit.org/show_bug.cgi?id=201480
     5
     6        Reviewed by Youenn Fablet.
     7
     8        No change in behavior, but this blocks bug 200050 which will make WebKitTestRunner use a persistent, non-default session.
     9        Without this change, that change causes lots of test failures because we are switching from the legacy private browsing session
     10        to the default session instead of the session we were using.
     11
     12        * page/Page.cpp:
     13        (WebCore::Page::enableLegacyPrivateBrowsing): Deleted.
     14        * page/Page.h:
     15        * page/PageGroup.cpp:
     16        (WebCore::PageGroup::addPage):
     17        (WebCore::PageGroup::setSessionIDForTesting):
     18        (WebCore::PageGroup::enableLegacyPrivateBrowsingForTesting): Deleted.
     19        * page/PageGroup.h:
     20        * storage/StorageNamespaceProvider.cpp:
     21        (WebCore::StorageNamespaceProvider::setSessionIDForTesting):
     22        (WebCore::StorageNamespaceProvider::enableLegacyPrivateBrowsingForTesting): Deleted.
     23        * storage/StorageNamespaceProvider.h:
     24
    1252019-09-06  Youenn Fablet  <youenn@apple.com>
    226
  • trunk/Source/WebCore/page/Page.cpp

    r248846 r249575  
    16771677}
    16781678
    1679 void Page::enableLegacyPrivateBrowsing(bool privateBrowsingEnabled)
    1680 {
    1681     // Don't allow changing the legacy private browsing state if we have set a session ID.
    1682     ASSERT(m_sessionID == PAL::SessionID::defaultSessionID() || m_sessionID == PAL::SessionID::legacyPrivateSessionID());
    1683 
    1684     setSessionID(privateBrowsingEnabled ? PAL::SessionID::legacyPrivateSessionID() : PAL::SessionID::defaultSessionID());
    1685 }
    1686 
    16871679void Page::updateIsPlayingMedia(uint64_t sourceElementID)
    16881680{
  • trunk/Source/WebCore/page/Page.h

    r248734 r249575  
    608608    WEBCORE_EXPORT PAL::SessionID sessionID() const;
    609609    WEBCORE_EXPORT void setSessionID(PAL::SessionID);
    610     WEBCORE_EXPORT void enableLegacyPrivateBrowsing(bool privateBrowsingEnabled);
    611610    bool usesEphemeralSession() const { return m_sessionID.isEphemeral(); }
    612611
  • trunk/Source/WebCore/page/PageGroup.cpp

    r248846 r249575  
    9696   
    9797    if (m_isLegacyPrivateBrowsingEnabledForTesting)
    98         page.enableLegacyPrivateBrowsing(true);
     98        page.setSessionID(PAL::SessionID::legacyPrivateSessionID());
    9999}
    100100
     
    127127#endif
    128128
    129 void PageGroup::enableLegacyPrivateBrowsingForTesting(bool enabled)
     129void PageGroup::setSessionIDForTesting(const PAL::SessionID& sessionID)
    130130{
    131     if (m_isLegacyPrivateBrowsingEnabledForTesting == enabled)
     131    bool legacyPrivate = sessionID == PAL::SessionID::legacyPrivateSessionID();
     132    if (m_isLegacyPrivateBrowsingEnabledForTesting == legacyPrivate)
    132133        return;
    133134
    134     m_isLegacyPrivateBrowsingEnabledForTesting = enabled;
     135    m_isLegacyPrivateBrowsingEnabledForTesting = legacyPrivate;
    135136   
    136137    for (auto* page : m_pages)
    137         page->enableLegacyPrivateBrowsing(enabled);
     138        page->setSessionID(sessionID);
    138139}
    139140
  • trunk/Source/WebCore/page/PageGroup.h

    r247283 r249575  
    3030#include <wtf/text/WTFString.h>
    3131
     32namespace PAL {
     33class SessionID;
     34}
     35
    3236namespace WebCore {
    3337
     
    5963#endif
    6064
    61     WEBCORE_EXPORT void enableLegacyPrivateBrowsingForTesting(bool);
     65    WEBCORE_EXPORT void setSessionIDForTesting(const PAL::SessionID&);
    6266
    6367private:
  • trunk/Source/WebCore/storage/StorageNamespaceProvider.cpp

    r248734 r249575  
    8383}
    8484
    85 void StorageNamespaceProvider::enableLegacyPrivateBrowsingForTesting(bool enabled)
     85void StorageNamespaceProvider::setSessionIDForTesting(const PAL::SessionID& newSessionID)
    8686{
    87     auto newSessionID = enabled ? PAL::SessionID::legacyPrivateSessionID() : PAL::SessionID::defaultSessionID();
    8887    if (m_localStorageNamespace && newSessionID != m_localStorageNamespace->sessionID())
    8988        m_localStorageNamespace->setSessionIDForTesting(newSessionID);
  • trunk/Source/WebCore/storage/StorageNamespaceProvider.h

    r248734 r249575  
    5353    Ref<StorageArea> localStorageArea(Document&);
    5454
    55     WEBCORE_EXPORT void enableLegacyPrivateBrowsingForTesting(bool enabled);
     55    WEBCORE_EXPORT void setSessionIDForTesting(const PAL::SessionID&);
    5656
    5757protected:
  • trunk/Source/WebKit/ChangeLog

    r249569 r249575  
     12019-09-06  Alex Christensen  <achristensen@webkit.org>
     2
     3        When disabling legacy private browsing for testing, change the SessionID back to what it was, not the defaultSessionID
     4        https://bugs.webkit.org/show_bug.cgi?id=201480
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * WebProcess/InjectedBundle/InjectedBundle.cpp:
     9        (WebKit::InjectedBundle::setPrivateBrowsingEnabled):
     10        * WebProcess/InjectedBundle/InjectedBundle.h:
     11
    1122019-09-06  Patrick Griffis  <pgriffis@igalia.com>
    213
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp

    r248846 r249575  
    167167}
    168168
    169 void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, bool enabled)
    170 {
    171     WebKit::toImpl(bundleRef)->setPrivateBrowsingEnabled(WebKit::toImpl(pageGroupRef), enabled);
     169void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundleRef, WKBundlePageGroupRef pageGroupRef, WKBundlePageRef pageRef, bool enabled)
     170{
     171    WebKit::toImpl(bundleRef)->setPrivateBrowsingEnabled(WebKit::toImpl(pageGroupRef), WebKit::toImpl(pageRef), enabled);
    172172}
    173173
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h

    r246285 r249575  
    5050WK_EXPORT void WKBundleSetFrameFlatteningEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    5151WK_EXPORT void WKBundleSetJavaScriptCanAccessClipboard(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    52 WK_EXPORT void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
     52WK_EXPORT void WKBundleSetPrivateBrowsingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, WKBundlePageRef pageRef, bool enabled);
    5353WK_EXPORT void WKBundleSetPopupBlockingEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
    5454WK_EXPORT void WKBundleSetAuthorAndUserStylesEnabled(WKBundleRef bundle, WKBundlePageGroupRef pageGroup, bool enabled);
  • trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.cpp

    r249354 r249575  
    347347}
    348348
    349 void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, bool enabled)
     349void InjectedBundle::setPrivateBrowsingEnabled(WebPageGroupProxy* pageGroup, WebPage* page, bool enabled)
    350350{
    351351    ASSERT(!hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
    352     if (enabled)
     352
     353    PAL::SessionID newSessionID = PAL::SessionID::legacyPrivateSessionID();
     354    if (enabled) {
     355        auto currentSessionID = page->corePage()->sessionID();
     356        if (currentSessionID == PAL::SessionID::legacyPrivateSessionID())
     357            return;
     358        m_initialSessionID = currentSessionID;
    353359        WebProcess::singleton().ensureLegacyPrivateBrowsingSessionInNetworkProcess();
    354 
    355     PageGroup::pageGroup(pageGroup->identifier())->enableLegacyPrivateBrowsingForTesting(enabled);
     360    } else {
     361        if (!m_initialSessionID)
     362            return;
     363        newSessionID = *std::exchange(m_initialSessionID, WTF::nullopt);
     364    }
     365
     366    PageGroup::pageGroup(pageGroup->identifier())->setSessionIDForTesting(newSessionID);
    356367
    357368    auto webStorageNameSpaceProvider = WebStorageNamespaceProvider::getOrCreate(*pageGroup);
    358     webStorageNameSpaceProvider->enableLegacyPrivateBrowsingForTesting(enabled);
     369    webStorageNameSpaceProvider->setSessionIDForTesting(newSessionID);
    359370}
    360371
  • trunk/Source/WebKit/WebProcess/InjectedBundle/InjectedBundle.h

    r246285 r249575  
    3232#include <WebCore/UserContentTypes.h>
    3333#include <WebCore/UserScriptTypes.h>
     34#include <pal/SessionID.h>
    3435#include <wtf/RefPtr.h>
    3536#include <wtf/RetainPtr.h>
     
    105106    void setPluginsEnabled(WebPageGroupProxy*, bool);
    106107    void setJavaScriptCanAccessClipboard(WebPageGroupProxy*, bool);
    107     void setPrivateBrowsingEnabled(WebPageGroupProxy*, bool);
     108    void setPrivateBrowsingEnabled(WebPageGroupProxy*, WebPage*, bool);
    108109    void setPopupBlockingEnabled(WebPageGroupProxy*, bool);
    109110    void setAuthorAndUserStylesEnabled(WebPageGroupProxy*, bool);
     
    174175    std::unique_ptr<API::InjectedBundle::Client> m_client;
    175176
     177    Optional<PAL::SessionID> m_initialSessionID;
     178
    176179#if PLATFORM(COCOA)
    177180    RetainPtr<WKWebProcessBundleParameters> m_bundleParameters;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r249571 r249575  
     12019-09-06  Alex Christensen  <achristensen@webkit.org>
     2
     3        When disabling legacy private browsing for testing, change the SessionID back to what it was, not the defaultSessionID
     4        https://bugs.webkit.org/show_bug.cgi?id=201480
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * WebView/WebView.mm:
     9        (-[WebView _preferencesChanged:]):
     10
    1112019-09-06  Rob Buis  <rbuis@igalia.com>
    212
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r249571 r249575  
    28892889    settings.setLocalStorageEnabled([preferences localStorageEnabled]);
    28902890
    2891     _private->page->enableLegacyPrivateBrowsing([preferences privateBrowsingEnabled]);
    2892     _private->group->storageNamespaceProvider().enableLegacyPrivateBrowsingForTesting([preferences privateBrowsingEnabled]);
     2891    _private->page->setSessionID([preferences privateBrowsingEnabled] ? PAL::SessionID::legacyPrivateSessionID() : PAL::SessionID::defaultSessionID());
     2892    _private->group->storageNamespaceProvider().setSessionIDForTesting([preferences privateBrowsingEnabled] ? PAL::SessionID::legacyPrivateSessionID() : PAL::SessionID::defaultSessionID());
    28932893    settings.setSansSerifFontFamily([preferences sansSerifFontFamily]);
    28942894    settings.setSerifFontFamily([preferences serifFontFamily]);
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r249571 r249575  
     12019-09-06  Alex Christensen  <achristensen@webkit.org>
     2
     3        When disabling legacy private browsing for testing, change the SessionID back to what it was, not the defaultSessionID
     4        https://bugs.webkit.org/show_bug.cgi?id=201480
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * WebView.cpp:
     9        (WebView::notifyPreferencesChanged):
     10
    1112019-09-06  Rob Buis  <rbuis@igalia.com>
    212
  • trunk/Source/WebKitLegacy/win/WebView.cpp

    r249571 r249575  
    53085308        WebFrameNetworkingContext::destroyPrivateBrowsingSession();
    53095309#endif
    5310     m_page->enableLegacyPrivateBrowsing(!!enabled);
     5310    m_page->setSessionID(!!enabled ? PAL::SessionID::legacyPrivateSessionID() : PAL::SessionID::defaultSessionID());
    53115311
    53125312    hr = preferences->sansSerifFontFamily(&str);
  • trunk/Tools/ChangeLog

    r249571 r249575  
     12019-09-06  Alex Christensen  <achristensen@webkit.org>
     2
     3        When disabling legacy private browsing for testing, change the SessionID back to what it was, not the defaultSessionID
     4        https://bugs.webkit.org/show_bug.cgi?id=201480
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     9        (WTR::InjectedBundle::beginTesting):
     10        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     11        (WTR::TestRunner::setPrivateBrowsingEnabled):
     12
    1132019-09-06  Rob Buis  <rbuis@igalia.com>
    214
  • trunk/Tools/TestWebKitAPI/glib/CMakeLists.txt

    r246039 r249575  
    88
    99set(WebKitGLibAPITests_INCLUDE_DIRECTORIES
    10     ${CMAKE_SOURCE_DIR}/Source
    11     ${CMAKE_SOURCE_DIR}/Source/WTF
    1210    ${FORWARDING_HEADERS_DIR}
    1311    ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGLib
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r249557 r249575  
    498498    WKBundleSetAllowUniversalAccessFromFileURLs(m_bundle, m_pageGroup, true);
    499499    WKBundleSetJavaScriptCanAccessClipboard(m_bundle, m_pageGroup, true);
    500     WKBundleSetPrivateBrowsingEnabled(m_bundle, m_pageGroup, false);
     500    WKBundleSetPrivateBrowsingEnabled(m_bundle, m_pageGroup, page()->page(), false);
    501501    WKBundleSetAuthorAndUserStylesEnabled(m_bundle, m_pageGroup, true);
    502502    WKBundleSetFrameFlatteningEnabled(m_bundle, m_pageGroup, false);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r249542 r249575  
    535535{
    536536    auto& injectedBundle = InjectedBundle::singleton();
    537     WKBundleSetPrivateBrowsingEnabled(injectedBundle.bundle(), injectedBundle.pageGroup(), enabled);
     537    WKBundleSetPrivateBrowsingEnabled(injectedBundle.bundle(), injectedBundle.pageGroup(), injectedBundle.page()->page(), enabled);
    538538}
    539539
Note: See TracChangeset for help on using the changeset viewer.