Changeset 228109 in webkit
- Timestamp:
- Feb 5, 2018 11:35:13 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r228104 r228109 1 2018-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 1 21 2018-02-05 Matt Lewis <jlewis3@apple.com> 2 22 -
trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt
r226409 r228109 5 5 6 6 PASS 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" 7 PASS There is a storage access entry for localhost. 8 PASS There is no storage access entry for localhost after iframe detach. 8 9 PASS successfullyParsed is true 9 10 -
trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html
r226235 r228109 24 24 25 25 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 }); 29 41 } 30 42 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 }); 35 60 } 36 61 37 const expectedPassMessages = 2;38 var passMessagesReceived = 0;39 62 function receiveMessage(event) { 40 63 if (event.origin === "http://localhost:8000") { 41 64 if (event.data.indexOf("PASS") !== -1) { 42 65 testPassed(event.data.replace("PASS ", "")); 43 passMessagesReceived++; 44 if (passMessagesReceived >= expectedPassMessages) 45 finishTest(); 46 else 47 detachIframeAndAskWhetherItStillHasStorageAccess(); 66 detachIframeAndCheckWhetherItStillHasStorageAccess(); 48 67 } else { 49 68 testFailed(event.data); … … 61 80 var centerY = element.offsetTop + element.offsetHeight / 2; 62 81 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 () { }, 71 83 function () { 72 84 testFailed("Promise rejected."); … … 78 90 function runTest() { 79 91 if (document.location.hash !== "#elementActivated") { 92 document.location.hash = "elementActivated"; 80 93 activateElement(iframeID); 81 document.location.hash = "elementActivated";82 94 } 83 95 } … … 100 112 </head> 101 113 <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> 103 117 </body> 104 118 </html> -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r228101 r228109 761 761 [ HighSierra+ ] http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction.html [ Pass ] 762 762 [ 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 ] 765 764 766 765 webkit.org/b/173861 [ Release ] http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html [ Pass Timeout ] -
trunk/Source/WebCore/ChangeLog
r228103 r228109 1 2018-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 1 20 2018-02-05 Youenn Fablet <youenn@apple.com> 2 21 -
trunk/Source/WebCore/platform/network/NetworkStorageSession.h
r227987 r228109 107 107 WEBCORE_EXPORT bool hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID) const; 108 108 WEBCORE_EXPORT bool hasStorageAccessForFrame(const ResourceRequest&, uint64_t frameID, uint64_t pageID) const; 109 WEBCORE_EXPORT Vector<String> getAllStorageAccessEntries() const; 109 110 WEBCORE_EXPORT void grantStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID); 110 111 WEBCORE_EXPORT void removeStorageAccessForFrame(uint64_t frameID, uint64_t pageID); -
trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
r227860 r228109 305 305 } 306 306 307 Vector<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 307 318 void NetworkStorageSession::grantStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID) 308 319 { -
trunk/Source/WebKit/ChangeLog
r228100 r228109 1 2018-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 1 30 2018-02-05 Daniel Bates <dabates@apple.com> 2 31 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r227627 r228109 362 362 } 363 363 364 void 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 364 372 void NetworkProcess::grantStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId) 365 373 { -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r228021 r228109 138 138 void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst); 139 139 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); 140 141 void grantStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId); 141 142 void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains); -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r227364 r228109 85 85 UpdatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, Vector<String> domainsToPartition, Vector<String> domainsToBlock, Vector<String> domainsToNeitherPartitionNorBlock, bool shouldClearFirst) 86 86 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) 87 88 GrantStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId) 88 89 RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction); -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r228019 r228109 29 29 #if WK_API_ENABLED 30 30 31 #import "APIString.h" 31 32 #import "WKHTTPCookieStoreInternal.h" 32 33 #import "WKNSArray.h" … … 657 658 } 658 659 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 659 672 @end 660 673 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
r228019 r228109 90 90 - (void)_resourceLoadStatisticsResetToConsistentState WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 91 91 - (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)); 92 93 + (void)_allowWebsiteDataRecordsForAllOrigins WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 93 94 @end -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r226482 r228109 434 434 callback(wasGranted); 435 435 } 436 437 void 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 445 void NetworkProcessProxy::allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId) 446 { 447 auto callback = m_allStorageAccessEntriesCallbackMap.take(contextId); 448 callback(WTFMove(domains)); 449 } 436 450 #endif 437 451 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r226482 r228109 81 81 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 82 82 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)>&&); 83 84 void grantStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback); 84 85 #endif … … 135 136 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 136 137 void storageAccessRequestResult(bool wasGranted, uint64_t contextId); 138 void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId); 137 139 #endif 138 140 … … 158 160 HashMap<uint64_t, CompletionHandler<void(bool success)>> m_writeBlobToFilePathCallbackMap; 159 161 HashMap<uint64_t, WTF::CompletionHandler<void(bool wasGranted)>> m_storageAccessResponseCallbackMap; 162 HashMap<uint64_t, CompletionHandler<void(Vector<String>&& domains)>> m_allStorageAccessEntriesCallbackMap; 160 163 }; 161 164 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in
r226470 r228109 47 47 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 48 48 StorageAccessRequestResult(bool wasGranted, uint64_t contextId) 49 AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId) 49 50 } -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r227762 r228109 1203 1203 } 1204 1204 1205 void WebsiteDataStore::getAllStorageAccessEntries(CompletionHandler<void(Vector<String>&& domains)>&& callback) 1206 { 1207 for (auto& processPool : processPools()) 1208 processPool->networkProcess()->getAllStorageAccessEntries(m_sessionID, WTFMove(callback)); 1209 } 1210 1205 1211 void WebsiteDataStore::grantStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool wasGranted)>&& callback) 1206 1212 { -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r228019 r228109 126 126 void updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst); 127 127 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)>&&); 128 129 void grantStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool wasGranted)>&& callback); 129 130 void removePrevalentDomains(const Vector<String>& domains); -
trunk/Tools/ChangeLog
r228106 r228109 1 2018-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 1 35 2018-02-05 Basuke Suzuki <Basuke.Suzuki@sony.com> 2 36 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r227943 r228109 177 177 void setAlwaysAcceptCookies(boolean accept); 178 178 void setCookieStoragePartitioningEnabled(boolean enabled); 179 void setStorageAccessAPIEnabled(boolean enabled);180 179 181 180 void overridePreference(DOMString preference, DOMString value); … … 299 298 void statisticsResetToConsistentState(); 300 299 300 // Storage Access API 301 void setStorageAccessAPIEnabled(boolean enabled); 302 void getAllStorageAccessEntries(object callback); 303 301 304 // Open panel 302 305 void setOpenPanelFiles(object filesArray); -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
r227943 r228109 251 251 } 252 252 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 253 271 if (WKStringIsEqualToUTF8CString(messageName, "CallDidRemoveAllSessionCredentialsCallback")) { 254 272 m_testRunner->callDidRemoveAllSessionCredentialsCallback(); -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r227943 r228109 653 653 StatisticsDidClearThroughWebsiteDataRemovalCallbackID, 654 654 StatisticsDidSetPartitionOrBlockCookiesForHostCallbackID, 655 AllStorageAccessEntriesCallbackID, 655 656 DidRemoveAllSessionCredentialsCallbackID, 656 657 GetApplicationManifestCallbackID, … … 786 787 } 787 788 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 797 789 double TestRunner::preciseTime() 798 790 { … … 1686 1678 } 1687 1679 1680 void 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 1689 void 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 1697 void 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 1688 1721 #if PLATFORM(MAC) 1689 1722 void TestRunner::connectMockGamepad(unsigned index) -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r227943 r228109 281 281 void setAlwaysAcceptCookies(bool); 282 282 void setCookieStoragePartitioningEnabled(bool); 283 void setStorageAccessAPIEnabled(bool);284 283 285 284 // Custom full screen behavior. … … 400 399 void statisticsResetToConsistentState(); 401 400 401 // Storage Access API 402 void setStorageAccessAPIEnabled(bool); 403 void getAllStorageAccessEntries(JSValueRef callback); 404 void callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains); 405 402 406 // Open panel 403 407 void setOpenPanelFiles(JSValueRef); -
trunk/Tools/WebKitTestRunner/TestController.cpp
r228025 r228109 2699 2699 } 2700 2700 2701 void TestController::getAllStorageAccessEntries() 2702 { 2703 // FIXME: Implement C API version of this test. 2704 } 2705 2701 2706 #endif 2702 2707 -
trunk/Tools/WebKitTestRunner/TestController.h
r228025 r228109 185 185 void statisticsResetToConsistentState(); 186 186 187 void getAllStorageAccessEntries(); 188 187 189 WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); } 188 190 void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; } -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r227943 r228109 836 836 return nullptr; 837 837 } 838 838 839 if (WKStringIsEqualToUTF8CString(messageName, "GetAllStorageAccessEntries")) { 840 TestController::singleton().getAllStorageAccessEntries(); 841 return nullptr; 842 } 843 839 844 if (WKStringIsEqualToUTF8CString(messageName, "SetAllowsAnySSLCertificate")) { 840 845 TestController::singleton().setAllowsAnySSLCertificate(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody))); … … 1352 1357 } 1353 1358 1359 void 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 1354 1370 void TestInvocation::didRemoveAllSessionCredentials() 1355 1371 { -
trunk/Tools/WebKitTestRunner/TestInvocation.h
r227943 r228109 74 74 void didClearStatisticsThroughWebsiteDataRemoval(); 75 75 void didSetPartitionOrBlockCookiesForHost(); 76 void didReceiveAllStorageAccessEntries(Vector<String>& domains); 76 77 77 78 void didRemoveAllSessionCredentials(); -
trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
r228019 r228109 460 460 [globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsResetToConsistentState]; 461 461 } 462 463 void 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 462 474 #endif // WK_API_ENABLED 463 475
Note: See TracChangeset
for help on using the changeset viewer.