WebKit Bugzilla
Attachment 347578 Details for
Bug 188757
: Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188757-20180820172552.patch (text/plain), 32.20 KB, created by
John Wilander
on 2018-08-20 17:25:53 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
John Wilander
Created:
2018-08-20 17:25:53 PDT
Size:
32.20 KB
patch
obsolete
>Subversion Revision: 235080 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 70bd1a9cd7558064b57c991ae1cbb4050ab43f7a..8e5ffea3037f1bc49e1b105520fecd929f43600e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+2018-08-20 John Wilander <wilander@apple.com> >+ >+ Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames >+ https://bugs.webkit.org/show_bug.cgi?id=188757 >+ <rdar://problem/38713390> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-20 Rob Buis <rbuis@igalia.com> > > Throw an exception if window.open() gets passed a URL that cannot be parsed >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 65f4f102ac5f23d0bbaab46c05b406eb0ed4a9bb..6006f254ed1655858fe1b76da3cc9f9b41f3e655 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,24 @@ >+2018-08-20 John Wilander <wilander@apple.com> >+ >+ Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames >+ https://bugs.webkit.org/show_bug.cgi?id=188757 >+ <rdar://problem/38713390> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-20 Carlos Garcia Campos <cgarcia@igalia.com> > > Unreviewed. Fix GTK/WPE cookie API tests after r234396. >diff --git a/Source/WebCore/Modules/websockets/WebSocket.cpp b/Source/WebCore/Modules/websockets/WebSocket.cpp >index c3ddd84c62cdbae410c06c6ef6be33f23af46392..8549555e15909427a3911df940cc2e3ed88bb0cf 100644 >--- a/Source/WebCore/Modules/websockets/WebSocket.cpp >+++ b/Source/WebCore/Modules/websockets/WebSocket.cpp >@@ -279,6 +279,10 @@ ExceptionOr<void> WebSocket::connect(const String& url, const Vector<String>& pr > } > } > >+ RunLoop::main().dispatch([targetURL = m_url, mainFrameURL = context.url(), 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 @@ ExceptionOr<void> WebSocket::connect(const String& url, const Vector<String>& pr > #endif > return { }; > } >- ResourceLoadObserver::shared().logWebSocketLoading(frame.get(), m_url); > } > > String protocolString; >diff --git a/Source/WebCore/loader/ResourceLoadObserver.cpp b/Source/WebCore/loader/ResourceLoadObserver.cpp >index 511b912a2540c3926304abedcb8ec04540217092..3a447c76848b10b8426a669e91f34a7e6912d402 100644 >--- a/Source/WebCore/loader/ResourceLoadObserver.cpp >+++ b/Source/WebCore/loader/ResourceLoadObserver.cpp >@@ -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 @@ static inline bool is3xxRedirect(const ResourceResponse& response) > 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 @@ void ResourceLoadObserver::logSubresourceLoading(const Frame* frame, const Resou > ASSERT(frame->page()); > > auto* page = frame->page(); >- if (!shouldLog(page)) >+ if (!shouldLog(page->usesEphemeralSession())) > return; > > bool isRedirect = is3xxRedirect(redirectResponse); >@@ -152,19 +149,11 @@ void ResourceLoadObserver::logSubresourceLoading(const Frame* frame, const Resou > 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) >- return; >- >- auto* page = frame->page(); >- if (!shouldLog(page)) >+ if (!shouldLog(usesEphemeralSession)) > return; > >- auto& mainFrameURL = frame->mainFrame().document()->url(); >- > auto targetHost = targetURL.host(); > auto mainFrameHost = mainFrameURL.host(); > >@@ -173,9 +162,6 @@ void ResourceLoadObserver::logWebSocketLoading(const Frame* frame, const URL& ta > > 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::logWebSocketLoading(const Frame* frame, const URL& ta > > void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Document& document) > { >- if (!shouldLog(document.page())) >- return; >- > ASSERT(document.page()); > >+ if (!shouldLog(document.page()->usesEphemeralSession())) >+ return; >+ > auto& url = document.url(); > if (url.isBlankURL() || url.isEmpty()) > return; >diff --git a/Source/WebCore/loader/ResourceLoadObserver.h b/Source/WebCore/loader/ResourceLoadObserver.h >index 52570a79aa8ffdcbfb9b079f375f283526193409..5b6d9188fbd2228a913f81f33ad7dbc90534bb26 100644 >--- a/Source/WebCore/loader/ResourceLoadObserver.h >+++ b/Source/WebCore/loader/ResourceLoadObserver.h >@@ -44,6 +44,7 @@ class Frame; > class Page; > class ResourceRequest; > class ResourceResponse; >+class ScriptExecutionContext; > class URL; > > struct ResourceLoadStatistics; >@@ -54,7 +55,7 @@ public: > 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 @@ public: > private: > ResourceLoadObserver(); > >- bool shouldLog(Page*) const; >+ bool shouldLog(bool usesEphemeralSession) const; > ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&); > > void scheduleNotificationIfNeeded(); >diff --git a/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp b/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp >index 4d84bcefab39b52bee825c1b9c97fd1aeccd8e98..802d1cd938d83022e061cdacfa4e3371f9c68966 100644 >--- a/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp >+++ b/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp >@@ -169,6 +169,19 @@ void WKWebsiteDataStoreIsStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef d > }); > } > >+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(); >diff --git a/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h b/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h >index 8d01963c991f291c5e35b25d322216d62384bda2..0662dcf2807783c01912e8cdd77087fee1f9354f 100644 >--- a/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h >+++ b/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h >@@ -52,6 +52,8 @@ WK_EXPORT void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDat > 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); >diff --git a/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp b/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp >index 348cacd3be5115cd797ced8856ee546a31faf007..c2534fdff2531fa871a9586028c278fe0754e969 100644 >--- a/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp >+++ b/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.cpp >@@ -695,6 +695,14 @@ bool ResourceLoadStatisticsMemoryStore::isVeryPrevalentResource(const String& pr > 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()); >diff --git a/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h b/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h >index 25787f9c05af54ce253287af5e07377eba043a92..40b394b08aac11a9c2457df44ea145e228332387 100644 >--- a/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h >+++ b/Source/WebKit/UIProcess/ResourceLoadStatisticsMemoryStore.h >@@ -78,6 +78,7 @@ public: > 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; > >diff --git a/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp b/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp >index 2877cad114308cb2cec1d8605ec9168044847933..8d03721d0a09fe0760f27c898ab633405674ff42 100644 >--- a/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp >+++ b/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp >@@ -537,6 +537,18 @@ void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const URL& url, Com > }); > } > >+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()); >diff --git a/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h b/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h >index 244bfa310a3e31a1c4a172beef2b9d2b9544d6f7..fb2440887d6a28e626169197b69c916e286ea423 100644 >--- a/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h >+++ b/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h >@@ -93,6 +93,7 @@ public: > 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()>&&); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 258ea76bbd4038003227403eb6ec1607498ef9ad..6cdc0f40f9c1deba20cb7b6a0e68eaca9b71f29c 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,24 @@ >+2018-08-20 John Wilander <wilander@apple.com> >+ >+ Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames >+ https://bugs.webkit.org/show_bug.cgi?id=188757 >+ <rdar://problem/38713390> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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-20 Bernhard M. Wiedemann <bwiedemann@suse.de> > > [GTK] Sort inspector GResource manifest to ensure reproducible builds >diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >index a9545c62f1e7e4c61104579f63754d03c86b3955..634d352f56abc3a991e38b157db98fe5cc1cbdbc 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >+++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl >@@ -278,6 +278,7 @@ interface TestRunner { > 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); >diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >index 8ea9301ffea8f5e96fa3ff40f522fac484f41de2..db5cd6d48c099697c51cc52c9f6087586f3c8c35 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp >@@ -1474,6 +1474,32 @@ bool TestRunner::isStatisticsVeryPrevalentResource(JSStringRef hostName) > 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; >diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >index a4bfc50d0f12e2fa60ba212ac982d8b74724ff80..789095f121d5b85319c651b88c583d03484a226c 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >+++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h >@@ -392,6 +392,7 @@ public: > 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); >diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp >index e3a62eaf0c9016974f6cd42405ca2c4fb4c536a1..e0527dab63a382d27862db724a0d95d7d0e124d2 100644 >--- a/Tools/WebKitTestRunner/TestController.cpp >+++ b/Tools/WebKitTestRunner/TestController.cpp >@@ -2737,6 +2737,15 @@ bool TestController::isStatisticsVeryPrevalentResource(WKStringRef host) > 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()); >diff --git a/Tools/WebKitTestRunner/TestController.h b/Tools/WebKitTestRunner/TestController.h >index 42a2b6f74227b0dec77743c72c94ba34ce25f76b..b07a9b1821cbee511502a5ae38800f19c428eec1 100644 >--- a/Tools/WebKitTestRunner/TestController.h >+++ b/Tools/WebKitTestRunner/TestController.h >@@ -163,6 +163,7 @@ public: > 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); >diff --git a/Tools/WebKitTestRunner/TestInvocation.cpp b/Tools/WebKitTestRunner/TestInvocation.cpp >index 7d4fdac1806adc75a9c07499101357956cf71a81..d3e9d8a7c53e6eaf2756dfafb53c1d028b88601e 100644 >--- a/Tools/WebKitTestRunner/TestInvocation.cpp >+++ b/Tools/WebKitTestRunner/TestInvocation.cpp >@@ -1105,6 +1105,21 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB > 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()); > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 9d62327c7eebe8952c1906553b438874c5261e17..14e558fa3ce328c8aeb056aef554434e3e89110f 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,19 @@ >+2018-08-20 John Wilander <wilander@apple.com> >+ >+ Make ResourceLoadObserver::logWebSocketLoading() handle websockets in detached frames >+ https://bugs.webkit.org/show_bug.cgi?id=188757 >+ <rdar://problem/38713390> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * 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-20 Rob Buis <rbuis@igalia.com> > > Throw an exception if window.open() gets passed a URL that cannot be parsed >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index e180442c05907687f7c0187ef9087d900719ac79..bef5b5d372185e7598d76cd0c8aea62b7f176936 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -115,6 +115,7 @@ http/tests/appcache/decide-navigation-policy-after-delay.html [ Skip ] > 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 ] >diff --git a/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt b/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..848cf2171ce96382ca68ba048043dba16644a09a >--- /dev/null >+++ b/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics-expected.txt >@@ -0,0 +1,5 @@ >+PASS localhost registered as subresource under 127.0.0.1. >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html b/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html >new file mode 100644 >index 0000000000000000000000000000000000000000..1f094304e1a8f12399f80fc418f617b0b7677074 >--- /dev/null >+++ b/LayoutTests/http/tests/websocket/construct-in-detached-frame-resource-load-statistics.html >@@ -0,0 +1,55 @@ >+<!DOCTYPE html> >+<head> >+ <script src="../resources/js-test-pre.js"></script> >+ <script src="/resourceLoadStatistics/resources/util.js"></script> >+</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 = "resources/construct-in-detached-frame-resource-load-statistics.html"; >+ iframeElement.id = "testIframe"; >+ document.body.appendChild(iframeElement); >+ }); >+ } >+</script> >+<script src="../resources/js-test-post.js"></script> >+</body> >diff --git a/LayoutTests/http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html b/LayoutTests/http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html >new file mode 100644 >index 0000000000000000000000000000000000000000..ab7518b8447693d65441fb4dcb88559182a628c8 >--- /dev/null >+++ b/LayoutTests/http/tests/websocket/resources/construct-in-detached-frame-resource-load-statistics.html >@@ -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> >diff --git a/LayoutTests/platform/wk2/TestExpectations b/LayoutTests/platform/wk2/TestExpectations >index 9195b41c6f66ac379cedc71c05f360b9ad2ceca9..925fbd217cc13d3ed85868f432c08411f85d491d 100644 >--- a/LayoutTests/platform/wk2/TestExpectations >+++ b/LayoutTests/platform/wk2/TestExpectations >@@ -721,6 +721,7 @@ http/tests/resourceLoadStatistics/grandfathering.html [ Pass ] > 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 ]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188757
:
347545
|
347550
|
347575
|
347578
|
347654
|
347818