Changeset 258884 in webkit


Ignore:
Timestamp:
Mar 23, 2020 4:00:50 PM (4 years ago)
Author:
wilander@apple.com
Message:

Add the capability to change all of a website's cookies to SameSite=Strict
https://bugs.webkit.org/show_bug.cgi?id=209369
<rdar://problem/60710690>

Reviewed by Alex Christensen and David Kilzer.

Source/WebCore:

Test: http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html

  • platform/network/NetworkStorageSession.cpp:

(WebCore::NetworkStorageSession::setAllCookiesToSameSiteStrict):

Stub function for non-Cocoa platforms.

  • platform/network/NetworkStorageSession.h:
  • platform/network/cocoa/NetworkStorageSessionCocoa.mm:

(WebCore::NetworkStorageSession::setAllCookiesToSameSiteStrict):

  • testing/Internals.h:

Added code to expose SameSite=None and path properties of cookies.
However, they don't seem to carry over so I'll have to revisit the
internal workings.

Source/WebKit:

These changes add test infrastructure to run function
WebCore::NetworkStorageSession::setAllCookiesToSameSiteStrict() in the
network process.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::setToSameSiteStrictCookiesForTesting):

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • UIProcess/API/C/WKWebsiteDataStoreRef.cpp:

(WKWebsiteDataStoreSetResourceLoadStatisticsToSameSiteStrictCookiesForTesting):

  • UIProcess/API/C/WKWebsiteDataStoreRef.h:
  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::setToSameSiteStrictCookiesForTesting):

  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::setResourceLoadStatisticsToSameSiteStrictCookiesForTesting):

  • UIProcess/WebsiteData/WebsiteDataStore.h:

Source/WTF:

  • wtf/PlatformHave.h:

Adds HAVE_CFNETWORK_SAMESITE_COOKIE_API for macOS Catalina and up,
iOS 13 and up, Catalyst, watchOS, and Apple TV.

Tools:

These changes add TestRunner function statisticsSetToSameSiteStrictCookies().

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:

(WTR::InjectedBundle::didReceiveMessageToPage):

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::statisticsSetToSameSiteStrictCookies):
(WTR::TestRunner::statisticsCallDidSetToSameSiteStrictCookiesCallback):

  • WebKitTestRunner/InjectedBundle/TestRunner.h:
  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::setStatisticsToSameSiteStrictCookies):

  • WebKitTestRunner/TestController.h:
  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
(WTR::TestInvocation::didSetToSameSiteStrictCookies):

  • WebKitTestRunner/TestInvocation.h:

LayoutTests:

  • http/tests/resourceLoadStatistics/resources/set-all-kinds-of-cookies.php: Added.
  • http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict-expected.txt: Added.
  • http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html: Added.
  • platform/ios/TestExpectations:

Marked http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html
as Pass.

  • platform/mac-wk2/TestExpectations:

Marked http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html
as Pass for Catalina+.

  • platform/wk2/TestExpectations:

Skipped http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html
since it's only available on macOS Catalina and up and the functionality is not
implemented on non-Cocoa platforms.

Location:
trunk
Files:
3 added
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r258881 r258884  
     12020-03-23  John Wilander  <wilander@apple.com>
     2
     3        Add the capability to change all of a website's cookies to SameSite=Strict
     4        https://bugs.webkit.org/show_bug.cgi?id=209369
     5        <rdar://problem/60710690>
     6
     7        Reviewed by Alex Christensen and David Kilzer.
     8
     9        * http/tests/resourceLoadStatistics/resources/set-all-kinds-of-cookies.php: Added.
     10        * http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict-expected.txt: Added.
     11        * http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html: Added.
     12        * platform/ios/TestExpectations:
     13            Marked http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html
     14            as Pass.
     15        * platform/mac-wk2/TestExpectations:
     16            Marked http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html
     17            as Pass for Catalina+.
     18        * platform/wk2/TestExpectations:
     19            Skipped http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html
     20            since it's only available on macOS Catalina and up and the functionality is not
     21            implemented on non-Cocoa platforms.
     22
    1232020-03-23  Jason Lawrence  <lawrence.j@apple.com>
    224
  • trunk/LayoutTests/platform/ios/TestExpectations

    r258880 r258884  
    27392739http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-third-party-redirects.html [ Pass ]
    27402740http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-third-party-requests.html [ Pass ]
     2741
     2742# The SameSite cookie API is only available in macOS Catalina and above, and thus skipped for WK2 in general.
     2743http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html [ Pass ]
     2744
    27412745http/tests/storageAccess/deny-storage-access-under-opener.html [ Pass ]
    27422746http/tests/storageAccess/deny-storage-access-under-opener-if-auto-dismiss.html [ Pass ]
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r258813 r258884  
    740740[ HighSierra+ ] http/tests/resourceLoadStatistics/cap-cache-max-age-for-prevalent-resource.html [ Pass ]
    741741
     742# The SameSite cookie API is only available in macOS Catalina and above.
     743[ Catalina+ ] http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html [ Pass ]
     744
    742745# Skipped in general expectations since they only work on iOS and Mac, WK2.
    743746media/deactivate-audio-session.html [ Pass ]
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r258150 r258884  
    733733http/tests/resourceLoadStatistics/prune-statistics.html [ Pass ]
    734734http/tests/resourceLoadStatistics [ Pass ]
     735
     736# The SameSite cookie API is only available in macOS Catalina and above.
     737http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html [ Skip ]
     738
    735739http/tests/websocket/connection-refusal-in-frame-resource-load-statistics.html [ Pass ]
    736740# These are only supported behind a compile time flag in macOS High Sierra + iOS 11, and above.
  • trunk/Source/WTF/ChangeLog

    r258869 r258884  
     12020-03-23  John Wilander  <wilander@apple.com>
     2
     3        Add the capability to change all of a website's cookies to SameSite=Strict
     4        https://bugs.webkit.org/show_bug.cgi?id=209369
     5        <rdar://problem/60710690>
     6
     7        Reviewed by Alex Christensen and David Kilzer.
     8
     9        * wtf/PlatformHave.h:
     10            Adds HAVE_CFNETWORK_SAMESITE_COOKIE_API for macOS Catalina and up,
     11            iOS 13 and up, Catalyst, watchOS, and Apple TV.
     12
    1132020-03-23  youenn fablet  <youenn@apple.com>
    214
  • trunk/Source/WTF/wtf/PlatformHave.h

    r258772 r258884  
    445445#endif
    446446
     447#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || PLATFORM(MACCATALYST) || PLATFORM(WATCHOS) || PLATFORM(APPLETV)
     448#define HAVE_CFNETWORK_SAMESITE_COOKIE_API 1
     449#endif
     450
    447451#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101600) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
    448452#define HAVE_CFNETWORK_METRICS_APIS_V4 1
  • trunk/Source/WebCore/ChangeLog

    r258883 r258884  
     12020-03-23  John Wilander  <wilander@apple.com>
     2
     3        Add the capability to change all of a website's cookies to SameSite=Strict
     4        https://bugs.webkit.org/show_bug.cgi?id=209369
     5        <rdar://problem/60710690>
     6
     7        Reviewed by Alex Christensen and David Kilzer.
     8
     9        Test: http/tests/resourceLoadStatistics/set-all-cookies-to-same-site-strict.html
     10
     11        * platform/network/NetworkStorageSession.cpp:
     12        (WebCore::NetworkStorageSession::setAllCookiesToSameSiteStrict):
     13            Stub function for non-Cocoa platforms.
     14        * platform/network/NetworkStorageSession.h:
     15        * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
     16        (WebCore::NetworkStorageSession::setAllCookiesToSameSiteStrict):
     17        * testing/Internals.h:
     18            Added code to expose SameSite=None and path properties of cookies.
     19            However, they don't seem to carry over so I'll have to revisit the
     20            internal workings.
     21
    1222020-03-23  Michael Catanzaro  <mcatanzaro@gnome.org>
    223
  • trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp

    r258448 r258884  
    8989}
    9090
     91#if !PLATFORM(COCOA)
     92void NetworkStorageSession::setAllCookiesToSameSiteStrict(const RegistrableDomain&, CompletionHandler<void()>&& completionHandler)
     93{
     94    // Not implemented.
     95    completionHandler();
     96}
     97#endif
     98
    9199bool NetworkStorageSession::hasHadUserInteractionAsFirstParty(const RegistrableDomain& registrableDomain) const
    92100{
  • trunk/Source/WebCore/platform/network/NetworkStorageSession.h

    r258448 r258884  
    178178    WEBCORE_EXPORT bool shouldBlockThirdPartyCookies(const RegistrableDomain&) const;
    179179    WEBCORE_EXPORT bool shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(const RegistrableDomain&) const;
     180    WEBCORE_EXPORT void setAllCookiesToSameSiteStrict(const RegistrableDomain&, CompletionHandler<void()>&&);
    180181    WEBCORE_EXPORT bool hasHadUserInteractionAsFirstParty(const RegistrableDomain&) const;
    181182    WEBCORE_EXPORT void setPrevalentDomainsToBlockAndDeleteCookiesFor(const Vector<RegistrableDomain>&);
  • trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm

    r257888 r258884  
    115115
    116116    completionHandler(false);
     117}
     118
     119void NetworkStorageSession::setAllCookiesToSameSiteStrict(const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler)
     120{
     121    ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
     122
     123#if HAVE(CFNETWORK_SAMESITE_COOKIE_API)
     124    RetainPtr<NSMutableArray<NSHTTPCookie *>> oldCookiesToDelete = adoptNS([[NSMutableArray alloc] init]);
     125    RetainPtr<NSMutableArray<NSHTTPCookie *>> newCookiesToAdd = adoptNS([[NSMutableArray alloc] init]);
     126
     127    for (NSHTTPCookie *nsCookie in nsCookieStorage().cookies) {
     128        if (RegistrableDomain::uncheckedCreateFromHost(nsCookie.domain) == domain && nsCookie.sameSitePolicy != NSHTTPCookieSameSiteStrict) {
     129            [oldCookiesToDelete addObject:nsCookie];
     130            RetainPtr<NSMutableDictionary<NSHTTPCookiePropertyKey, id>> mutableProperties = adoptNS([[nsCookie properties] mutableCopy]);
     131            mutableProperties.get()[NSHTTPCookieSameSitePolicy] = NSHTTPCookieSameSiteStrict;
     132            NSHTTPCookie *strictCookie = [NSHTTPCookie cookieWithProperties:mutableProperties.get()];
     133            [newCookiesToAdd addObject:strictCookie];
     134        }
     135    }
     136
     137    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     138    for (NSHTTPCookie *oldCookie in oldCookiesToDelete.get())
     139        deleteHTTPCookie(cookieStorage().get(), oldCookie);
     140
     141    for (NSHTTPCookie *newCookie in newCookiesToAdd.get())
     142        [nsCookieStorage() setCookie:newCookie];
     143    END_BLOCK_OBJC_EXCEPTIONS;
     144#else
     145    UNUSED_PARAM(domain);
     146#endif
     147    completionHandler();
    117148}
    118149
  • trunk/Source/WebCore/testing/Internals.h

    r258826 r258884  
    849849        String value;
    850850        String domain;
     851        String path;
    851852        // Expiration dates are expressed as milliseconds since the UNIX epoch.
    852853        double expires { 0 };
     
    854855        bool isSecure { false };
    855856        bool isSession { false };
     857        bool isSameSiteNone { false };
    856858        bool isSameSiteLax { false };
    857859        bool isSameSiteStrict { false };
     
    861863            , value(cookie.value)
    862864            , domain(cookie.domain)
     865            , path(cookie.path)
    863866            , expires(cookie.expires.valueOr(0))
    864867            , isHttpOnly(cookie.httpOnly)
    865868            , isSecure(cookie.secure)
    866869            , isSession(cookie.session)
     870            , isSameSiteNone(cookie.sameSite == Cookie::SameSitePolicy::None)
    867871            , isSameSiteLax(cookie.sameSite == Cookie::SameSitePolicy::Lax)
    868872            , isSameSiteStrict(cookie.sameSite == Cookie::SameSitePolicy::Strict)
    869873        {
    870             ASSERT(!(isSameSiteLax && isSameSiteStrict));
     874            ASSERT(!(isSameSiteLax && isSameSiteStrict) && !(isSameSiteLax && isSameSiteNone) && !(isSameSiteStrict && isSameSiteNone));
    871875        }
    872876
  • trunk/Source/WebKit/ChangeLog

    r258873 r258884  
     12020-03-23  John Wilander  <wilander@apple.com>
     2
     3        Add the capability to change all of a website's cookies to SameSite=Strict
     4        https://bugs.webkit.org/show_bug.cgi?id=209369
     5        <rdar://problem/60710690>
     6
     7        Reviewed by Alex Christensen and David Kilzer.
     8
     9        These changes add test infrastructure to run function
     10        WebCore::NetworkStorageSession::setAllCookiesToSameSiteStrict() in the
     11        network process.
     12
     13        * NetworkProcess/NetworkProcess.cpp:
     14        (WebKit::NetworkProcess::setToSameSiteStrictCookiesForTesting):
     15        * NetworkProcess/NetworkProcess.h:
     16        * NetworkProcess/NetworkProcess.messages.in:
     17        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     18        (WKWebsiteDataStoreSetResourceLoadStatisticsToSameSiteStrictCookiesForTesting):
     19        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
     20        * UIProcess/Network/NetworkProcessProxy.cpp:
     21        (WebKit::NetworkProcessProxy::setToSameSiteStrictCookiesForTesting):
     22        * UIProcess/Network/NetworkProcessProxy.h:
     23        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     24        (WebKit::WebsiteDataStore::setResourceLoadStatisticsToSameSiteStrictCookiesForTesting):
     25        * UIProcess/WebsiteData/WebsiteDataStore.h:
     26
    1272020-03-23  Daniel Bates  <dabates@apple.com>
    228
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r258862 r258884  
    13071307    }
    13081308}
     1309
     1310void NetworkProcess::setToSameSiteStrictCookiesForTesting(PAL::SessionID sessionID, const WebCore::RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler)
     1311{
     1312    if (auto* networkStorageSession = storageSession(sessionID))
     1313        networkStorageSession->setAllCookiesToSameSiteStrict(domain, WTFMove(completionHandler));
     1314    else {
     1315        ASSERT_NOT_REACHED();
     1316        completionHandler();
     1317    }
     1318}
    13091319#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
    13101320
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r258862 r258884  
    266266    void setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID, WebCore::ThirdPartyCookieBlockingMode, CompletionHandler<void()>&&);
    267267    void setFirstPartyWebsiteDataRemovalModeForTesting(PAL::SessionID, WebCore::FirstPartyWebsiteDataRemovalMode, CompletionHandler<void()>&&);
     268    void setToSameSiteStrictCookiesForTesting(PAL::SessionID, const WebCore::RegistrableDomain&, CompletionHandler<void()>&&);
    268269#endif
    269270
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r258862 r258884  
    143143    SetShouldBlockThirdPartyCookiesForTesting(PAL::SessionID sessionID, enum:uint8_t WebCore::ThirdPartyCookieBlockingMode blockingMode) -> () Async
    144144    SetFirstPartyWebsiteDataRemovalModeForTesting(PAL::SessionID sessionID, enum:uint8_t WebCore::FirstPartyWebsiteDataRemovalMode mode) -> () Async
     145    SetToSameSiteStrictCookiesForTesting(PAL::SessionID sessionID, WebCore::RegistrableDomain domain) -> () Async
    145146#endif
    146147
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r258436 r258884  
    583583}
    584584
     585void WKWebsiteDataStoreSetResourceLoadStatisticsToSameSiteStrictCookiesForTesting(WKWebsiteDataStoreRef dataStoreRef, WKStringRef hostName, void* context, WKWebsiteDataStoreSetResourceLoadStatisticsToSameSiteStrictCookiesForTestingFunction completionHandler)
     586{
     587#if ENABLE(RESOURCE_LOAD_STATISTICS)
     588    WebKit::toImpl(dataStoreRef)->setResourceLoadStatisticsToSameSiteStrictCookiesForTesting(URL(URL(), WebKit::toImpl(hostName)->string()), [context, completionHandler] {
     589        completionHandler(context);
     590    });
     591#else
     592    completionHandler(context);
     593#endif
     594}
     595
    585596void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler)
    586597{
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r258436 r258884  
    128128typedef void (*WKWebsiteDataStoreSetResourceLoadStatisticsFirstPartyWebsiteDataRemovalModeForTestingFunction)(void* functionContext);
    129129WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsFirstPartyWebsiteDataRemovalModeForTesting(WKWebsiteDataStoreRef dataStoreRef, bool enabled, void* context, WKWebsiteDataStoreSetResourceLoadStatisticsFirstPartyWebsiteDataRemovalModeForTestingFunction completionHandler);
     130typedef void (*WKWebsiteDataStoreSetResourceLoadStatisticsToSameSiteStrictCookiesForTestingFunction)(void* functionContext);
     131WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsToSameSiteStrictCookiesForTesting(WKWebsiteDataStoreRef dataStoreRef, WKStringRef hostName, void* context, WKWebsiteDataStoreSetResourceLoadStatisticsToSameSiteStrictCookiesForTestingFunction completionHandler);
    130132typedef void (*WKWebsiteDataStoreStatisticsResetToConsistentStateFunction)(void* functionContext);
    131133WK_EXPORT void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler);
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r258862 r258884  
    11711171    sendWithAsyncReply(Messages::NetworkProcess::SetFirstPartyWebsiteDataRemovalModeForTesting(sessionID, mode), WTFMove(completionHandler));
    11721172}
     1173
     1174void NetworkProcessProxy::setToSameSiteStrictCookiesForTesting(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler)
     1175{
     1176    if (!canSendMessage()) {
     1177        completionHandler();
     1178        return;
     1179    }
     1180
     1181    sendWithAsyncReply(Messages::NetworkProcess::SetToSameSiteStrictCookiesForTesting(sessionID, domain), WTFMove(completionHandler));
     1182}
    11731183#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
    11741184
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r258862 r258884  
    176176    void setShouldBlockThirdPartyCookiesForTesting(PAL::SessionID, WebCore::ThirdPartyCookieBlockingMode, CompletionHandler<void()>&&);
    177177    void setFirstPartyWebsiteDataRemovalModeForTesting(PAL::SessionID, WebCore::FirstPartyWebsiteDataRemovalMode, CompletionHandler<void()>&&);
     178    void setToSameSiteStrictCookiesForTesting(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
    178179#endif
    179180   
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r258862 r258884  
    18581858    }
    18591859}
     1860
     1861void WebsiteDataStore::setResourceLoadStatisticsToSameSiteStrictCookiesForTesting(const URL& url, CompletionHandler<void()>&& completionHandler)
     1862{
     1863    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1864
     1865    for (auto& processPool : processPools()) {
     1866        if (auto* networkProcess = processPool->networkProcess())
     1867            networkProcess->setToSameSiteStrictCookiesForTesting(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator = callbackAggregator.copyRef()] { });
     1868    }
     1869}
    18601870#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
    18611871
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r258862 r258884  
    197197    void setResourceLoadStatisticsShouldBlockThirdPartyCookiesForTesting(bool enabled, bool onlyOnSitesWithoutUserInteraction, CompletionHandler<void()>&&);
    198198    void setResourceLoadStatisticsFirstPartyWebsiteDataRemovalModeForTesting(bool enabled, CompletionHandler<void()>&&);
     199    void setResourceLoadStatisticsToSameSiteStrictCookiesForTesting(const URL&, CompletionHandler<void()>&&);
    199200    WebCore::ThirdPartyCookieBlockingMode thirdPartyCookieBlockingMode() const;
    200201    bool isItpStateExplicitlySet() const { return m_isItpStateExplicitlySet; }
  • trunk/Tools/ChangeLog

    r258879 r258884  
     12020-03-23  John Wilander  <wilander@apple.com>
     2
     3        Add the capability to change all of a website's cookies to SameSite=Strict
     4        https://bugs.webkit.org/show_bug.cgi?id=209369
     5        <rdar://problem/60710690>
     6
     7        Reviewed by Alex Christensen and David Kilzer.
     8
     9        These changes add TestRunner function statisticsSetToSameSiteStrictCookies().
     10
     11        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     12        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     13        (WTR::InjectedBundle::didReceiveMessageToPage):
     14        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     15        (WTR::TestRunner::statisticsSetToSameSiteStrictCookies):
     16        (WTR::TestRunner::statisticsCallDidSetToSameSiteStrictCookiesCallback):
     17        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     18        * WebKitTestRunner/TestController.cpp:
     19        (WTR::TestController::setStatisticsToSameSiteStrictCookies):
     20        * WebKitTestRunner/TestController.h:
     21        * WebKitTestRunner/TestInvocation.cpp:
     22        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
     23        (WTR::TestInvocation::didSetToSameSiteStrictCookies):
     24        * WebKitTestRunner/TestInvocation.h:
     25
    1262020-03-23  Nikos Mouchtaris  <nmouchtaris@apple.com>
    227
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r258421 r258884  
    346346    void setStatisticsShouldBlockThirdPartyCookies(boolean value, object callback, optional boolean onlyOnSitesWithoutUserInteraction);
    347347    void setStatisticsFirstPartyWebsiteDataRemovalMode(boolean value, object callback);
     348    void statisticsSetToSameSiteStrictCookies(DOMString hostName, object callback);
    348349    void loadedThirdPartyDomains(object callback);
    349350
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r258672 r258884  
    358358    }
    359359
     360    if (WKStringIsEqualToUTF8CString(messageName, "CallDidSetToSameSiteStrictCookies")) {
     361        m_testRunner->statisticsCallDidSetToSameSiteStrictCookiesCallback();
     362        return;
     363    }
     364
    360365    if (WKStringIsEqualToUTF8CString(messageName, "CallDidResetStatisticsToConsistentState")) {
    361366        m_testRunner->statisticsCallDidResetToConsistentStateCallback();
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r258672 r258884  
    755755    StatisticsDidSetShouldBlockThirdPartyCookiesCallbackID,
    756756    StatisticsDidSetFirstPartyWebsiteDataRemovalModeCallbackID,
     757    StatisticsDidSetToSameSiteStrictCookiesCallbackID,
    757758    AllStorageAccessEntriesCallbackID,
    758759    LoadedThirdPartyDomainsCallbackID,
     
    22872288}
    22882289
     2290void TestRunner::statisticsSetToSameSiteStrictCookies(JSStringRef hostName, JSValueRef completionHandler)
     2291{
     2292    cacheTestRunnerCallback(StatisticsDidSetToSameSiteStrictCookiesCallbackID, completionHandler);
     2293
     2294    auto messageName = adoptWK(WKStringCreateWithUTF8CString("StatisticsSetToSameSiteStrictCookies"));
     2295    auto messageBody = adoptWK(WKStringCreateWithJSString(hostName));
     2296    WKBundlePostMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get());
     2297}
     2298
     2299void TestRunner::statisticsCallDidSetToSameSiteStrictCookiesCallback()
     2300{
     2301    callTestRunnerCallback(StatisticsDidSetToSameSiteStrictCookiesCallbackID);
     2302}
     2303
    22892304void TestRunner::statisticsResetToConsistentState(JSValueRef completionHandler)
    22902305{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r258672 r258884  
    449449    void setStatisticsFirstPartyWebsiteDataRemovalMode(bool value, JSValueRef callback);
    450450    void statisticsCallDidSetFirstPartyWebsiteDataRemovalModeCallback();
     451    void statisticsSetToSameSiteStrictCookies(JSStringRef hostName, JSValueRef callback);
     452    void statisticsCallDidSetToSameSiteStrictCookiesCallback();
    451453    void statisticsResetToConsistentState(JSValueRef completionHandler);
    452454    void statisticsCallDidResetToConsistentStateCallback();
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r258672 r258884  
    37053705}
    37063706
     3707void TestController::setStatisticsToSameSiteStrictCookies(WKStringRef hostName)
     3708{
     3709    ResourceStatisticsCallbackContext context(*this);
     3710    WKWebsiteDataStoreSetResourceLoadStatisticsToSameSiteStrictCookiesForTesting(websiteDataStore(), hostName, &context, resourceStatisticsVoidResultCallback);
     3711    runUntil(context.done, noTimeout);
     3712    m_currentInvocation->didSetToSameSiteStrictCookies();
     3713}
     3714
    37073715void TestController::statisticsResetToConsistentState()
    37083716{
  • trunk/Tools/WebKitTestRunner/TestController.h

    r258436 r258884  
    263263    void setStatisticsShouldBlockThirdPartyCookies(bool value, bool onlyOnSitesWithoutUserInteraction);
    264264    void setStatisticsFirstPartyWebsiteDataRemovalMode(bool value);
     265    void setStatisticsToSameSiteStrictCookies(WKStringRef hostName);
    265266    void statisticsResetToConsistentState();
    266267
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r258672 r258884  
    951951    }
    952952
     953    if (WKStringIsEqualToUTF8CString(messageName, "StatisticsSetToSameSiteStrictCookies")) {
     954        ASSERT(WKGetTypeID(messageBody) == WKStringGetTypeID());
     955        WKStringRef hostName = static_cast<WKStringRef>(messageBody);
     956        TestController::singleton().setStatisticsToSameSiteStrictCookies(hostName);
     957        return;
     958    }
     959
    953960    if (WKStringIsEqualToUTF8CString(messageName, "StatisticsResetToConsistentState")) {
    954961        if (m_shouldDumpResourceLoadStatistics)
     
    19171924}
    19181925
     1926void TestInvocation::didSetToSameSiteStrictCookies()
     1927{
     1928    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidSetToSameSiteStrictCookies"));
     1929    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), nullptr);
     1930}
     1931
    19191932void TestInvocation::didResetStatisticsToConsistentState()
    19201933{
  • trunk/Tools/WebKitTestRunner/TestInvocation.h

    r258672 r258884  
    7878    void didSetShouldBlockThirdPartyCookies();
    7979    void didSetFirstPartyWebsiteDataRemovalMode();
     80    void didSetToSameSiteStrictCookies();
    8081    void didResetStatisticsToConsistentState();
    8182    void didSetBlockCookiesForHost();
Note: See TracChangeset for help on using the changeset viewer.