Diff
Modified: trunk/Source/WebKit/ChangeLog (246448 => 246449)
--- trunk/Source/WebKit/ChangeLog 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Source/WebKit/ChangeLog 2019-06-14 23:05:31 UTC (rev 246449)
@@ -1,3 +1,22 @@
+2019-06-14 Youenn Fablet <[email protected]>
+
+ WebResourceLoadStatisticsStore should not use its network session if invalidated
+ https://bugs.webkit.org/show_bug.cgi?id=198814
+
+ Reviewed by Geoffrey Garen.
+
+ Tell WebResourceLoadStatisticsStore that its network session is invalidated.
+ WebResourceLoadStatisticsStore will then clear its reference to the network session.
+
+ * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
+ (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking):
+ Added for test purposes to trigger further cookie processing.
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+ (WebKit::WebResourceLoadStatisticsStore::invalidateAndCancel):
+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+ * NetworkProcess/NetworkSession.cpp:
+ (WebKit::NetworkSession::invalidateAndCancel):
+
2019-06-14 Joseph Pecoraro <[email protected]>
[Cocoa] NSFileWrapper associated with _WKAttachment
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (246448 => 246449)
--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp 2019-06-14 23:05:31 UTC (rev 246449)
@@ -758,7 +758,7 @@
domainsToBlock.append(resourceStatistic.registrableDomain);
}
- if (domainsToBlock.isEmpty()) {
+ if (domainsToBlock.isEmpty() && !debugModeEnabled()) {
completionHandler();
return;
}
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (246448 => 246449)
--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp 2019-06-14 23:05:31 UTC (rev 246449)
@@ -1021,6 +1021,11 @@
return m_networkSession.get();
}
+void WebResourceLoadStatisticsStore::invalidateAndCancel()
+{
+ m_networkSession = nullptr;
+}
+
void WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomains(OptionSet<WebsiteDataType> dataTypes, HashMap<RegistrableDomain, WebsiteDataToRemove>&& domainsToRemoveWebsiteDataFor, bool shouldNotifyPage, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&& completionHandler)
{
ASSERT(RunLoop::isMain());
Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (246448 => 246449)
--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h 2019-06-14 23:05:31 UTC (rev 246449)
@@ -176,6 +176,7 @@
void notifyResourceLoadStatisticsProcessed();
NetworkSession* networkSession();
+ void invalidateAndCancel();
void sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample) const;
void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (246448 => 246449)
--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2019-06-14 23:05:31 UTC (rev 246449)
@@ -100,11 +100,19 @@
{
for (auto* task : m_dataTaskSet)
task->invalidateAndCancel();
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ if (m_resourceLoadStatistics)
+ m_resourceLoadStatistics->invalidateAndCancel();
+#endif
+#if !ASSERT_DISABLED
+ m_isInvalidated = true;
+#endif
}
#if ENABLE(RESOURCE_LOAD_STATISTICS)
void NetworkSession::setResourceLoadStatisticsEnabled(bool enable)
{
+ ASSERT(!m_isInvalidated);
if (!enable) {
m_resourceLoadStatistics = nullptr;
return;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (246448 => 246449)
--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2019-06-14 23:05:31 UTC (rev 246449)
@@ -127,6 +127,9 @@
PrefetchCache m_prefetchCache;
Ref<StorageManager> m_storageManager;
+#if !ASSERT_DISABLED
+ bool m_isInvalidated { false };
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (246448 => 246449)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2019-06-14 23:05:31 UTC (rev 246449)
@@ -480,6 +480,17 @@
#endif
}
+- (void)_scheduleCookieBlockingUpdate:(void (^)(void))completionHandler
+{
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+ _websiteDataStore->websiteDataStore().scheduleCookieBlockingUpdate([completionHandler = makeBlockPtr(completionHandler)]() {
+ completionHandler();
+ });
+#else
+ completionHandler();
+#endif
+}
+
- (void)_setPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler
{
#if ENABLE(RESOURCE_LOAD_STATISTICS)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (246448 => 246449)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2019-06-14 23:05:31 UTC (rev 246449)
@@ -67,6 +67,7 @@
+ (void)_allowWebsiteDataRecordsForAllOrigins WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
- (bool)_hasRegisteredServiceWorker WK_API_AVAILABLE(macos(10.14), ios(12.0));
+- (void)_scheduleCookieBlockingUpdate:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_setPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_getIsPrevalentDomain:(NSURL *)domain completionHandler:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
Modified: trunk/Tools/ChangeLog (246448 => 246449)
--- trunk/Tools/ChangeLog 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Tools/ChangeLog 2019-06-14 23:05:31 UTC (rev 246449)
@@ -1,5 +1,15 @@
2019-06-14 Youenn Fablet <[email protected]>
+ WebResourceLoadStatisticsStore should not use its network session if invalidated
+ https://bugs.webkit.org/show_bug.cgi?id=198814
+
+ Reviewed by Geoffrey Garen.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
+ (TEST):
+
+2019-06-14 Youenn Fablet <[email protected]>
+
import-w3c-tests should respect WEBKIT_OUTPUTDIR
https://bugs.webkit.org/show_bug.cgi?id=198682
<rdar://problem/51536931>
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm (246448 => 246449)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2019-06-14 22:52:24 UTC (rev 246448)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2019-06-14 23:05:31 UTC (rev 246449)
@@ -28,10 +28,12 @@
#import "PlatformUtilities.h"
#import "TestNavigationDelegate.h"
#import <WebKit/WKFoundation.h>
+#import <WebKit/WKPreferencesPrivate.h>
#import <WebKit/WKProcessPoolPrivate.h>
#import <WebKit/WKWebViewConfigurationPrivate.h>
#import <WebKit/WKWebsiteDataRecordPrivate.h>
#import <WebKit/WKWebsiteDataStorePrivate.h>
+#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
#import <wtf/RetainPtr.h>
static bool finishedNavigation = false;
@@ -281,3 +283,37 @@
TestWebKitAPI::Util::run(&doneFlag);
}
+TEST(ResourceLoadStatistics, RemoveSessionID)
+{
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
+ configuration.get().websiteDataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()] autorelease];
+
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+ // We load a resource so that the NetworkSession stays alive a little bit longer after the session is removed.
+
+ [webView loadHTMLString:@"<a id='link' href='' download>Click me!</a>" baseURL:[NSURL URLWithString:@"http://webkit.org"]];
+ [webView _test_waitForDidFinishNavigation];
+
+ static bool doneFlag = false;
+ [webView evaluateJavaScript:@"document.getElementById('link').click();" completionHandler: ^(id, NSError*) {
+ doneFlag = true;
+ }];
+ TestWebKitAPI::Util::run(&doneFlag);
+
+ [configuration.get().websiteDataStore _setResourceLoadStatisticsEnabled:YES];
+ [configuration.get().websiteDataStore _setResourceLoadStatisticsDebugMode:YES];
+
+ // Trigger ITP tasks.
+ [configuration.get().websiteDataStore _scheduleCookieBlockingUpdate: ^(void) { }];
+ // Trigger removing of the sessionID.
+ TestWebKitAPI::Util::spinRunLoop(2);
+ [webView _close];
+ webView = nullptr;
+ configuration = nullptr;
+
+ auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+ [webView2 loadHTMLString:@"WebKit Test" baseURL:[NSURL URLWithString:@"http://webkit.org"]];
+ [webView2 _test_waitForDidFinishNavigation];
+}