Diff
Modified: trunk/LayoutTests/ChangeLog (228108 => 228109)
--- trunk/LayoutTests/ChangeLog 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/LayoutTests/ChangeLog 2018-02-05 19:35:13 UTC (rev 228109)
@@ -1,3 +1,23 @@
+2018-02-05 John Wilander <wilan...@apple.com>
+
+ 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.
+
+ 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.
+
2018-02-05 Matt Lewis <jlew...@apple.com>
Skipped imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html
Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt (228108 => 228109)
--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access-expected.txt 2018-02-05 19:35:13 UTC (rev 228109)
@@ -4,7 +4,8 @@
PASS Storage access was granted. document.cookie == firstPartyCookie=value, cookies seen server-side == {"firstPartyCookie":"value"}
-PASS PASS. document.cookie == , cookies seen server-side == "No cookies"
+PASS There is a storage access entry for localhost.
+PASS There is no storage access entry for localhost after iframe detach.
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html (228108 => 228109)
--- trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html 2018-02-05 19:35:13 UTC (rev 228109)
@@ -23,28 +23,47 @@
}
const iframeID = "TheIframeThatRequestsStorageAccess";
- function askIframeIfItHasStorageAccess() {
- var iframeContentWindow = document.getElementById(iframeID).contentWindow;
- iframeContentWindow.postMessage("reportBackCookies", "http://localhost:8000");
+ function askIfIframeStillHasStorageAccess() {
+ testRunner.getAllStorageAccessEntries(function (arrayOfDomains) {
+ var passed = true;
+ for (var i = 0; i < arrayOfDomains.length; ++i) {
+ if (arrayOfDomains[i] === "localhost") {
+ passed = false;
+ break;
+ }
+ }
+ if (passed)
+ testPassed("There is no storage access entry for localhost after iframe detach.");
+ else
+ testFailed("There is still a storage access entry for localhost after iframe detach.");
+ finishTest();
+ });
}
- function detachIframeAndAskWhetherItStillHasStorageAccess() {
- var theIframe = document.getElementById(iframeID);
- theIframe._onload_ = askIframeIfItHasStorageAccess;
- document.getElementsByTagName('body')[0].appendChild(theIframe);
+ function detachIframeAndCheckWhetherItStillHasStorageAccess() {
+ testRunner.getAllStorageAccessEntries(function (arrayOfDomains) {
+ var passed = false;
+ for (var i = 0; i < arrayOfDomains.length; ++i) {
+ if (arrayOfDomains[i] === "localhost") {
+ passed = true;
+ break;
+ }
+ }
+ if (passed)
+ testPassed("There is a storage access entry for localhost.");
+ else
+ testFailed("There is no storage access entry for localhost.");
+ var theIframe = document.getElementById(iframeID);
+ theIframe._onload_ = askIfIframeStillHasStorageAccess;
+ document.getElementsByTagName('body')[0].appendChild(theIframe);
+ });
}
- const expectedPassMessages = 2;
- var passMessagesReceived = 0;
function receiveMessage(event) {
if (event.origin === "http://localhost:8000") {
if (event.data.indexOf("PASS") !== -1) {
testPassed(event.data.replace("PASS ", ""));
- passMessagesReceived++;
- if (passMessagesReceived >= expectedPassMessages)
- finishTest();
- else
- detachIframeAndAskWhetherItStillHasStorageAccess();
+ detachIframeAndCheckWhetherItStillHasStorageAccess();
} else {
testFailed(event.data);
finishTest();
@@ -60,15 +79,8 @@
var centerX = element.offsetLeft + element.offsetWidth / 2;
var centerY = element.offsetTop + element.offsetHeight / 2;
UIHelper.activateAt(centerX, centerY).then(
+ function () { },
function () {
- if (window.eventSender)
- eventSender.keyDown("escape");
- else {
- testFailed("No eventSender.");
- finishTest();
- }
- },
- function () {
testFailed("Promise rejected.");
finishTest();
}
@@ -77,8 +89,8 @@
function runTest() {
if (document.location.hash !== "#elementActivated") {
+ document.location.hash = "elementActivated";
activateElement(iframeID);
- document.location.hash = "elementActivated";
}
}
@@ -99,6 +111,8 @@
</script>
</head>
<body>
-<iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="TheIframeThatRequestsStorageAccess" src=""
+<div>
+ <iframe sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals" _onload_="runTest()" id="TheIframeThatRequestsStorageAccess" src=""
+</div>
</body>
</html>
\ No newline at end of file
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (228108 => 228109)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2018-02-05 19:35:13 UTC (rev 228109)
@@ -760,9 +760,8 @@
[ HighSierra+ ] http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-non-recent-user-interaction.html [ Pass ]
[ HighSierra+ ] http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-recent-user-interaction.html [ Pass ]
[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-detach-should-not-have-access.html [ Pass ]
+[ HighSierra+ ] http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html [ Pass ]
-webkit.org/b/181601 [ HighSierra+ Release ] http/tests/storageAccess/request-and-grant-access-then-navigate-should-not-have-access.html [ Pass Failure ]
-
webkit.org/b/173861 [ Release ] http/tests/webrtc/filtering-ice-candidate-same-origin-frame.html [ Pass Timeout ]
webkit.org/b/173861 [ Release ] http/tests/webrtc/filtering-ice-candidate-cross-origin-frame.html [ Pass Timeout ]
Modified: trunk/Source/WebCore/ChangeLog (228108 => 228109)
--- trunk/Source/WebCore/ChangeLog 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebCore/ChangeLog 2018-02-05 19:35:13 UTC (rev 228109)
@@ -1,3 +1,22 @@
+2018-02-05 John Wilander <wilan...@apple.com>
+
+ 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.
+
+ 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):
+
2018-02-05 Youenn Fablet <you...@apple.com>
Use downcast in createLinkPreloadResourceClient
Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (228108 => 228109)
--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2018-02-05 19:35:13 UTC (rev 228109)
@@ -106,6 +106,7 @@
WEBCORE_EXPORT void removePrevalentDomains(const Vector<String>& domains);
WEBCORE_EXPORT bool hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID) const;
WEBCORE_EXPORT bool hasStorageAccessForFrame(const ResourceRequest&, uint64_t frameID, uint64_t pageID) const;
+ WEBCORE_EXPORT Vector<String> getAllStorageAccessEntries() const;
WEBCORE_EXPORT void grantStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID);
WEBCORE_EXPORT void removeStorageAccessForFrame(uint64_t frameID, uint64_t pageID);
WEBCORE_EXPORT void removeStorageAccessForAllFramesOnPage(uint64_t pageID);
Modified: trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp (228108 => 228109)
--- trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp 2018-02-05 19:35:13 UTC (rev 228109)
@@ -304,6 +304,17 @@
return hasStorageAccessForFrame(getPartitioningDomain(request.url()), getPartitioningDomain(request.firstPartyForCookies()), frameID, pageID);
}
+Vector<String> NetworkStorageSession::getAllStorageAccessEntries() const
+{
+ Vector<String> entries;
+ for (auto& pageID : m_framesGrantedStorageAccess.keys()) {
+ auto it1 = m_framesGrantedStorageAccess.find(pageID);
+ for (auto& frameID : it1->value.keys())
+ entries.append(it1->value.find(frameID)->value);
+ }
+ return entries;
+}
+
void NetworkStorageSession::grantStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID)
{
UNUSED_PARAM(firstPartyDomain);
Modified: trunk/Source/WebKit/ChangeLog (228108 => 228109)
--- trunk/Source/WebKit/ChangeLog 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/ChangeLog 2018-02-05 19:35:13 UTC (rev 228109)
@@ -1,3 +1,32 @@
+2018-02-05 John Wilander <wilan...@apple.com>
+
+ 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.
+
+ 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:
+
2018-02-05 Daniel Bates <daba...@apple.com>
Disallow evaluating _javascript_ from NPP_Destroy() in WebKit
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (228108 => 228109)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-02-05 19:35:13 UTC (rev 228109)
@@ -361,6 +361,14 @@
ASSERT_NOT_REACHED();
}
+void NetworkProcess::getAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
+{
+ if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
+ parentProcessConnection()->send(Messages::NetworkProcessProxy::AllStorageAccessEntriesResult(networkStorageSession->getAllStorageAccessEntries(), contextId), 0);
+ else
+ ASSERT_NOT_REACHED();
+}
+
void NetworkProcess::grantStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
{
bool isStorageGranted = false;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (228108 => 228109)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2018-02-05 19:35:13 UTC (rev 228109)
@@ -137,6 +137,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst);
void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
+ void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId);
void grantStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains);
#endif
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (228108 => 228109)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2018-02-05 19:35:13 UTC (rev 228109)
@@ -84,6 +84,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
UpdatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, Vector<String> domainsToPartition, Vector<String> domainsToBlock, Vector<String> domainsToNeitherPartitionNorBlock, bool shouldClearFirst)
HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
+ GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
GrantStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction);
#endif
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (228108 => 228109)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2018-02-05 19:35:13 UTC (rev 228109)
@@ -28,6 +28,7 @@
#if WK_API_ENABLED
+#import "APIString.h"
#import "WKHTTPCookieStoreInternal.h"
#import "WKNSArray.h"
#import "WKWebsiteDataRecordInternal.h"
@@ -656,6 +657,18 @@
WebKit::WebsiteDataStore::allowWebsiteDataRecordsForAllOrigins();
}
+- (void)_getAllStorageAccessEntries:(void (^)(NSArray<NSString *> *domains))completionHandler
+{
+ _websiteDataStore->websiteDataStore().getAllStorageAccessEntries([completionHandler = makeBlockPtr(completionHandler)](auto domains) {
+ Vector<RefPtr<API::Object>> apiDomains;
+ apiDomains.reserveInitialCapacity(domains.size());
+ for (auto& domain : domains)
+ apiDomains.uncheckedAppend(API::String::create(domain));
+
+ completionHandler(wrapper(API::Array::create(WTFMove(apiDomains))));
+ });
+}
+
@end
#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (228108 => 228109)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2018-02-05 19:35:13 UTC (rev 228109)
@@ -89,6 +89,7 @@
- (void)_resourceLoadStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours:(unsigned)hours completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_resourceLoadStatisticsResetToConsistentState WK_API_AVAILABLE(macosx(10.13), ios(11.0));
- (void)_setResourceLoadStatisticsTestingCallback:(nullable void (^)(WKWebsiteDataStore *, NSString *))callback WK_API_AVAILABLE(macosx(10.13), ios(11.0));
+- (void)_getAllStorageAccessEntries:(void (^)(NSArray<NSString *> *domains))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+ (void)_allowWebsiteDataRecordsForAllOrigins WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@end
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (228108 => 228109)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2018-02-05 19:35:13 UTC (rev 228109)
@@ -433,6 +433,20 @@
auto callback = m_storageAccessResponseCallbackMap.take(contextId);
callback(wasGranted);
}
+
+void NetworkProcessProxy::getAllStorageAccessEntries(PAL::SessionID sessionID, CompletionHandler<void(Vector<String>&& domains)>&& callback)
+{
+ auto contextId = nextRequestStorageAccessContextId();
+ auto addResult = m_allStorageAccessEntriesCallbackMap.add(contextId, WTFMove(callback));
+ ASSERT_UNUSED(addResult, addResult.isNewEntry);
+ send(Messages::NetworkProcess::GetAllStorageAccessEntries(sessionID, contextId), 0);
+}
+
+void NetworkProcessProxy::allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId)
+{
+ auto callback = m_allStorageAccessEntriesCallbackMap.take(contextId);
+ callback(WTFMove(domains));
+}
#endif
void NetworkProcessProxy::sendProcessWillSuspendImminently()
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (228108 => 228109)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2018-02-05 19:35:13 UTC (rev 228109)
@@ -80,6 +80,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
+ void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&);
void grantStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
#endif
@@ -134,6 +135,7 @@
#endif
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
+ void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
#endif
// ProcessLauncher::Client
@@ -157,6 +159,7 @@
HashMap<uint64_t, CompletionHandler<void(bool success)>> m_writeBlobToFilePathCallbackMap;
HashMap<uint64_t, WTF::CompletionHandler<void(bool wasGranted)>> m_storageAccessResponseCallbackMap;
+ HashMap<uint64_t, CompletionHandler<void(Vector<String>&& domains)>> m_allStorageAccessEntriesCallbackMap;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (228108 => 228109)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2018-02-05 19:35:13 UTC (rev 228109)
@@ -46,4 +46,5 @@
#endif
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
+ AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
}
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (228108 => 228109)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-02-05 19:35:13 UTC (rev 228109)
@@ -1202,6 +1202,12 @@
processPool->networkProcess()->hasStorageAccessForFrame(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(callback));
}
+void WebsiteDataStore::getAllStorageAccessEntries(CompletionHandler<void(Vector<String>&& domains)>&& callback)
+{
+ for (auto& processPool : processPools())
+ processPool->networkProcess()->getAllStorageAccessEntries(m_sessionID, WTFMove(callback));
+}
+
void WebsiteDataStore::grantStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool wasGranted)>&& callback)
{
for (auto& processPool : processPools())
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (228108 => 228109)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2018-02-05 19:35:13 UTC (rev 228109)
@@ -125,6 +125,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
void updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst);
void hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool hasAccess)>&& callback);
+ void getAllStorageAccessEntries(CompletionHandler<void(Vector<String>&& domains)>&&);
void grantStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool wasGranted)>&& callback);
void removePrevalentDomains(const Vector<String>& domains);
void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback);
Modified: trunk/Tools/ChangeLog (228108 => 228109)
--- trunk/Tools/ChangeLog 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/ChangeLog 2018-02-05 19:35:13 UTC (rev 228109)
@@ -1,3 +1,37 @@
+2018-02-05 John Wilander <wilan...@apple.com>
+
+ 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.
+
+ 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.
+
2018-02-05 Basuke Suzuki <basuke.suz...@sony.com>
[Win] Enable multi CPU building on MSBuild.
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (228108 => 228109)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2018-02-05 19:35:13 UTC (rev 228109)
@@ -176,7 +176,6 @@
// Cookies testing
void setAlwaysAcceptCookies(boolean accept);
void setCookieStoragePartitioningEnabled(boolean enabled);
- void setStorageAccessAPIEnabled(boolean enabled);
void overridePreference(DOMString preference, DOMString value);
@@ -298,6 +297,10 @@
void statisticsClearThroughWebsiteDataRemoval(object callback);
void statisticsResetToConsistentState();
+ // Storage Access API
+ void setStorageAccessAPIEnabled(boolean enabled);
+ void getAllStorageAccessEntries(object callback);
+
// Open panel
void setOpenPanelFiles(object filesArray);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (228108 => 228109)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp 2018-02-05 19:35:13 UTC (rev 228109)
@@ -250,6 +250,24 @@
return;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "CallDidReceiveAllStorageAccessEntries")) {
+ ASSERT(messageBody);
+ ASSERT(WKGetTypeID(messageBody) == WKArrayGetTypeID());
+
+ WKArrayRef domainsArray = static_cast<WKArrayRef>(messageBody);
+ auto size = WKArrayGetSize(domainsArray);
+ Vector<String> domains;
+ domains.reserveInitialCapacity(size);
+ for (size_t i = 0; i < size; ++i) {
+ WKTypeRef item = WKArrayGetItemAtIndex(domainsArray, i);
+ if (item && WKGetTypeID(item) == WKStringGetTypeID())
+ domains.append(toWTFString(static_cast<WKStringRef>(item)));
+ }
+
+ m_testRunner->callDidReceiveAllStorageAccessEntriesCallback(domains);
+ return;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "CallDidRemoveAllSessionCredentialsCallback")) {
m_testRunner->callDidRemoveAllSessionCredentialsCallback();
return;
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (228108 => 228109)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2018-02-05 19:35:13 UTC (rev 228109)
@@ -652,6 +652,7 @@
StatisticsDidRunTelemetryCallbackID,
StatisticsDidClearThroughWebsiteDataRemovalCallbackID,
StatisticsDidSetPartitionOrBlockCookiesForHostCallbackID,
+ AllStorageAccessEntriesCallbackID,
DidRemoveAllSessionCredentialsCallbackID,
GetApplicationManifestCallbackID,
FirstUIScriptCallbackID = 100
@@ -785,15 +786,6 @@
WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
}
-void TestRunner::setStorageAccessAPIEnabled(bool enabled)
-{
- WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStorageAccessAPIEnabled"));
-
- WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(enabled));
-
- WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
-}
-
double TestRunner::preciseTime()
{
return currentTime();
@@ -1685,6 +1677,47 @@
WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
}
+void TestRunner::setStorageAccessAPIEnabled(bool enabled)
+{
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStorageAccessAPIEnabled"));
+
+ WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(enabled));
+
+ WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
+void TestRunner::getAllStorageAccessEntries(JSValueRef callback)
+{
+ cacheTestRunnerCallback(AllStorageAccessEntriesCallbackID, callback);
+
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("GetAllStorageAccessEntries"));
+ WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), 0, nullptr);
+}
+
+void TestRunner::callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains)
+{
+ WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::singleton().page()->page());
+ JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
+
+ StringBuilder stringBuilder;
+ stringBuilder.appendLiteral("[");
+ bool firstDomain = true;
+ for (auto& domain : domains) {
+ if (firstDomain)
+ firstDomain = false;
+ else
+ stringBuilder.appendLiteral(", ");
+ stringBuilder.appendLiteral("\"");
+ stringBuilder.append(domain);
+ stringBuilder.appendLiteral("\"");
+ }
+ stringBuilder.appendLiteral("]");
+
+ JSValueRef result = JSValueMakeFromJSONString(context, JSStringCreateWithUTF8CString(stringBuilder.toString().utf8().data()));
+
+ callTestRunnerCallback(AllStorageAccessEntriesCallbackID, 1, &result);
+}
+
#if PLATFORM(MAC)
void TestRunner::connectMockGamepad(unsigned index)
{
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (228108 => 228109)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2018-02-05 19:35:13 UTC (rev 228109)
@@ -280,7 +280,6 @@
// Cookies testing
void setAlwaysAcceptCookies(bool);
void setCookieStoragePartitioningEnabled(bool);
- void setStorageAccessAPIEnabled(bool);
// Custom full screen behavior.
void setHasCustomFullScreenBehavior(bool value) { m_customFullScreenBehavior = value; }
@@ -399,6 +398,11 @@
void statisticsCallClearThroughWebsiteDataRemovalCallback();
void statisticsResetToConsistentState();
+ // Storage Access API
+ void setStorageAccessAPIEnabled(bool);
+ void getAllStorageAccessEntries(JSValueRef callback);
+ void callDidReceiveAllStorageAccessEntriesCallback(Vector<String>& domains);
+
// Open panel
void setOpenPanelFiles(JSValueRef);
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (228108 => 228109)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2018-02-05 19:35:13 UTC (rev 228109)
@@ -2698,6 +2698,11 @@
WKWebsiteDataStoreStatisticsResetToConsistentState(dataStore);
}
+void TestController::getAllStorageAccessEntries()
+{
+ // FIXME: Implement C API version of this test.
+}
+
#endif
} // namespace WTR
Modified: trunk/Tools/WebKitTestRunner/TestController.h (228108 => 228109)
--- trunk/Tools/WebKitTestRunner/TestController.h 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2018-02-05 19:35:13 UTC (rev 228109)
@@ -184,6 +184,8 @@
void statisticsClearThroughWebsiteDataRemoval();
void statisticsResetToConsistentState();
+ void getAllStorageAccessEntries();
+
WKArrayRef openPanelFileURLs() const { return m_openPanelFileURLs.get(); }
void setOpenPanelFileURLs(WKArrayRef fileURLs) { m_openPanelFileURLs = fileURLs; }
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (228108 => 228109)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2018-02-05 19:35:13 UTC (rev 228109)
@@ -835,7 +835,12 @@
WKCookieManagerSetStorageAccessAPIEnabled(WKContextGetCookieManager(TestController::singleton().context()), WKBooleanGetValue(accept));
return nullptr;
}
-
+
+ if (WKStringIsEqualToUTF8CString(messageName, "GetAllStorageAccessEntries")) {
+ TestController::singleton().getAllStorageAccessEntries();
+ return nullptr;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "SetAllowsAnySSLCertificate")) {
TestController::singleton().setAllowsAnySSLCertificate(WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)));
return nullptr;
@@ -1351,6 +1356,17 @@
WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), 0);
}
+void TestInvocation::didReceiveAllStorageAccessEntries(Vector<String>& domains)
+{
+ WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidReceiveAllStorageAccessEntries"));
+
+ WKRetainPtr<WKMutableArrayRef> messageBody(AdoptWK, WKMutableArrayCreate());
+ for (auto& domain : domains)
+ WKArrayAppendItem(messageBody.get(), adoptWK(WKStringCreateWithUTF8CString(domain.utf8().data())).get());
+
+ WKPagePostMessageToInjectedBundle(TestController::singleton().mainWebView()->page(), messageName.get(), messageBody.get());
+}
+
void TestInvocation::didRemoveAllSessionCredentials()
{
WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("CallDidRemoveAllSessionCredentialsCallback"));
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (228108 => 228109)
--- trunk/Tools/WebKitTestRunner/TestInvocation.h 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h 2018-02-05 19:35:13 UTC (rev 228109)
@@ -73,6 +73,7 @@
void didClearStatisticsThroughWebsiteDataRemoval();
void didSetPartitionOrBlockCookiesForHost();
+ void didReceiveAllStorageAccessEntries(Vector<String>& domains);
void didRemoveAllSessionCredentials();
Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (228108 => 228109)
--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2018-02-05 19:26:49 UTC (rev 228108)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2018-02-05 19:35:13 UTC (rev 228109)
@@ -459,6 +459,18 @@
{
[globalWebViewConfiguration.websiteDataStore _resourceLoadStatisticsResetToConsistentState];
}
+
+void TestController::getAllStorageAccessEntries()
+{
+ [globalWebViewConfiguration.websiteDataStore _getAllStorageAccessEntries:^(NSArray<NSString *> *nsDomains) {
+ Vector<String> domains;
+ domains.reserveInitialCapacity(nsDomains.count);
+ for (NSString *domain : nsDomains)
+ domains.uncheckedAppend(domain);
+ m_currentInvocation->didReceiveAllStorageAccessEntries(domains);
+ }];
+}
+
#endif // WK_API_ENABLED
} // namespace WTR