Changeset 260356 in webkit


Ignore:
Timestamp:
Apr 20, 2020 1:33:58 AM (4 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK][WPE] Enable resource load statistics
https://bugs.webkit.org/show_bug.cgi?id=210184

Reviewed by Žan Doberšek.

.:

Enable resource load statistics.

  • Source/cmake/OptionsGTK.cmake:
  • Source/cmake/OptionsWPE.cmake:

Source/WebCore:

  • platform/network/soup/NetworkStorageSessionSoup.cpp:

(WebCore::NetworkStorageSession::setCookiesFromDOM const): Return early if cookies are blocked and update the
persistent cookies expiration if needed.
(WebCore::NetworkStorageSession::deleteCookiesForHostnames): Implement this when receiving
IncludeHttpOnlyCookies parameter.
(WebCore::NetworkStorageSession::hasCookies const): Implement this.
(WebCore::NetworkStorageSession::getRawCookies const): Honor shouldAskITP parameter.
(WebCore::cookiesForSession): Ditto.
(WebCore::NetworkStorageSession::cookiesForDOM const): Ditto.
(WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const): Ditto.

Source/WebKit:

  • NetworkProcess/NetworkDataTask.cpp:

(WebKit::NetworkDataTask::create): Pass page and frame identifiers to the constructor.
(WebKit::NetworkDataTask::isThirdPartyRequest const): Moved from NetworkDataTaskCocoa.mm.
(WebKit::NetworkDataTask::restrictRequestReferrerToOriginIfNeeded): Ditto.

  • NetworkProcess/NetworkDataTask.h:
  • NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
  • NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
  • NetworkProcess/soup/NetworkDataTaskSoup.cpp:

(WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): Initialize m_frameID and m_pageID.
(WebKit::NetworkDataTaskSoup::createRequest): Add WasBlockingCookies parameter. Call
restrictRequestReferrerToOriginIfNeeded() and disable cookies in the soup message if cookies should be blocked.
(WebKit::NetworkDataTaskSoup::clearRequest): Reset m_isBlockingCookies.
(WebKit::NetworkDataTaskSoup::continueHTTPRedirection): Pass WasBlockingCookies to createRequest().

  • NetworkProcess/soup/NetworkDataTaskSoup.h:
  • UIProcess/API/C/WKPage.cpp:

(WKPageLoadedThirdPartyDomains): Added for tests.
(WKPageClearLoadedThirdPartyDomains): Ditto.

  • UIProcess/API/C/WKPagePrivate.h:
  • UIProcess/glib/WebsiteDataStoreGLib.cpp:

(WebKit::WebsiteDataStore::defaultResourceLoadStatisticsDirectory): Use lowercase for consistency with other
default directories.

Tools:

Implement TestController::loadedThirdPartyDomains() and TestController::clearLoadedThirdPartyDomains() for
non-cocoa ports.

  • WebKitTestRunner/TestController.cpp:

(WTR::LoadedThirdPartyDomainsCallbackContext::LoadedThirdPartyDomainsCallbackContext):
(WTR::loadedThirdPartyDomainsCallback):
(WTR::TestController::loadedThirdPartyDomains):
(WTR::TestController::clearLoadedThirdPartyDomains):

LayoutTests:

Unskip tests that are now passing and add expectations for the two reminaing failures.

  • http/tests/resourceLoadStatistics/loaded-registrable-domains-get-reported.html: Use setTimeout in onload

handler to avoid a deadlock due to sync injected bundle messages.

  • platform/gtk/TestExpectations:
  • platform/wpe/TestExpectations:
Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r260277 r260356  
     12020-04-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Enable resource load statistics
     4        https://bugs.webkit.org/show_bug.cgi?id=210184
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Enable resource load statistics.
     9
     10        * Source/cmake/OptionsGTK.cmake:
     11        * Source/cmake/OptionsWPE.cmake:
     12
    1132020-04-17  Don Olmstead  <don.olmstead@sony.com>
    214
  • trunk/LayoutTests/ChangeLog

    r260352 r260356  
     12020-04-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Enable resource load statistics
     4        https://bugs.webkit.org/show_bug.cgi?id=210184
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Unskip tests that are now passing and add expectations for the two reminaing failures.
     9
     10        * http/tests/resourceLoadStatistics/loaded-registrable-domains-get-reported.html: Use setTimeout in onload
     11        handler to avoid a deadlock due to sync injected bundle messages.
     12        * platform/gtk/TestExpectations:
     13        * platform/wpe/TestExpectations:
     14
    1152020-04-19  Yusuke Suzuki  <ysuzuki@apple.com>
    216
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/loaded-registrable-domains-get-reported.html

    r258421 r260356  
    2525</head>
    2626<body>
    27 <iframe onload='askForLoadedThirdPartyDomains()' src="http://localhost:8000/resourceLoadStatistics/resources/basic-iframe.html">
     27<iframe onload="setTimeout('askForLoadedThirdPartyDomains()', 0)" src="http://localhost:8000/resourceLoadStatistics/resources/basic-iframe.html">
    2828</iframe>
    2929</body>
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r260183 r260356  
    11811181webkit.org/b/191005 inspector/canvas/updateShader-webgpu-sharedVertexFragment.html [ Skip ]
    11821182
    1183 # No support for resource load statistics yet
    1184 http/tests/resourceLoadStatistics/ [ Skip ]
    1185 http/tests/websocket/web-socket-loads-captured-in-per-page-domains.html [ Skip ]
    1186 
    11871183# No support for screen capture
    11881184fast/mediastream/screencapture-user-gesture.html [ Skip ]
     
    14451441webkit.org/b/210601 imported/w3c/web-platform-tests/web-animations/interfaces/KeyframeEffect/style-change-events.html [ Failure ]
    14461442webkit.org/b/210601 imported/w3c/web-platform-tests/web-animations/interfaces/KeyframeEffect/target.html [ Failure ]
     1443
     1444webkit.org/b/210487 http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction-database.php [ Failure ]
     1445webkit.org/b/210487 http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.php [ Failure ]
    14471446
    14481447#////////////////////////////////////////////////////////////////////////////////////////
  • trunk/LayoutTests/platform/wpe/TestExpectations

    r260182 r260356  
    738738# Currently enabled on Mac only
    739739media/media-usage-state.html [ Skip ]
     740
     741webkit.org/b/210487 http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction-database.php [ Failure ]
     742webkit.org/b/210487 http/tests/resourceLoadStatistics/switch-session-on-navigation-to-prevalent-with-interaction.php [ Failure ]
    740743
    741744#////////////////////////////////////////////////////////////////////////////////////////
  • trunk/Source/WebCore/ChangeLog

    r260353 r260356  
     12020-04-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Enable resource load statistics
     4        https://bugs.webkit.org/show_bug.cgi?id=210184
     5
     6        Reviewed by Žan Doberšek.
     7
     8        * platform/network/soup/NetworkStorageSessionSoup.cpp:
     9        (WebCore::NetworkStorageSession::setCookiesFromDOM const): Return early if cookies are blocked and update the
     10        persistent cookies expiration if needed.
     11        (WebCore::NetworkStorageSession::deleteCookiesForHostnames): Implement this when receiving
     12        IncludeHttpOnlyCookies parameter.
     13        (WebCore::NetworkStorageSession::hasCookies const): Implement this.
     14        (WebCore::NetworkStorageSession::getRawCookies const): Honor shouldAskITP parameter.
     15        (WebCore::cookiesForSession): Ditto.
     16        (WebCore::NetworkStorageSession::cookiesForDOM const): Ditto.
     17        (WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const): Ditto.
     18
    1192020-04-19  Simon Fraser  <simon.fraser@apple.com>
    220
  • trunk/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp

    r258698 r260356  
    269269}
    270270
    271 void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo&, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, ShouldAskITP, const String& value) const
    272 {
     271void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo&, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, ShouldAskITP shouldAskITP, const String& value) const
     272{
     273#if ENABLE(RESOURCE_LOAD_STATISTICS)
     274    if (shouldAskITP == ShouldAskITP::Yes && shouldBlockCookies(firstParty, url, frameID, pageID))
     275        return;
     276#else
    273277    UNUSED_PARAM(frameID);
    274278    UNUSED_PARAM(pageID);
     279    UNUSED_PARAM(shouldAskITP);
     280#endif
    275281    GUniquePtr<SoupURI> origin = urlToSoupURI(url);
    276282    if (!origin)
     
    280286    if (!firstPartyURI)
    281287        return;
     288
     289#if ENABLE(RESOURCE_LOAD_STATISTICS)
     290    auto cappedLifetime = clientSideCookieCap(RegistrableDomain { firstParty }, pageID);
     291#endif
    282292
    283293    // Get existing cookies for this origin.
     
    298308        if (httpOnlyCookieExists(existingCookies, soup_cookie_get_name(cookie.get()), soup_cookie_get_path(cookie.get())))
    299309            continue;
     310
     311#if ENABLE(RESOURCE_LOAD_STATISTICS)
     312        // Cap lifetime of persistent, client-side cookies to a week.
     313        if (cappedLifetime) {
     314            if (auto* expiresDate = soup_cookie_get_expires(cookie.get())) {
     315                auto timeIntervalSinceNow = Seconds(static_cast<double>(soup_date_to_time_t(expiresDate))) - WallTime::now().secondsSinceEpoch();
     316                if (timeIntervalSinceNow > cappedLifetime.value())
     317                    soup_cookie_set_max_age(cookie.get(), cappedLifetime->secondsAs<int>());
     318            }
     319        }
     320#endif
    300321
    301322#if SOUP_CHECK_VERSION(2, 67, 1)
     
    381402void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& hostnames, IncludeHttpOnlyCookies includeHttpOnlyCookies)
    382403{
    383     // FIXME: Not yet implemented.
    384     UNUSED_PARAM(includeHttpOnlyCookies);
    385     deleteCookiesForHostnames(hostnames);
    386 }
    387 
    388 void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& hostnames)
    389 {
    390404    SoupCookieJar* cookieJar = cookieStorage();
    391 
    392405    for (const auto& hostname : hostnames) {
    393406        CString hostNameString = hostname.utf8();
    394407
    395408        GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
    396         for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
    397             SoupCookie* cookie = static_cast<SoupCookie*>(item->data);
    398             if (soup_cookie_domain_matches(cookie, hostNameString.data()))
    399                 soup_cookie_jar_delete_cookie(cookieJar, cookie);
    400             soup_cookie_free(cookie);
     409        for (auto* item = cookies.get(); item; item = g_slist_next(item)) {
     410            GUniquePtr<SoupCookie> cookie(static_cast<SoupCookie*>(item->data));
     411            if (includeHttpOnlyCookies == IncludeHttpOnlyCookies::No && soup_cookie_get_http_only(cookie.get()))
     412                continue;
     413
     414            if (soup_cookie_domain_matches(cookie.get(), hostNameString.data()))
     415                soup_cookie_jar_delete_cookie(cookieJar, cookie.get());
    401416        }
    402417    }
     418}
     419
     420void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& hostnames)
     421{
     422    deleteCookiesForHostnames(hostnames, IncludeHttpOnlyCookies::Yes);
    403423}
    404424
     
    441461}
    442462
    443 void NetworkStorageSession::hasCookies(const RegistrableDomain&, CompletionHandler<void(bool)>&& completionHandler) const
    444 {
    445     // FIXME: Implement.
     463void NetworkStorageSession::hasCookies(const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) const
     464{
     465    GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieStorage()));
     466    for (auto* item = cookies.get(); item; item = g_slist_next(item)) {
     467        GUniquePtr<SoupCookie> cookie(static_cast<SoupCookie*>(item->data));
     468        if (RegistrableDomain::uncheckedCreateFromHost(cookie->domain) == domain) {
     469            completionHandler(true);
     470            return;
     471        }
     472    }
    446473    completionHandler(false);
    447474}
    448475
    449 bool NetworkStorageSession::getRawCookies(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, ShouldAskITP, Vector<Cookie>& rawCookies) const
     476bool NetworkStorageSession::getRawCookies(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, ShouldAskITP shouldAskITP, Vector<Cookie>& rawCookies) const
    450477{
    451478    rawCookies.clear();
    452479
    453480#if ENABLE(RESOURCE_LOAD_STATISTICS)
    454     if (shouldBlockCookies(firstParty, url, frameID, pageID))
     481    if (shouldAskITP == ShouldAskITP::Yes && shouldBlockCookies(firstParty, url, frameID, pageID))
    455482        return true;
    456483#else
    457484    UNUSED_PARAM(frameID);
    458485    UNUSED_PARAM(pageID);
     486    UNUSED_PARAM(shouldAskITP);
    459487#endif
    460488
     
    488516}
    489517
    490 static std::pair<String, bool> cookiesForSession(const NetworkStorageSession& session, const URL& firstParty, const URL& url, const SameSiteInfo& sameSiteInfo, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, bool forHTTPHeader, IncludeSecureCookies includeSecureCookies)
     518static std::pair<String, bool> cookiesForSession(const NetworkStorageSession& session, const URL& firstParty, const URL& url, const SameSiteInfo& sameSiteInfo, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, bool forHTTPHeader, IncludeSecureCookies includeSecureCookies, ShouldAskITP shouldAskITP)
    491519{
    492520#if ENABLE(RESOURCE_LOAD_STATISTICS)
    493     if (session.shouldBlockCookies(firstParty, url, frameID, pageID))
     521    if (shouldAskITP == ShouldAskITP::Yes && session.shouldBlockCookies(firstParty, url, frameID, pageID))
    494522        return { { }, false };
    495523#else
    496524    UNUSED_PARAM(frameID);
    497525    UNUSED_PARAM(pageID);
     526    UNUSED_PARAM(shouldAskITP);
    498527#endif
    499528
     
    544573}
    545574
    546 std::pair<String, bool> NetworkStorageSession::cookiesForDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, IncludeSecureCookies includeSecureCookies, ShouldAskITP) const
    547 {
    548     return cookiesForSession(*this, firstParty, url, sameSiteInfo, frameID, pageID, false, includeSecureCookies);
    549 }
    550 
    551 std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, IncludeSecureCookies includeSecureCookies, ShouldAskITP) const
     575std::pair<String, bool> NetworkStorageSession::cookiesForDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, IncludeSecureCookies includeSecureCookies, ShouldAskITP shouldAskITP) const
     576{
     577    return cookiesForSession(*this, firstParty, url, sameSiteInfo, frameID, pageID, false, includeSecureCookies, shouldAskITP);
     578}
     579
     580std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, IncludeSecureCookies includeSecureCookies, ShouldAskITP shouldAskITP) const
    552581{
    553582    // Secure cookies will still only be included if url's protocol is https.
    554     return cookiesForSession(*this, firstParty, url, sameSiteInfo, frameID, pageID, true, includeSecureCookies);
     583    return cookiesForSession(*this, firstParty, url, sameSiteInfo, frameID, pageID, true, includeSecureCookies, shouldAskITP);
    555584}
    556585
  • trunk/Source/WebKit/ChangeLog

    r260354 r260356  
     12020-04-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Enable resource load statistics
     4        https://bugs.webkit.org/show_bug.cgi?id=210184
     5
     6        Reviewed by Žan Doberšek.
     7
     8        * NetworkProcess/NetworkDataTask.cpp:
     9        (WebKit::NetworkDataTask::create): Pass page and frame identifiers to the constructor.
     10        (WebKit::NetworkDataTask::isThirdPartyRequest const): Moved from NetworkDataTaskCocoa.mm.
     11        (WebKit::NetworkDataTask::restrictRequestReferrerToOriginIfNeeded): Ditto.
     12        * NetworkProcess/NetworkDataTask.h:
     13        * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
     14        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
     15        * NetworkProcess/soup/NetworkDataTaskSoup.cpp:
     16        (WebKit::NetworkDataTaskSoup::NetworkDataTaskSoup): Initialize m_frameID and m_pageID.
     17        (WebKit::NetworkDataTaskSoup::createRequest): Add WasBlockingCookies parameter. Call
     18        restrictRequestReferrerToOriginIfNeeded() and disable cookies in the soup message if cookies should be blocked.
     19        (WebKit::NetworkDataTaskSoup::clearRequest): Reset m_isBlockingCookies.
     20        (WebKit::NetworkDataTaskSoup::continueHTTPRedirection): Pass WasBlockingCookies to createRequest().
     21        * NetworkProcess/soup/NetworkDataTaskSoup.h:
     22        * UIProcess/API/C/WKPage.cpp:
     23        (WKPageLoadedThirdPartyDomains): Added for tests.
     24        (WKPageClearLoadedThirdPartyDomains): Ditto.
     25        * UIProcess/API/C/WKPagePrivate.h:
     26        * UIProcess/glib/WebsiteDataStoreGLib.cpp:
     27        (WebKit::WebsiteDataStore::defaultResourceLoadStatisticsDirectory): Use lowercase for consistency with other
     28        default directories.
     29
    1302020-04-20  David Kilzer  <ddkilzer@apple.com>
    231
  • trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp

    r259241 r260356  
    3131#include "NetworkLoadParameters.h"
    3232#include "NetworkSession.h"
     33#include <WebCore/RegistrableDomain.h>
    3334#include <WebCore/ResourceError.h>
     35#include <WebCore/ResourceRequest.h>
    3436#include <WebCore/ResourceResponse.h>
    3537#include <wtf/RunLoop.h>
     
    5557#endif
    5658#if USE(SOUP)
    57     return NetworkDataTaskSoup::create(session, client, parameters.request, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.isMainFrameNavigation);
     59    return NetworkDataTaskSoup::create(session, client, parameters.request, parameters.webFrameID, parameters.webPageID, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.isMainFrameNavigation);
    5860#endif
    5961#if USE(CURL)
     
    170172}
    171173
     174bool NetworkDataTask::isThirdPartyRequest(const WebCore::ResourceRequest& request) const
     175{
     176    return !WebCore::areRegistrableDomainsEqual(request.url(), request.firstPartyForCookies());
     177}
     178
     179void NetworkDataTask::restrictRequestReferrerToOriginIfNeeded(WebCore::ResourceRequest& request)
     180{
     181    if ((m_session->sessionID().isEphemeral() || m_session->isResourceLoadStatisticsEnabled()) && m_session->shouldDowngradeReferrer() && isThirdPartyRequest(request))
     182        request.setExistingHTTPReferrerToOriginString();
     183}
     184
    172185} // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h

    r255846 r260356  
    149149    void scheduleFailure(FailureType);
    150150
     151    bool isThirdPartyRequest(const WebCore::ResourceRequest&) const;
     152    void restrictRequestReferrerToOriginIfNeeded(WebCore::ResourceRequest&);
     153
    151154    FailureType m_scheduledFailureType { NoFailure };
    152155    WebCore::Timer m_failureTimer;
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h

    r260031 r260356  
    8282    void applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(__strong NSURLRequest*&, bool shouldContentSniff, bool shouldContentEncodingSniff);
    8383
    84     void restrictRequestReferrerToOriginIfNeeded(WebCore::ResourceRequest&);
    85 
    8684#if ENABLE(RESOURCE_LOAD_STATISTICS)
    8785    static NSHTTPCookieStorage *statelessCookieStorage();
     
    9088    bool needsFirstPartyCookieBlockingLatchModeQuirk(const URL& firstPartyURL, const URL& requestURL, const URL& redirectingURL) const;
    9189#endif
    92     bool isThirdPartyRequest(const WebCore::ResourceRequest&) const;
    9390    bool isAlwaysOnLoggingAllowed() const;
    9491
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm

    r260031 r260356  
    3939#import <WebCore/NetworkStorageSession.h>
    4040#import <WebCore/NotImplemented.h>
    41 #import <WebCore/RegistrableDomain.h>
    4241#import <WebCore/ResourceRequest.h>
    4342#import <pal/spi/cf/CFNetworkSPI.h>
     
    178177}
    179178#endif
    180 
    181 bool NetworkDataTaskCocoa::isThirdPartyRequest(const WebCore::ResourceRequest& request) const
    182 {
    183     return !WebCore::areRegistrableDomainsEqual(request.url(), request.firstPartyForCookies());
    184 }
    185179
    186180static void updateTaskWithFirstPartyForSameSiteCookies(NSURLSessionDataTask* task, const WebCore::ResourceRequest& request)
     
    300294    RELEASE_ASSERT(m_sessionWrapper->dataTaskMap.get([m_task taskIdentifier]) == this);
    301295    m_sessionWrapper->dataTaskMap.remove([m_task taskIdentifier]);
    302 }
    303 
    304 void NetworkDataTaskCocoa::restrictRequestReferrerToOriginIfNeeded(WebCore::ResourceRequest& request)
    305 {
    306     if ((m_session->sessionID().isEphemeral() || m_session->isResourceLoadStatisticsEnabled()) && m_session->shouldDowngradeReferrer() && isThirdPartyRequest(request))
    307         request.setExistingHTTPReferrerToOriginString();
    308296}
    309297
  • trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp

    r258685 r260356  
    5151static const size_t gDefaultReadBufferSize = 8192;
    5252
    53 NetworkDataTaskSoup::NetworkDataTaskSoup(NetworkSession& session, NetworkDataTaskClient& client, const ResourceRequest& requestWithCredentials, StoredCredentialsPolicy storedCredentialsPolicy, ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation)
     53NetworkDataTaskSoup::NetworkDataTaskSoup(NetworkSession& session, NetworkDataTaskClient& client, const ResourceRequest& requestWithCredentials, FrameIdentifier frameID, PageIdentifier pageID, StoredCredentialsPolicy storedCredentialsPolicy, ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation)
    5454    : NetworkDataTask(session, client, requestWithCredentials, storedCredentialsPolicy, shouldClearReferrerOnHTTPSToHTTPRedirect, dataTaskIsForMainFrameNavigation)
     55    , m_frameID(frameID)
     56    , m_pageID(pageID)
    5557    , m_shouldContentSniff(shouldContentSniff)
    5658    , m_timeoutSource(RunLoop::main(), this, &NetworkDataTaskSoup::timeoutFired)
     
    7678        applyAuthenticationToRequest(request);
    7779    }
    78     createRequest(WTFMove(request));
     80    createRequest(WTFMove(request), WasBlockingCookies::No);
    7981}
    8082
     
    104106}
    105107
    106 void NetworkDataTaskSoup::createRequest(ResourceRequest&& request)
     108void NetworkDataTaskSoup::createRequest(ResourceRequest&& request, WasBlockingCookies wasBlockingCookies)
    107109{
    108110    m_currentRequest = WTFMove(request);
     
    133135        return;
    134136    }
     137
     138    restrictRequestReferrerToOriginIfNeeded(m_currentRequest);
    135139
    136140    unsigned messageFlags = SOUP_MESSAGE_NO_REDIRECT;
     
    149153    }
    150154
     155#if ENABLE(RESOURCE_LOAD_STATISTICS)
     156    bool shouldBlockCookies = wasBlockingCookies == WasBlockingCookies::Yes ? true : m_storedCredentialsPolicy == StoredCredentialsPolicy::EphemeralStateless;
     157    if (!shouldBlockCookies) {
     158        if (auto* networkStorageSession = m_session->networkStorageSession())
     159            shouldBlockCookies = networkStorageSession->shouldBlockCookies(m_currentRequest, m_frameID, m_pageID);
     160    }
     161    if (shouldBlockCookies)
     162        soup_message_disable_feature(soupMessage.get(), SOUP_TYPE_COOKIE_JAR);
     163    m_isBlockingCookies = shouldBlockCookies;
     164#endif
     165
    151166#if SOUP_CHECK_VERSION(2, 67, 1)
    152167    if ((m_currentRequest.url().protocolIs("https") && !shouldAllowHSTSPolicySetting()) || (m_currentRequest.url().protocolIs("http") && !shouldAllowHSTSProtocolUpgrade()))
     
    195210    g_cancellable_cancel(m_cancellable.get());
    196211    m_cancellable = nullptr;
     212    m_isBlockingCookies = false;
    197213    if (m_soupMessage) {
    198214        g_signal_handlers_disconnect_matched(m_soupMessage.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
     
    704720    }
    705721
     722    auto wasBlockingCookies = m_isBlockingCookies ? WasBlockingCookies::Yes : WasBlockingCookies::No;
     723
    706724    clearRequest();
    707725
    708726    auto response = ResourceResponse(m_response);
    709     m_client->willPerformHTTPRedirection(WTFMove(response), WTFMove(request), [this, protectedThis = makeRef(*this), isCrossOrigin](const ResourceRequest& newRequest) {
     727    m_client->willPerformHTTPRedirection(WTFMove(response), WTFMove(request), [this, protectedThis = makeRef(*this), isCrossOrigin, wasBlockingCookies](const ResourceRequest& newRequest) {
    710728        if (newRequest.isNull() || m_state == State::Canceling)
    711729            return;
     
    720738            applyAuthenticationToRequest(request);
    721739        }
    722         createRequest(WTFMove(request));
     740        createRequest(WTFMove(request), wasBlockingCookies);
    723741        if (m_soupRequest && m_state != State::Suspended) {
    724742            m_state = State::Suspended;
  • trunk/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.h

    r249192 r260356  
    2727
    2828#include "NetworkDataTask.h"
     29#include <WebCore/FrameIdentifier.h>
    2930#include <WebCore/NetworkLoadMetrics.h>
     31#include <WebCore/PageIdentifier.h>
    3032#include <WebCore/ProtectionSpace.h>
    3133#include <WebCore/ResourceResponse.h>
     
    3739class NetworkDataTaskSoup final : public NetworkDataTask {
    3840public:
    39     static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation)
     41    static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation)
    4042    {
    41         return adoptRef(*new NetworkDataTaskSoup(session, client, request, storedCredentialsPolicy, shouldContentSniff, shouldContentEncodingSniff, shouldClearReferrerOnHTTPSToHTTPRedirect, dataTaskIsForMainFrameNavigation));
     43        return adoptRef(*new NetworkDataTaskSoup(session, client, request, frameID, pageID, storedCredentialsPolicy, shouldContentSniff, shouldContentEncodingSniff, shouldClearReferrerOnHTTPSToHTTPRedirect, dataTaskIsForMainFrameNavigation));
    4244    }
    4345
     
    4547
    4648private:
    47     NetworkDataTaskSoup(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation);
     49    NetworkDataTaskSoup(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, WebCore::FrameIdentifier, WebCore::PageIdentifier, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, bool dataTaskIsForMainFrameNavigation);
    4850
    4951    void cancel() override;
     
    5961    void stopTimeout();
    6062
    61     void createRequest(WebCore::ResourceRequest&&);
     63    enum class WasBlockingCookies { No, Yes };
     64    void createRequest(WebCore::ResourceRequest&&, WasBlockingCookies);
    6265    void clearRequest();
    6366    static void sendRequestCallback(SoupRequest*, GAsyncResult*, NetworkDataTaskSoup*);
     
    123126    void didRestart();
    124127
     128    WebCore::FrameIdentifier m_frameID;
     129    WebCore::PageIdentifier m_pageID;
    125130    State m_state { State::Suspended };
    126131    WebCore::ContentSniffingPolicy m_shouldContentSniff;
     
    144149    WebCore::NetworkLoadMetrics m_networkLoadMetrics;
    145150    MonotonicTime m_startTime;
     151    bool m_isBlockingCookies { false };
    146152    RunLoop::Timer<NetworkDataTaskSoup> m_timeoutSource;
    147153};
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r259307 r260356  
    29712971#endif
    29722972}
     2973
     2974void WKPageLoadedThirdPartyDomains(WKPageRef page, WKPageLoadedThirdPartyDomainsFunction callback, void* callbackContext)
     2975{
     2976#if ENABLE(RESOURCE_LOAD_STATISTICS)
     2977    toImpl(page)->loadedThirdPartyDomains([callbackContext, callback](Vector<RegistrableDomain>&& domains) {
     2978        Vector<RefPtr<API::Object>> apiDomains = WTF::map(domains, [](auto& domain) {
     2979            return RefPtr<API::Object>(API::String::create(WTFMove(domain.string())));
     2980        });
     2981        callback(toAPI(API::Array::create(WTFMove(apiDomains)).ptr()), callbackContext);
     2982    });
     2983#else
     2984    UNUSED_PARAM(page);
     2985    callback(nullptr, callbackContext);
     2986#endif
     2987}
     2988
     2989void WKPageClearLoadedThirdPartyDomains(WKPageRef page)
     2990{
     2991#if ENABLE(RESOURCE_LOAD_STATISTICS)
     2992    toImpl(page)->clearLoadedThirdPartyDomains();
     2993#else
     2994    UNUSED_PARAM(page);
     2995#endif
     2996}
  • trunk/Source/WebKit/UIProcess/API/C/WKPagePrivate.h

    r253149 r260356  
    195195WK_EXPORT bool WKPageIsMockRealtimeMediaSourceCenterEnabled(WKPageRef page);
    196196
     197typedef void (*WKPageLoadedThirdPartyDomainsFunction)(WKArrayRef domains, void* functionContext);
     198WK_EXPORT void WKPageLoadedThirdPartyDomains(WKPageRef page, WKPageLoadedThirdPartyDomainsFunction callback, void* callbackContext);
     199WK_EXPORT void WKPageClearLoadedThirdPartyDomains(WKPageRef page);
     200
    197201#ifdef __cplusplus
    198202}
  • trunk/Source/WebKit/UIProcess/glib/WebsiteDataStoreGLib.cpp

    r250169 r260356  
    9292WTF::String WebsiteDataStore::defaultResourceLoadStatisticsDirectory()
    9393{
    94     return websiteDataDirectoryFileSystemRepresentation(BASE_DIRECTORY G_DIR_SEPARATOR_S "ResourceLoadStatistics");
     94    return websiteDataDirectoryFileSystemRepresentation(BASE_DIRECTORY G_DIR_SEPARATOR_S "resourceloadstatistics");
    9595}
    9696
  • trunk/Source/cmake/OptionsGTK.cmake

    r260175 r260356  
    186186WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_TYPED_OM PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
    187187WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_CONIC_GRADIENTS PRIVATE ON)
     188WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOURCE_LOAD_STATISTICS PRIVATE ON)
    188189
    189190if (USE_GTK4)
  • trunk/Source/cmake/OptionsWPE.cmake

    r259707 r260356  
    6565WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS PRIVATE OFF)
    6666WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_OFFSCREEN_CANVAS PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
     67WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOURCE_LOAD_STATISTICS PRIVATE ON)
    6768WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SERVICE_WORKER PRIVATE ON)
    6869WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SHAREABLE_RESOURCE PUBLIC ON)
  • trunk/Tools/ChangeLog

    r260355 r260356  
     12020-04-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Enable resource load statistics
     4        https://bugs.webkit.org/show_bug.cgi?id=210184
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Implement TestController::loadedThirdPartyDomains() and TestController::clearLoadedThirdPartyDomains() for
     9        non-cocoa ports.
     10
     11        * WebKitTestRunner/TestController.cpp:
     12        (WTR::LoadedThirdPartyDomainsCallbackContext::LoadedThirdPartyDomainsCallbackContext):
     13        (WTR::loadedThirdPartyDomainsCallback):
     14        (WTR::TestController::loadedThirdPartyDomains):
     15        (WTR::TestController::clearLoadedThirdPartyDomains):
     16
    1172020-04-20  David Kilzer  <ddkilzer@apple.com>
    218
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r260169 r260356  
    31533153}
    31543154
     3155struct LoadedThirdPartyDomainsCallbackContext {
     3156    explicit LoadedThirdPartyDomainsCallbackContext(TestController& controller)
     3157        : testController(controller)
     3158    {
     3159    }
     3160
     3161    TestController& testController;
     3162    bool done { false };
     3163    Vector<String> result;
     3164};
     3165
     3166static void loadedThirdPartyDomainsCallback(WKArrayRef domains, void* userData)
     3167{
     3168    auto* context = static_cast<LoadedThirdPartyDomainsCallbackContext*>(userData);
     3169    context->done = true;
     3170
     3171    if (domains) {
     3172        auto size = WKArrayGetSize(domains);
     3173        context->result.reserveInitialCapacity(size);
     3174        for (size_t index = 0; index < size; ++index)
     3175            context->result.uncheckedAppend(toWTFString(static_cast<WKStringRef>(WKArrayGetItemAtIndex(domains, index))));
     3176    }
     3177
     3178    context->testController.notifyDone();
     3179}
     3180
    31553181void TestController::loadedThirdPartyDomains()
    31563182{
     3183    LoadedThirdPartyDomainsCallbackContext context(*this);
     3184    WKPageLoadedThirdPartyDomains(m_mainWebView->page(), loadedThirdPartyDomainsCallback, &context);
     3185    runUntil(context.done, noTimeout);
     3186    m_currentInvocation->didReceiveLoadedThirdPartyDomains(WTFMove(context.result));
    31573187}
    31583188
    31593189void TestController::clearLoadedThirdPartyDomains()
    31603190{
     3191    WKPageClearLoadedThirdPartyDomains(m_mainWebView->page());
    31613192}
    31623193
Note: See TracChangeset for help on using the changeset viewer.