Changeset 251391 in webkit


Ignore:
Timestamp:
Oct 21, 2019 3:33:47 PM (5 years ago)
Author:
wilander@apple.com
Message:

Resource Load Statistics: Update cookie blocking in NetworkStorageSession after first user interaction
https://bugs.webkit.org/show_bug.cgi?id=203195
<rdar://problem/56464567>

Reviewed by Alex Christensen and Chris Dumez.

Source/WebKit:

This change makes sure that the state of cookie blocking in
WebCore:: NetworkStorageSession is immediately updated if the logged
user interaction was new for this domain. It adds a completion
handler to WebResourceLoadStatisticsStore::logUserInteraction() so
that the call properly waits for everything to be updated.

  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:

(WebKit::CompletionHandler<void):

  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
  • NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:

(WebKit::ResourceLoadStatisticsMemoryStore::logUserInteraction):

  • NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
  • NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
  • NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:

(WebKit::WebResourceLoadStatisticsStore::logUserInteraction):

LayoutTests:

This patch removes the explicit calls to testRunner.statisticsUpdateCookieBlocking() since
they are no longer needed. This makes sure the changed code is tested.

  • http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html:
  • http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r251389 r251391  
     12019-10-21  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Update cookie blocking in NetworkStorageSession after first user interaction
     4        https://bugs.webkit.org/show_bug.cgi?id=203195
     5        <rdar://problem/56464567>
     6
     7        Reviewed by Alex Christensen and Chris Dumez.
     8
     9        This patch removes the explicit calls to testRunner.statisticsUpdateCookieBlocking() since
     10        they are no longer needed. This makes sure the changed code is tested.
     11
     12        * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html:
     13        * http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html:
     14
    1152019-10-21  Wenson Hsieh  <wenson_hsieh@apple.com>
    216
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction-database.html

    r251213 r251391  
    4747                // Produce user interaction for the first-party to allow third-party cookie access.
    4848                testRunner.setStatisticsHasHadUserInteraction(partitionOrigin, true, function() {
    49                     testRunner.statisticsUpdateCookieBlocking(function() {
    50                         // Check that the cookie is no longer blocked for localhost under 127.0.0.1.
    51                         openIframe(thirdPartyBaseUrl + subPathToGetCookies +  "&message=After user interaction, should receive first-party cookie.", runTest);
    52                     });
     49                    // Check that the cookie is no longer blocked for localhost under 127.0.0.1.
     50                    openIframe(thirdPartyBaseUrl + subPathToGetCookies +  "&message=After user interaction, should receive first-party cookie.", runTest);
    5351                });
    5452                break;
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/third-party-cookie-blocking-on-sites-without-user-interaction.html

    r251213 r251391  
    4747                // Produce user interaction for the first-party to allow third-party cookie access.
    4848                testRunner.setStatisticsHasHadUserInteraction(partitionOrigin, true, function() {
    49                     testRunner.statisticsUpdateCookieBlocking(function() {
    50                         // Check that the cookie is no longer blocked for localhost under 127.0.0.1.
    51                         openIframe(thirdPartyBaseUrl + subPathToGetCookies +  "&message=After user interaction, should receive first-party cookie.", runTest);
    52                     });
     49                    // Check that the cookie is no longer blocked for localhost under 127.0.0.1.
     50                    openIframe(thirdPartyBaseUrl + subPathToGetCookies +  "&message=After user interaction, should receive first-party cookie.", runTest);
    5351                });
    5452                break;
  • trunk/Source/WebKit/ChangeLog

    r251390 r251391  
     12019-10-21  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Update cookie blocking in NetworkStorageSession after first user interaction
     4        https://bugs.webkit.org/show_bug.cgi?id=203195
     5        <rdar://problem/56464567>
     6
     7        Reviewed by Alex Christensen and Chris Dumez.
     8
     9        This change makes sure that the state of cookie blocking in
     10        WebCore:: NetworkStorageSession is immediately updated if the logged
     11        user interaction was new for this domain. It adds a completion
     12        handler to WebResourceLoadStatisticsStore::logUserInteraction() so
     13        that the call properly waits for everything to be updated.
     14
     15        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
     16        (WebKit::CompletionHandler<void):
     17        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
     18        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
     19        (WebKit::ResourceLoadStatisticsMemoryStore::logUserInteraction):
     20        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
     21        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
     22        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
     23        (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
     24
    1252019-10-21  Dean Jackson  <dino@apple.com>
    226
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp

    r251213 r251391  
    13511351}
    13521352
    1353 void ResourceLoadStatisticsDatabaseStore::logUserInteraction(const TopFrameDomain& domain)
    1354 {
    1355     ASSERT(!RunLoop::isMain());
    1356 
     1353void ResourceLoadStatisticsDatabaseStore::logUserInteraction(const TopFrameDomain& domain, CompletionHandler<void()>&& completionHandler)
     1354{
     1355    ASSERT(!RunLoop::isMain());
     1356
     1357    bool didHavePreviousUserInteraction = hasHadUserInteraction(domain, OperatingDatesWindow::Long);
    13571358    ensureResourceStatisticsForRegistrableDomain(domain);
    13581359    setUserInteraction(domain, true, WallTime::now());
     1360    if (didHavePreviousUserInteraction) {
     1361        completionHandler();
     1362        return;
     1363    }
     1364    updateCookieBlocking(WTFMove(completionHandler));
    13591365}
    13601366
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h

    r251213 r251391  
    124124
    125125    void logFrameNavigation(const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame) override;
    126     void logUserInteraction(const TopFrameDomain&) override;
     126    void logUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&) override;
    127127    void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&) override;
    128128
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp

    r251213 r251391  
    404404}
    405405
    406 void ResourceLoadStatisticsMemoryStore::logUserInteraction(const TopFrameDomain& domain)
     406void ResourceLoadStatisticsMemoryStore::logUserInteraction(const TopFrameDomain& domain, CompletionHandler<void()>&& completionHandler)
    407407{
    408408    ASSERT(!RunLoop::isMain());
    409409
    410410    auto& statistics = ensureResourceStatisticsForRegistrableDomain(domain);
     411    bool didHavePreviousUserInteraction = statistics.hadUserInteraction;
    411412    statistics.hadUserInteraction = true;
    412413    statistics.mostRecentUserInteractionTime = WallTime::now();
     414    if (didHavePreviousUserInteraction) {
     415        completionHandler();
     416        return;
     417    }
     418    updateCookieBlocking(WTFMove(completionHandler));
    413419}
    414420
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h

    r250621 r251391  
    103103
    104104    void logFrameNavigation(const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame) override;
    105     void logUserInteraction(const TopFrameDomain&) override;
     105    void logUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&) override;
    106106    void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&) override;
    107107
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h

    r250621 r251391  
    167167
    168168    virtual void logFrameNavigation(const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame) = 0;
    169     virtual void logUserInteraction(const TopFrameDomain&) = 0;
     169    virtual void logUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&) = 0;
    170170    virtual void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&) = 0;
    171171
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

    r251213 r251391  
    548548
    549549    postTask([this, domain = domain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    550         if (m_statisticsStore)
    551             m_statisticsStore->logUserInteraction(domain);
    552         postTaskReply(WTFMove(completionHandler));
     550        auto innerCompletionHandler = [completionHandler = WTFMove(completionHandler)]() mutable {
     551            postTaskReply(WTFMove(completionHandler));
     552        };
     553        if (m_statisticsStore) {
     554            m_statisticsStore->logUserInteraction(domain, WTFMove(innerCompletionHandler));
     555            return;
     556        }
     557        innerCompletionHandler();
    553558    });
    554559}
Note: See TracChangeset for help on using the changeset viewer.