Diff
Modified: trunk/LayoutTests/ChangeLog (235123 => 235124)
--- trunk/LayoutTests/ChangeLog 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/LayoutTests/ChangeLog 2018-08-21 18:02:33 UTC (rev 235124)
@@ -1,3 +1,19 @@
+2018-08-21 John Wilander <[email protected]>
+
+ Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames
+ https://bugs.webkit.org/show_bug.cgi?id=188757
+ <rdar://problem/38713390>
+
+ Reviewed by Alex Christensen.
+
+ * TestExpectations:
+ Skipped the new test case since it is only supported on WebKit2.
+ * http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt: Added.
+ * http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html: Added.
+ * http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html: Added.
+ * platform/wk2/TestExpectations:
+ Marked the new test case as [ Pass ].
+
2018-08-21 Daniel Bates <[email protected]>
Disallow navigations when page cache updates the current document of the frame
Modified: trunk/LayoutTests/TestExpectations (235123 => 235124)
--- trunk/LayoutTests/TestExpectations 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/LayoutTests/TestExpectations 2018-08-21 18:02:33 UTC (rev 235124)
@@ -115,6 +115,7 @@
http/tests/misc/will-send-request-with-client-provided-http-body.html [ Skip ]
http/tests/loading/resourceLoadStatistics/ [ Skip ]
http/tests/resourceLoadStatistics/ [ Skip ]
+http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html [ Skip ]
http/tests/storageAccess/ [ Skip ]
http/tests/navigation/process-swap-window-open.html [ Skip ]
http/tests/navigation/useragent-reload.php [ Skip ]
Added: trunk/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt (0 => 235124)
--- trunk/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt 2018-08-21 18:02:33 UTC (rev 235124)
@@ -0,0 +1,5 @@
+PASS localhost registered as subresource under 127.0.0.1.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html (0 => 235124)
--- trunk/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html 2018-08-21 18:02:33 UTC (rev 235124)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<head>
+ <script src=""
+ <script src=""
+</head>
+<body _onload_="runTest()">
+<script>
+ description('Construct a WebSocket in a detached frame. The test passes if Resource Load Statistics logs it properly.');
+
+ window.jsTestIsAsync = true;
+
+ function detachIframe() {
+ var testIframe = document.getElementById('testIframe');
+ testIframe.parentNode.remove(testIframe);
+ }
+
+ function completeTest() {
+ if (testRunner.isStatisticsRegisteredAsSubresourceUnder("http://localhost", "http://127.0.0.1"))
+ testPassed("localhost registered as subresource under 127.0.0.1.");
+ else
+ testFailed("localhost not registered as subresource under 127.0.0.1.");
+ setEnableFeature(false, finishJSTest);
+ }
+
+ let dataRecordsScanned = false;
+ function didScanDataRecords() {
+ dataRecordsScanned = true;
+ if (createdWebSocket)
+ completeTest();
+ }
+
+ let createdWebSocket = false;
+ function didCreateWebSocket() {
+ createdWebSocket = true;
+ if (dataRecordsScanned)
+ completeTest();
+ }
+
+ function runTest() {
+ setEnableFeature(true, function() {
+ if (testRunner.isStatisticsRegisteredAsSubresourceUnder("http://localhost", "http://127.0.0.1"))
+ testFailed("localhost already registered as subresource under 127.0.0.1.");
+
+ testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+ testRunner.installStatisticsDidScanDataRecordsCallback(didScanDataRecords);
+
+ let iframeElement = document.createElement("iframe");
+ iframeElement.src = ""
+ iframeElement.id = "testIframe";
+ document.body.appendChild(iframeElement);
+ });
+ }
+</script>
+<script src=""
+</body>
Added: trunk/LayoutTests/http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html (0 => 235124)
--- trunk/LayoutTests/http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html 2018-08-21 18:02:33 UTC (rev 235124)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<script>
+ var parentWindow = parent;
+ var webSocketClass = WebSocket;
+
+ parentWindow.detachIframe();
+ try {
+ new webSocketClass('ws://localhost/');
+ } catch (e) {
+ parentWindow.console.log(e.message);
+ }
+ parentWindow.didCreateWebSocket();
+</script>
Modified: trunk/LayoutTests/platform/wk2/TestExpectations (235123 => 235124)
--- trunk/LayoutTests/platform/wk2/TestExpectations 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/LayoutTests/platform/wk2/TestExpectations 2018-08-21 18:02:33 UTC (rev 235124)
@@ -721,6 +721,7 @@
webkit.org/b/180703 http/tests/resourceLoadStatistics/telemetry-generation.html [ Pass Failure ]
http/tests/resourceLoadStatistics/prune-statistics.html [ Pass ]
http/tests/resourceLoadStatistics [ Pass ]
+http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html [ Pass ]
# These are only supported behind a compile time flag in macOS High Sierra + iOS 11, and above.
http/tests/resourceLoadStatistics/cookie-deletion.html [ Skip ]
http/tests/resourceLoadStatistics/cookies-with-and-without-user-interaction.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (235123 => 235124)
--- trunk/Source/WebCore/ChangeLog 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebCore/ChangeLog 2018-08-21 18:02:33 UTC (rev 235124)
@@ -1,3 +1,30 @@
+2018-08-21 John Wilander <[email protected]>
+
+ Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames
+ https://bugs.webkit.org/show_bug.cgi?id=188757
+ <rdar://problem/38713390>
+
+ Reviewed by Alex Christensen.
+
+ Test: http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html
+
+ * Modules/websockets/WebSocket.cpp:
+ (WebCore::WebSocket::connect):
+ Now logs even when a frame doesn't exist.
+ * loader/ResourceLoadObserver.cpp:
+ (WebCore::ResourceLoadObserver::shouldLog const):
+ Now takes boolean 'usesEphemeralSession' instead of a page to support logging when there is no page.
+ (WebCore::ResourceLoadObserver::logSubresourceLoading):
+ Changed to send a boolean to ResourceLoadObserver::shouldLog().
+ (WebCore::ResourceLoadObserver::logWebSocketLoading):
+ Changed to:
+ - receive the main frame's URL and a boolean for ephemeral sessions instead of the Frame.
+ - send a boolean to ResourceLoadObserver::shouldLog().
+ - No longer call areDomainsAssociated(). It is being removed in https://bugs.webkit.org/show_bug.cgi?id=188756.
+ (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+ Changed to send a boolean to ResourceLoadObserver::shouldLog().
+ * loader/ResourceLoadObserver.h:
+
2018-08-21 Daniel Bates <[email protected]>
Disallow navigations when page cache updates the current document of the frame
Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (235123 => 235124)
--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp 2018-08-21 18:02:33 UTC (rev 235124)
@@ -279,6 +279,10 @@
}
}
+ RunLoop::main().dispatch([targetURL = m_url.isolatedCopy(), mainFrameURL = context.url().isolatedCopy(), usesEphemeralSession = context.sessionID().isEphemeral()]() {
+ ResourceLoadObserver::shared().logWebSocketLoading(targetURL, mainFrameURL, usesEphemeralSession);
+ });
+
if (is<Document>(context)) {
Document& document = downcast<Document>(context);
RefPtr<Frame> frame = document.frame();
@@ -307,7 +311,6 @@
#endif
return { };
}
- ResourceLoadObserver::shared().logWebSocketLoading(frame.get(), m_url);
}
String protocolString;
Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (235123 => 235124)
--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp 2018-08-21 18:02:33 UTC (rev 235124)
@@ -36,6 +36,7 @@
#include "ResourceLoadStatistics.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
+#include "ScriptExecutionContext.h"
#include "SecurityOrigin.h"
#include "Settings.h"
#include "URL.h"
@@ -95,13 +96,9 @@
return response.httpStatusCode() >= 300 && response.httpStatusCode() <= 399;
}
-bool ResourceLoadObserver::shouldLog(Page* page) const
+bool ResourceLoadObserver::shouldLog(bool usesEphemeralSession) const
{
- // FIXME: Err on the safe side until we have sorted out what to do in worker contexts
- if (!page)
- return false;
-
- return DeprecatedGlobalSettings::resourceLoadStatisticsEnabled() && !page->usesEphemeralSession() && m_notificationCallback;
+ return DeprecatedGlobalSettings::resourceLoadStatisticsEnabled() && !usesEphemeralSession && m_notificationCallback;
}
void ResourceLoadObserver::logSubresourceLoading(const Frame* frame, const ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
@@ -109,7 +106,7 @@
ASSERT(frame->page());
auto* page = frame->page();
- if (!shouldLog(page))
+ if (!shouldLog(page->usesEphemeralSession()))
return;
bool isRedirect = is3xxRedirect(redirectResponse);
@@ -152,19 +149,11 @@
scheduleNotificationIfNeeded();
}
-void ResourceLoadObserver::logWebSocketLoading(const Frame* frame, const URL& targetURL)
+void ResourceLoadObserver::logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL, bool usesEphemeralSession)
{
- // FIXME: Web sockets can run in detached frames. Decide how to count such connections.
- // See LayoutTests/http/tests/websocket/construct-in-detached-frame.html
- if (!frame)
+ if (!shouldLog(usesEphemeralSession))
return;
- auto* page = frame->page();
- if (!shouldLog(page))
- return;
-
- auto& mainFrameURL = frame->mainFrame().document()->url();
-
auto targetHost = targetURL.host();
auto mainFrameHost = mainFrameURL.host();
@@ -173,9 +162,6 @@
auto targetPrimaryDomain = primaryDomain(targetURL);
auto mainFramePrimaryDomain = primaryDomain(mainFrameURL);
-
- if (areDomainsAssociated(page, targetPrimaryDomain, mainFramePrimaryDomain))
- return;
auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
targetStatistics.lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
@@ -185,11 +171,11 @@
void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Document& document)
{
- if (!shouldLog(document.page()))
+ ASSERT(document.page());
+
+ if (!shouldLog(document.page()->usesEphemeralSession()))
return;
- ASSERT(document.page());
-
auto& url = ""
if (url.isBlankURL() || url.isEmpty())
return;
Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (235123 => 235124)
--- trunk/Source/WebCore/loader/ResourceLoadObserver.h 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h 2018-08-21 18:02:33 UTC (rev 235124)
@@ -44,6 +44,7 @@
class Page;
class ResourceRequest;
class ResourceResponse;
+class ScriptExecutionContext;
class URL;
struct ResourceLoadStatistics;
@@ -54,7 +55,7 @@
WEBCORE_EXPORT static ResourceLoadObserver& shared();
void logSubresourceLoading(const Frame*, const ResourceRequest& newRequest, const ResourceResponse& redirectResponse);
- void logWebSocketLoading(const Frame*, const URL&);
+ void logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL, bool usesEphemeralSession);
void logUserInteractionWithReducedTimeResolution(const Document&);
void logWindowCreation(const URL& popupUrl, uint64_t openerPageID, Document& openerDocument);
@@ -74,7 +75,7 @@
private:
ResourceLoadObserver();
- bool shouldLog(Page*) const;
+ bool shouldLog(bool usesEphemeralSession) const;
ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
void scheduleNotificationIfNeeded();
Modified: trunk/Source/WebKit/ChangeLog (235123 => 235124)
--- trunk/Source/WebKit/ChangeLog 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebKit/ChangeLog 2018-08-21 18:02:33 UTC (rev 235124)
@@ -1,3 +1,24 @@
+2018-08-21 John Wilander <[email protected]>
+
+ Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames
+ https://bugs.webkit.org/show_bug.cgi?id=188757
+ <rdar://problem/38713390>
+
+ Reviewed by Alex Christensen.
+
+ These changes are test infrastructure to support the new WebKitTestRunner
+ function isStatisticsRegisteredAsSubresourceUnder().
+
+ * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+ (WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder):
+ * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+ * UIProcess/ResourceLoadStatisticsMemoryStore.cpp:
+ (WebKit::ResourceLoadStatisticsMemoryStore::isRegisteredAsSubresourceUnder const):
+ * UIProcess/ResourceLoadStatisticsMemoryStore.h:
+ * UIProcess/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder):
+ * UIProcess/WebResourceLoadStatisticsStore.h:
+
2018-08-21 Daniel Bates <[email protected]>
Replace TextCheckingTypeMask with OptionSet
Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp (235123 => 235124)
--- trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp 2018-08-21 18:02:33 UTC (rev 235124)
@@ -169,6 +169,19 @@
});
}
+void WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subresourceHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnderFunction callback)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store) {
+ callback(false, context);
+ return;
+ }
+
+ store->isRegisteredAsSubresourceUnder(WebCore::URL(WebCore::URL(), WebKit::toImpl(subresourceHost)->string()), WebCore::URL(WebCore::URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubresourceUnder) {
+ callback(isRegisteredAsSubresourceUnder, context);
+ });
+}
+
void WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subFrameHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnderFunction callback)
{
auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h (235123 => 235124)
--- trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h 2018-08-21 18:02:33 UTC (rev 235124)
@@ -52,6 +52,8 @@
typedef void (*WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction)(bool isPrevalentResource, void* functionContext);
WK_EXPORT void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback);
WK_EXPORT void WKWebsiteDataStoreIsStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback);
+typedef void (*WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnderFunction)(bool isRegisteredAsSubresourceUnder, void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subresourceHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnderFunction callback);
typedef void (*WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnderFunction)(bool isRegisteredAsSubFrameUnder, void* functionContext);
WK_EXPORT void WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subFrameHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnderFunction callback);
typedef void (*WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingToFunction)(bool isRegisteredAsRedirectingTo, void* functionContext);
Modified: trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp (235123 => 235124)
--- trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp 2018-08-21 18:02:33 UTC (rev 235124)
@@ -695,6 +695,14 @@
return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.isPrevalentResource && mapEntry->value.isVeryPrevalentResource;
}
+bool ResourceLoadStatisticsMemoryStore::isRegisteredAsSubresourceUnder(const String& subresourcePrimaryDomain, const String& topFramePrimaryDomain) const
+{
+ ASSERT(!RunLoop::isMain());
+
+ auto mapEntry = m_resourceStatisticsMap.find(subresourcePrimaryDomain);
+ return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.subresourceUnderTopFrameOrigins.contains(topFramePrimaryDomain);
+}
+
bool ResourceLoadStatisticsMemoryStore::isRegisteredAsSubFrameUnder(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain) const
{
ASSERT(!RunLoop::isMain());
Modified: trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h (235123 => 235124)
--- trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h 2018-08-21 18:02:33 UTC (rev 235124)
@@ -78,6 +78,7 @@
void grandfatherExistingWebsiteData(CompletionHandler<void()>&&);
void cancelPendingStatisticsProcessingRequest();
+ bool isRegisteredAsSubresourceUnder(const String& subresourcePrimaryDomain, const String& topFramePrimaryDomain) const;
bool isRegisteredAsSubFrameUnder(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain) const;
bool isRegisteredAsRedirectingTo(const String& hostRedirectedFromPrimaryDomain, const String& hostRedirectedToPrimaryDomain) const;
Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (235123 => 235124)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-08-21 18:02:33 UTC (rev 235124)
@@ -537,6 +537,18 @@
});
}
+void WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler)
+{
+ ASSERT(RunLoop::isMain());
+
+ postTask([this, subresourcePrimaryDomain = isolatedPrimaryDomain(subresource), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)] () mutable {
+ bool isRegisteredAsSubresourceUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubresourceUnder(subresourcePrimaryDomain, topFramePrimaryDomain) : false;
+ postTaskReply([isRegisteredAsSubresourceUnder, completionHandler = WTFMove(completionHandler)] () mutable {
+ completionHandler(isRegisteredAsSubresourceUnder);
+ });
+ });
+}
+
void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void (bool)>&& completionHandler)
{
ASSERT(RunLoop::isMain());
Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (235123 => 235124)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h 2018-08-21 18:02:33 UTC (rev 235124)
@@ -93,6 +93,7 @@
void setVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
void isPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&);
void isVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&);
+ void isRegisteredAsSubresourceUnder(const WebCore::URL& subresource, const WebCore::URL& topFrame, CompletionHandler<void(bool)>&&);
void isRegisteredAsSubFrameUnder(const WebCore::URL& subFrame, const WebCore::URL& topFrame, CompletionHandler<void(bool)>&&);
void isRegisteredAsRedirectingTo(const WebCore::URL& hostRedirectedFrom, const WebCore::URL& hostRedirectedTo, CompletionHandler<void(bool)>&&);
void clearPrevalentResource(const WebCore::URL&, CompletionHandler<void()>&&);
Modified: trunk/Tools/ChangeLog (235123 => 235124)
--- trunk/Tools/ChangeLog 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Tools/ChangeLog 2018-08-21 18:02:33 UTC (rev 235124)
@@ -1,3 +1,24 @@
+2018-08-21 John Wilander <[email protected]>
+
+ Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames
+ https://bugs.webkit.org/show_bug.cgi?id=188757
+ <rdar://problem/38713390>
+
+ Reviewed by Alex Christensen.
+
+ These changes add the new WebKitTestRunner function
+ isStatisticsRegisteredAsSubresourceUnder().
+
+ * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+ * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+ (WTR::TestRunner::isStatisticsRegisteredAsSubresourceUnder):
+ * WebKitTestRunner/InjectedBundle/TestRunner.h:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::isStatisticsRegisteredAsSubresourceUnder):
+ * WebKitTestRunner/TestController.h:
+ * WebKitTestRunner/TestInvocation.cpp:
+ (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
2018-08-21 Alex Christensen <[email protected]>
Transition more API tests from WKPageLoaderClient to WKPageNavigationClient
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (235123 => 235124)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl 2018-08-21 18:02:33 UTC (rev 235124)
@@ -278,6 +278,7 @@
void setStatisticsVeryPrevalentResource(DOMString hostName, boolean value, object completionHandler);
boolean isStatisticsPrevalentResource(DOMString hostName);
boolean isStatisticsVeryPrevalentResource(DOMString hostName);
+ boolean isStatisticsRegisteredAsSubresourceUnder(DOMString subresourceHost, DOMString topFrameHost);
boolean isStatisticsRegisteredAsSubFrameUnder(DOMString subFrameHost, DOMString topFrameHost);
boolean isStatisticsRegisteredAsRedirectingTo(DOMString hostRedirectedFrom, DOMString hostRedirectedTo);
void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value, object completionHandler);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (235123 => 235124)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp 2018-08-21 18:02:33 UTC (rev 235124)
@@ -1474,6 +1474,32 @@
return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
}
+bool TestRunner::isStatisticsRegisteredAsSubresourceUnder(JSStringRef subresourceHost, JSStringRef topFrameHost)
+{
+ Vector<WKRetainPtr<WKStringRef>> keys;
+ Vector<WKRetainPtr<WKTypeRef>> values;
+
+ keys.append({ AdoptWK, WKStringCreateWithUTF8CString("SubresourceHost") });
+ values.append({ AdoptWK, WKStringCreateWithJSString(subresourceHost) });
+
+ keys.append({ AdoptWK, WKStringCreateWithUTF8CString("TopFrameHost") });
+ values.append({ AdoptWK, WKStringCreateWithJSString(topFrameHost) });
+
+ Vector<WKStringRef> rawKeys(keys.size());
+ Vector<WKTypeRef> rawValues(values.size());
+
+ for (size_t i = 0; i < keys.size(); ++i) {
+ rawKeys[i] = keys[i].get();
+ rawValues[i] = values[i].get();
+ }
+
+ WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("IsStatisticsRegisteredAsSubresourceUnder"));
+ WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
+ WKTypeRef returnData = 0;
+ WKBundlePagePostSynchronousMessageForTesting(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get(), &returnData);
+ return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
+}
+
bool TestRunner::isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost)
{
Vector<WKRetainPtr<WKStringRef>> keys;
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (235123 => 235124)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h 2018-08-21 18:02:33 UTC (rev 235124)
@@ -392,6 +392,7 @@
void statisticsCallDidSetVeryPrevalentResourceCallback();
bool isStatisticsPrevalentResource(JSStringRef hostName);
bool isStatisticsVeryPrevalentResource(JSStringRef hostName);
+ bool isStatisticsRegisteredAsSubresourceUnder(JSStringRef subresourceHost, JSStringRef topFrameHost);
bool isStatisticsRegisteredAsSubFrameUnder(JSStringRef subFrameHost, JSStringRef topFrameHost);
bool isStatisticsRegisteredAsRedirectingTo(JSStringRef hostRedirectedFrom, JSStringRef hostRedirectedTo);
void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value, JSValueRef completionHandler);
Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (235123 => 235124)
--- trunk/Tools/WebKitTestRunner/TestController.cpp 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp 2018-08-21 18:02:33 UTC (rev 235124)
@@ -2737,6 +2737,15 @@
return context.result;
}
+bool TestController::isStatisticsRegisteredAsSubresourceUnder(WKStringRef subresourceHost, WKStringRef topFrameHost)
+{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ ResourceStatisticsCallbackContext context(*this);
+ WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder(dataStore, subresourceHost, topFrameHost, &context, resourceStatisticsBooleanResultCallback);
+ runUntil(context.done, noTimeout);
+ return context.result;
+}
+
bool TestController::isStatisticsRegisteredAsSubFrameUnder(WKStringRef subFrameHost, WKStringRef topFrameHost)
{
auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
Modified: trunk/Tools/WebKitTestRunner/TestController.h (235123 => 235124)
--- trunk/Tools/WebKitTestRunner/TestController.h 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Tools/WebKitTestRunner/TestController.h 2018-08-21 18:02:33 UTC (rev 235124)
@@ -163,6 +163,7 @@
void setStatisticsVeryPrevalentResource(WKStringRef hostName, bool value);
bool isStatisticsPrevalentResource(WKStringRef hostName);
bool isStatisticsVeryPrevalentResource(WKStringRef hostName);
+ bool isStatisticsRegisteredAsSubresourceUnder(WKStringRef subresourceHost, WKStringRef topFrameHost);
bool isStatisticsRegisteredAsSubFrameUnder(WKStringRef subFrameHost, WKStringRef topFrameHost);
bool isStatisticsRegisteredAsRedirectingTo(WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo);
void setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value);
Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (235123 => 235124)
--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2018-08-21 17:31:44 UTC (rev 235123)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp 2018-08-21 18:02:33 UTC (rev 235124)
@@ -1105,6 +1105,21 @@
return result;
}
+ if (WKStringIsEqualToUTF8CString(messageName, "IsStatisticsRegisteredAsSubresourceUnder")) {
+ ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+
+ WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+ WKRetainPtr<WKStringRef> subresourceHostKey(AdoptWK, WKStringCreateWithUTF8CString("SubresourceHost"));
+ WKRetainPtr<WKStringRef> topFrameHostKey(AdoptWK, WKStringCreateWithUTF8CString("TopFrameHost"));
+
+ WKStringRef subresourceHost = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, subresourceHostKey.get()));
+ WKStringRef topFrameHost = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, topFrameHostKey.get()));
+
+ bool isRegisteredAsSubresourceUnder = TestController::singleton().isStatisticsRegisteredAsSubresourceUnder(subresourceHost, topFrameHost);
+ WKRetainPtr<WKTypeRef> result(AdoptWK, WKBooleanCreate(isRegisteredAsSubresourceUnder));
+ return result;
+ }
+
if (WKStringIsEqualToUTF8CString(messageName, "IsStatisticsRegisteredAsSubFrameUnder")) {
ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());