Changeset 228621 in webkit


Ignore:
Timestamp:
Feb 19, 2018 1:28:32 AM (6 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r228109 - Storage Access API: Add testRunner.getAllStorageAccessEntries() to make testing easier and more explicit
https://bugs.webkit.org/show_bug.cgi?id=181601
<rdar://problem/36475837>

Reviewed by Alex Christensen.

Source/WebCore:

No new tests. Existing test updated.

http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
was found to be flaky. With the testRunner.hasStorageAccessEntry() getter
it's possible to check access even if a frame doesn't respond timely to
postMessage after detach and attach.

  • platform/network/NetworkStorageSession.h:
  • platform/network/cf/NetworkStorageSessionCFNet.cpp:

(WebCore::NetworkStorageSession::getAllStorageAccessEntries const):

Source/WebKit:

http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
was found to be flaky. With the testRunner.hasStorageAccessEntry() getter
it's possible to check access even if a frame doesn't respond timely to
postMessage after detach and attach.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::getAllStorageAccessEntries):

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • UIProcess/API/Cocoa/WKWebsiteDataStore.mm:

(-[WKWebsiteDataStore _getAllStorageAccessEntries:]):

  • UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::getAllStorageAccessEntries):
(WebKit::NetworkProcessProxy::allStorageAccessEntriesResult):

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

(WebKit::WebsiteDataStore::getAllStorageAccessEntries):

  • UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
was found to be flaky. With the testRunner.hasStorageAccessEntry() getter
it's possible to check access even if a frame doesn't respond timely to
postMessage after detach and attach.

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

(WTR::InjectedBundle::didReceiveMessageToPage):

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setStorageAccessAPIEnabled):

Just moved for source file grouping.

(WTR::TestRunner::getAllStorageAccessEntries):
(WTR::TestRunner::callDidReceiveAllStorageAccessEntriesCallback):

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

(WTR::TestController::getAllStorageAccessEntries):

Note that this is just stubbed out, i.e. not implemented.

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

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
(WTR::TestInvocation::didReceiveAllStorageAccessEntries):

  • WebKitTestRunner/TestInvocation.h:
  • WebKitTestRunner/cocoa/TestControllerCocoa.mm:

(WTR::TestController::getAllStorageAccessEntries):

This is the Cocoa-specific version of this test infrastructure.

LayoutTests:

http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
was found to be flaky. With the testRunner.hasStorageAccessEntry() getter
it's possible to check access even if a frame doesn't respond timely to
postMessage after detach and attach.

  • http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt:
  • http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html:
  • platform/mac-wk2/TestExpectations:

http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html
no longer marked as flaky. Note that the wrong test was marked flaky. It should have been
http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html.

Location:
releases/WebKitGTK/webkit-2.20
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.20/LayoutTests/ChangeLog

    r228614 r228621  
     12018-02-05  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Add testRunner.getAllStorageAccessEntries() to make testing easier and more explicit
     4        https://bugs.webkit.org/show_bug.cgi?id=181601
     5        <rdar://problem/36475837>
     6
     7        Reviewed by Alex Christensen.
     8
     9        http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
     10        was found to be flaky. With the testRunner.hasStorageAccessEntry() getter
     11        it's possible to check access even if a frame doesn't respond timely to
     12        postMessage after detach and attach.
     13
     14        * http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt:
     15        * http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html:
     16        * platform/mac-wk2/TestExpectations:
     17            http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html
     18            no longer marked as flaky. Note that the wrong test was marked flaky. It should have been
     19            http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html.
     20
    1212018-02-05  Chris Dumez  <cdumez@apple.com>
    222
  • releases/WebKitGTK/webkit-2.20/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt

    r226409 r228621  
    55
    66PASS Storage access was granted. document.cookie == firstPartyCookie=value, cookies seen server-side == {"firstPartyCookie":"value"}
    7 PASS PASS. document.cookie == , cookies seen server-side == "No cookies"
     7PASS There is a storage access entry for localhost.
     8PASS There is no storage access entry for localhost after iframe detach.
    89PASS successfullyParsed is true
    910
  • releases/WebKitGTK/webkit-2.20/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html

    r226235 r228621  
    2424
    2525        const iframeID = "TheIframeThatRequestsStorageAccess";
    26         function askIframeIfItHasStorageAccess() {
    27             var iframeContentWindow = document.getElementById(iframeID).contentWindow;
    28             iframeContentWindow.postMessage("reportBackCookies", "http://localhost:8000");
     26        function askIfIframeStillHasStorageAccess() {
     27            testRunner.getAllStorageAccessEntries(function (arrayOfDomains) {
     28                var passed = true;
     29                for (var i = 0; i < arrayOfDomains.length; ++i) {
     30                    if (arrayOfDomains[i] === "localhost") {
     31                        passed = false;
     32                        break;
     33                    }
     34                }
     35                if (passed)
     36                    testPassed("There is no storage access entry for localhost after iframe detach.");
     37                else
     38                    testFailed("There is still a storage access entry for localhost after iframe detach.");
     39                finishTest();
     40            });
    2941        }
    3042
    31         function detachIframeAndAskWhetherItStillHasStorageAccess() {
    32             var theIframe = document.getElementById(iframeID);
    33             theIframe.onload = askIframeIfItHasStorageAccess;
    34             document.getElementsByTagName('body')[0].appendChild(theIframe);
     43        function detachIframeAndCheckWhetherItStillHasStorageAccess() {
     44            testRunner.getAllStorageAccessEntries(function (arrayOfDomains) {
     45                var passed = false;
     46                for (var i = 0; i < arrayOfDomains.length; ++i) {
     47                    if (arrayOfDomains[i] === "localhost") {
     48                        passed = true;
     49                        break;
     50                    }
     51                }
     52                if (passed)
     53                    testPassed("There is a storage access entry for localhost.");
     54                else
     55                    testFailed("There is no storage access entry for localhost.");
     56                var theIframe = document.getElementById(iframeID);
     57                theIframe.onload = askIfIframeStillHasStorageAccess;
     58                document.getElementsByTagName('body')[0].appendChild(theIframe);
     59            });
    3560        }
    3661
    37         const expectedPassMessages = 2;
    38         var passMessagesReceived = 0;
    3962        function receiveMessage(event) {
    4063            if (event.origin === "http://localhost:8000") {
    4164                if (event.data.indexOf("PASS") !== -1) {
    4265                    testPassed(event.data.replace("PASS ", ""));
    43                     passMessagesReceived++;
    44                     if (passMessagesReceived >= expectedPassMessages)
    45                         finishTest();
    46                     else
    47                         detachIframeAndAskWhetherItStillHasStorageAccess();
     66                    detachIframeAndCheckWhetherItStillHasStorageAccess();
    4867                } else {
    4968                    testFailed(event.data);
     
    6180            var centerY = element.offsetTop + element.offsetHeight / 2;
    6281            UIHelper.activateAt(centerX, centerY).then(
    63                 function () {
    64                     if (window.eventSender)
    65                         eventSender.keyDown("escape");
    66                     else {
    67                         testFailed("No eventSender.");
    68                         finishTest();
    69                     }
    70                 },
     82                function () { },
    7183                function () {
    7284                    testFailed("Promise rejected.");
     
    7890        function runTest() {
    7991            if (document.location.hash !== "#elementActivated") {
     92                document.location.hash = "elementActivated";
    8093                activateElement(iframeID);
    81                 document.location.hash = "elementActivated";
    8294            }
    8395        }
     
    100112</head>
    101113<body>
    102 <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" onload="runTest()" id="TheIframeThatRequestsStorageAccess" src="http://localhost:8000/storageAccess/resources/request-storage-access-iframe.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess"></iframe>
     114<div>
     115    <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" onload="runTest()" id="TheIframeThatRequestsStorageAccess" src="http://localhost:8000/storageAccess/resources/request-storage-access-iframe.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess"></iframe>
     116</div>
    103117</body>
    104118</html>
  • releases/WebKitGTK/webkit-2.20/LayoutTests/platform/mac-wk2/TestExpectations

    r228614 r228621  
    761761[ HighSierra+ ] http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction.html [ Pass ]
    762762[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html [ Pass ]
    763 
    764 webkit.org/b/181601 [ HighSierra+ Release ] http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html [ Pass Failure ]
     763[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html [ Pass ]
    765764
    766765webkit.org/b/173861 [ Release ] http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html [ Pass Timeout ]
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog

    r228614 r228621  
     12018-02-05  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Add testRunner.getAllStorageAccessEntries() to make testing easier and more explicit
     4        https://bugs.webkit.org/show_bug.cgi?id=181601
     5        <rdar://problem/36475837>
     6
     7        Reviewed by Alex Christensen.
     8
     9        No new tests. Existing test updated.
     10
     11        http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
     12        was found to be flaky. With the testRunner.hasStorageAccessEntry() getter
     13        it's possible to check access even if a frame doesn't respond timely to
     14        postMessage after detach and attach.
     15
     16        * platform/network/NetworkStorageSession.h:
     17        * platform/network/cf/NetworkStorageSessionCFNet.cpp:
     18        (WebCore::NetworkStorageSession::getAllStorageAccessEntries const):
     19
    1202018-02-05  Chris Dumez  <cdumez@apple.com>
    221
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/network/NetworkStorageSession.h

    r227987 r228621  
    107107    WEBCORE_EXPORT bool hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID) const;
    108108    WEBCORE_EXPORT bool hasStorageAccessForFrame(const ResourceRequest&, uint64_t frameID, uint64_t pageID) const;
     109    WEBCORE_EXPORT Vector<String> getAllStorageAccessEntries() const;
    109110    WEBCORE_EXPORT void grantStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID);
    110111    WEBCORE_EXPORT void removeStorageAccessForFrame(uint64_t frameID, uint64_t pageID);
  • releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp

    r227860 r228621  
    305305}
    306306
     307Vector<String> NetworkStorageSession::getAllStorageAccessEntries() const
     308{
     309    Vector<String> entries;
     310    for (auto& pageID : m_framesGrantedStorageAccess.keys()) {
     311        auto it1 = m_framesGrantedStorageAccess.find(pageID);
     312        for (auto& frameID : it1->value.keys())
     313            entries.append(it1->value.find(frameID)->value);
     314    }
     315    return entries;
     316}
     317   
    307318void NetworkStorageSession::grantStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID)
    308319{
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog

    r228613 r228621  
     12018-02-05  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Add testRunner.getAllStorageAccessEntries() to make testing easier and more explicit
     4        https://bugs.webkit.org/show_bug.cgi?id=181601
     5        <rdar://problem/36475837>
     6
     7        Reviewed by Alex Christensen.
     8
     9        http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
     10        was found to be flaky. With the testRunner.hasStorageAccessEntry() getter
     11        it's possible to check access even if a frame doesn't respond timely to
     12        postMessage after detach and attach.
     13
     14        * NetworkProcess/NetworkProcess.cpp:
     15        (WebKit::NetworkProcess::getAllStorageAccessEntries):
     16        * NetworkProcess/NetworkProcess.h:
     17        * NetworkProcess/NetworkProcess.messages.in:
     18        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
     19        (-[WKWebsiteDataStore _getAllStorageAccessEntries:]):
     20        * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
     21        * UIProcess/Network/NetworkProcessProxy.cpp:
     22        (WebKit::NetworkProcessProxy::getAllStorageAccessEntries):
     23        (WebKit::NetworkProcessProxy::allStorageAccessEntriesResult):
     24        * UIProcess/Network/NetworkProcessProxy.h:
     25        * UIProcess/Network/NetworkProcessProxy.messages.in:
     26        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     27        (WebKit::WebsiteDataStore::getAllStorageAccessEntries):
     28        * UIProcess/WebsiteData/WebsiteDataStore.h:
     29
    1302018-02-05  Daniel Bates  <dabates@apple.com>
    231
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r227627 r228621  
    362362}
    363363
     364void NetworkProcess::getAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
     365{
     366    if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     367        parentProcessConnection()->send(Messages::NetworkProcessProxy::AllStorageAccessEntriesResult(networkStorageSession->getAllStorageAccessEntries(), contextId), 0);
     368    else
     369        ASSERT_NOT_REACHED();
     370}
     371
    364372void NetworkProcess::grantStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
    365373{
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/NetworkProcess/NetworkProcess.h

    r228021 r228621  
    138138    void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst);
    139139    void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
     140    void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId);
    140141    void grantStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
    141142    void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains);
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r227364 r228621  
    8585    UpdatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, Vector<String> domainsToPartition, Vector<String> domainsToBlock, Vector<String> domainsToNeitherPartitionNorBlock, bool shouldClearFirst)
    8686    HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
     87    GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
    8788    GrantStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
    8889    RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction);
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm

    r228019 r228621  
    2929#if WK_API_ENABLED
    3030
     31#import "APIString.h"
    3132#import "WKHTTPCookieStoreInternal.h"
    3233#import "WKNSArray.h"
     
    657658}
    658659
     660- (void)_getAllStorageAccessEntries:(void (^)(NSArray<NSString *> *domains))completionHandler
     661{
     662    _websiteDataStore->websiteDataStore().getAllStorageAccessEntries([completionHandler = makeBlockPtr(completionHandler)](auto domains) {
     663        Vector<RefPtr<API::Object>> apiDomains;
     664        apiDomains.reserveInitialCapacity(domains.size());
     665        for (auto& domain : domains)
     666            apiDomains.uncheckedAppend(API::String::create(domain));
     667
     668        completionHandler(wrapper(API::Array::create(WTFMove(apiDomains))));
     669    });
     670}
     671
    659672@end
    660673
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h

    r228019 r228621  
    9090- (void)_resourceLoadStatisticsResetToConsistentState WK_API_AVAILABLE(macosx(10.13), ios(11.0));
    9191- (void)_setResourceLoadStatisticsTestingCallback:(nullable void (^)(WKWebsiteDataStore *, NSString *))callback WK_API_AVAILABLE(macosx(10.13), ios(11.0));
     92- (void)_getAllStorageAccessEntries:(void (^)(NSArray<NSString *> *domains))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    9293+ (void)_allowWebsiteDataRecordsForAllOrigins WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    9394@end
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r226482 r228621  
    434434    callback(wasGranted);
    435435}
     436
     437void NetworkProcessProxy::getAllStorageAccessEntries(PAL::SessionID sessionID, CompletionHandler<void(Vector<String>&& domains)>&& callback)
     438{
     439    auto contextId = nextRequestStorageAccessContextId();
     440    auto addResult = m_allStorageAccessEntriesCallbackMap.add(contextId, WTFMove(callback));
     441    ASSERT_UNUSED(addResult, addResult.isNewEntry);
     442    send(Messages::NetworkProcess::GetAllStorageAccessEntries(sessionID, contextId), 0);
     443}
     444
     445void NetworkProcessProxy::allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId)
     446{
     447    auto callback = m_allStorageAccessEntriesCallbackMap.take(contextId);
     448    callback(WTFMove(domains));
     449}
    436450#endif
    437451
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r226482 r228621  
    8181#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    8282    void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
     83    void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&);
    8384    void grantStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
    8485#endif
     
    135136#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    136137    void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
     138    void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
    137139#endif
    138140
     
    158160    HashMap<uint64_t, CompletionHandler<void(bool success)>> m_writeBlobToFilePathCallbackMap;
    159161    HashMap<uint64_t, WTF::CompletionHandler<void(bool wasGranted)>> m_storageAccessResponseCallbackMap;
     162    HashMap<uint64_t, CompletionHandler<void(Vector<String>&& domains)>> m_allStorageAccessEntriesCallbackMap;
    160163};
    161164
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in

    r226470 r228621  
    4747#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
    4848    StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
     49    AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
    4950}
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r227762 r228621  
    12031203}
    12041204
     1205void WebsiteDataStore::getAllStorageAccessEntries(CompletionHandler<void(Vector<String>&& domains)>&& callback)
     1206{
     1207    for (auto& processPool : processPools())
     1208        processPool->networkProcess()->getAllStorageAccessEntries(m_sessionID, WTFMove(callback));
     1209}
     1210
    12051211void WebsiteDataStore::grantStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool wasGranted)>&& callback)
    12061212{
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r228019 r228621  
    126126    void updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst);
    127127    void hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool hasAccess)>&& callback);
     128    void getAllStorageAccessEntries(CompletionHandler<void(Vector<String>&& domains)>&&);
    128129    void grantStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool wasGranted)>&& callback);
    129130    void removePrevalentDomains(const Vector<String>& domains);
  • releases/WebKitGTK/webkit-2.20/Tools/ChangeLog

    r228089 r228621  
     12018-02-05  John Wilander  <wilander@apple.com>
     2
     3        Storage Access API: Add testRunner.getAllStorageAccessEntries() to make testing easier and more explicit
     4        https://bugs.webkit.org/show_bug.cgi?id=181601
     5        <rdar://problem/36475837>
     6
     7        Reviewed by Alex Christensen.
     8
     9        http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
     10        was found to be flaky. With the testRunner.hasStorageAccessEntry() getter
     11        it's possible to check access even if a frame doesn't respond timely to
     12        postMessage after detach and attach.
     13
     14        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     15        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     16        (WTR::InjectedBundle::didReceiveMessageToPage):
     17        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     18        (WTR::TestRunner::setStorageAccessAPIEnabled):
     19            Just moved for source file grouping.
     20        (WTR::TestRunner::getAllStorageAccessEntries):
     21        (WTR::TestRunner::callDidReceiveAllStorageAccessEntriesCallback):
     22        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     23        * WebKitTestRunner/TestController.cpp:
     24        (WTR::TestController::getAllStorageAccessEntries):
     25            Note that this is just stubbed out, i.e. not implemented.
     26        * WebKitTestRunner/TestController.h:
     27        * WebKitTestRunner/TestInvocation.cpp:
     28        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     29        (WTR::TestInvocation::didReceiveAllStorageAccessEntries):
     30        * WebKitTestRunner/TestInvocation.h:
     31        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
     32        (WTR::TestController::getAllStorageAccessEntries):
     33            This is the Cocoa-specific version of this test infrastructure.
     34
    1352018-02-05  Alicia Boya García  <aboya@igalia.com>
    236
  • releases/WebKitGTK/webkit-2.20/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r227943 r228621  
    177177    void setAlwaysAcceptCookies(boolean accept);
    178178    void setCookieStoragePartitioningEnabled(boolean enabled);
    179     void setStorageAccessAPIEnabled(boolean enabled);
    180179
    181180    void overridePreference(DOMString preference, DOMString value);
     
    299298    void statisticsResetToConsistentState();
    300299
     300    // Storage Access API
     301    void setStorageAccessAPIEnabled(boolean enabled);
     302    void getAllStorageAccessEntries(object callback);
     303
    301304    // Open panel
    302305    void setOpenPanelFiles(object filesArray);
  • releases/WebKitGTK/webkit-2.20/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r227943 r228621  
    251251    }
    252252
     253    if (WKStringIsEqualToUTF8CString(messageName, "CallDidReceiveAllStorageAccessEntries")) {
     254        ASSERT(messageBody);
     255        ASSERT(WKGetTypeID(messageBody) == WKArrayGetTypeID());
     256
     257        WKArrayRef domainsArray = static_cast<WKArrayRef>(messageBody);
     258        auto size = WKArrayGetSize(domainsArray);
     259        Vector<String> domains;
     260        domains.reserveInitialCapacity(size);
     261        for (size_t i = 0; i < size; ++i) {
     262            WKTypeRef item = WKArrayGetItemAtIndex(domainsArray, i);
     263            if (item && WKGetTypeID(item) == WKStringGetTypeID())
     264                domains.append(toWTFString(static_cast<WKStringRef>(item)));
     265        }
     266
     267        m_testRunner->callDidReceiveAllStorageAccessEntriesCallback(domains);
     268        return;
     269    }
     270
    253271    if (WKStringIsEqualToUTF8CString(messageName, "CallDidRemoveAllSessionCredentialsCallback")) {
    254272        m_testRunner->callDidRemoveAllSessionCredentialsCallback();
  • releases/WebKitGTK/webkit-2.20/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r227943 r228621  
    653653    StatisticsDidClearThroughWebsiteDataRemovalCallbackID,
    654654    StatisticsDidSetPartitionOrBlockCookiesForHostCallbackID,
     655    AllStorageAccessEntriesCallbackID,
    655656    DidRemoveAllSessionCredentialsCallbackID,
    656657    GetApplicationManifestCallbackID,
     
    786787}
    787788
    788 void TestRunner::setStorageAccessAPIEnabled(bool enabled)
    789 {
    790     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStorageAccessAPIEnabled"));
    791    
    792     WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(enabled));
    793    
    794     WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
    795 }
    796    
    797789double TestRunner::preciseTime()
    798790{
     
    16861678}
    16871679
     1680void TestRunner::setStorageAccessAPIEnabled(bool enabled)
     1681{
     1682    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStorageAccessAPIEnabled"));
     1683   
     1684    WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(enabled));
     1685   
     1686    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
     1687}
     1688
     1689void TestRunner::getAllStorageAccessEntries(JSValueRef callback)
     1690{
     1691    cacheTestRunnerCallback(AllStorageAccessEntriesCallbackID, callback);
     1692   
     1693    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("GetAllStorageAccessEntries"));
     1694    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
     1695}
     1696
     1697void TestRunner::callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains)
     1698{
     1699    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::singleton().page()->page());
     1700    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
     1701   
     1702    StringBuilder stringBuilder;
     1703    stringBuilder.appendLiteral("[");
     1704    bool firstDomain = true;
     1705    for (auto& domain : domains) {
     1706        if (firstDomain)
     1707            firstDomain = false;
     1708        else
     1709            stringBuilder.appendLiteral(", ");
     1710        stringBuilder.appendLiteral("\"");
     1711        stringBuilder.append(domain);
     1712        stringBuilder.appendLiteral("\"");
     1713    }
     1714    stringBuilder.appendLiteral("]");
     1715   
     1716    JSValueRef result = JSValueMakeFromJSONString(context, JSStringCreateWithUTF8CString(stringBuilder.toString().utf8().data()));
     1717
     1718    callTestRunnerCallback(AllStorageAccessEntriesCallbackID, 1, &result);
     1719}
     1720
    16881721#if PLATFORM(MAC)
    16891722void TestRunner::connectMockGamepad(unsigned index)
  • releases/WebKitGTK/webkit-2.20/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r227943 r228621  
    281281    void setAlwaysAcceptCookies(bool);
    282282    void setCookieStoragePartitioningEnabled(bool);
    283     void setStorageAccessAPIEnabled(bool);
    284283
    285284    // Custom full screen behavior.
     
    400399    void statisticsResetToConsistentState();
    401400
     401    // Storage Access API
     402    void setStorageAccessAPIEnabled(bool);
     403    void getAllStorageAccessEntries(JSValueRef callback);
     404    void callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains);
     405
    402406    // Open panel
    403407    void setOpenPanelFiles(JSValueRef);
  • releases/WebKitGTK/webkit-2.20/Tools/WebKitTestRunner/TestController.cpp

    r228025 r228621  
    26992699}
    27002700
     2701void TestController::getAllStorageAccessEntries()
     2702{
     2703    // FIXME: Implement C API version of this test.
     2704}
     2705
    27012706#endif
    27022707
  • releases/WebKitGTK/webkit-2.20/Tools/WebKitTestRunner/TestController.h

    r228025 r228621  
    185185    void statisticsResetToConsistentState();
    186186
     187    void getAllStorageAccessEntries();
     188
    187189    WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }
    188190    void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; }
  • releases/WebKitGTK/webkit-2.20/Tools/WebKitTestRunner/TestInvocation.cpp

    r227943 r228621  
    836836        return nullptr;
    837837    }
    838    
     838
     839    if (WKStringIsEqualToUTF8CString(messageName, "GetAllStorageAccessEntries")) {
     840        TestController::singleton().getAllStorageAccessEntries();
     841        return nullptr;
     842    }
     843
    839844    if (WKStringIsEqualToUTF8CString(messageName, "SetAllowsAnySSLCertificate")) {
    840845        TestController::singleton().setAllowsAnySSLCertificate(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
     
    13521357}
    13531358
     1359void TestInvocation::didReceiveAllStorageAccessEntries(Vector<String>& domains)
     1360{
     1361    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidReceiveAllStorageAccessEntries"));
     1362   
     1363    WKRetainPtr<WKMutableArrayRef> messageBody(AdoptWK, WKMutableArrayCreate());
     1364    for (auto& domain : domains)
     1365        WKArrayAppendItem(messageBody.get(), adoptWK(WKStringCreateWithUTF8CString(domain.utf8().data())).get());
     1366   
     1367    WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), messageBody.get());
     1368}
     1369
    13541370void TestInvocation::didRemoveAllSessionCredentials()
    13551371{
  • releases/WebKitGTK/webkit-2.20/Tools/WebKitTestRunner/TestInvocation.h

    r227943 r228621  
    7474    void didClearStatisticsThroughWebsiteDataRemoval();
    7575    void didSetPartitionOrBlockCookiesForHost();
     76    void didReceiveAllStorageAccessEntries(Vector<String>& domains);
    7677
    7778    void didRemoveAllSessionCredentials();
  • releases/WebKitGTK/webkit-2.20/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm

    r228019 r228621  
    460460    [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsResetToConsistentState];
    461461}
     462
     463void TestController::getAllStorageAccessEntries()
     464{
     465    [globalWebViewConfiguration.websiteDataStore _getAllStorageAccessEntries:^(NSArray<NSString *> *nsDomains) {
     466        Vector<String> domains;
     467        domains.reserveInitialCapacity(nsDomains.count);
     468        for (NSString *domain : nsDomains)
     469            domains.uncheckedAppend(domain);
     470        m_currentInvocation->didReceiveAllStorageAccessEntries(domains);
     471    }];
     472}
     473
    462474#endif // WK_API_ENABLED
    463475
Note: See TracChangeset for help on using the changeset viewer.