Title: [226924] branches/safari-605-branch

Diff

Modified: branches/safari-605-branch/Source/WebKit/ChangeLog (226923 => 226924)


--- branches/safari-605-branch/Source/WebKit/ChangeLog	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Source/WebKit/ChangeLog	2018-01-12 23:56:32 UTC (rev 226924)
@@ -1,5 +1,49 @@
 2018-01-12  Jason Marcell  <[email protected]>
 
+        Cherry-pick r226838. rdar://problem/36480711
+
+    2018-01-11  Brent Fulgham  <[email protected]>
+
+            REGRESSION(r219530): ResourceLoadStatisticsPersistentStorage should be read-only in ephemeral sessions
+            https://bugs.webkit.org/show_bug.cgi?id=181136
+            <rdar://problem/36116604>
+
+            Reviewed by Chris Dumez.
+
+            Some uses of WebKit involve running a UIProcess as an ephemeral session for the life of the process. In this
+            case, we do not initialize the data path for the set of load statistics triggering an assertion.
+
+            We actually intended ephemeral sessions to consume the existing resource load data (presumably captured during
+            non-ephemeral browsing). This would be a read-only mode, where it would not add new entries to the load
+            statistics, but would take advantage of existing observations. Currently that does not happen (for this type
+            of WebKit embed), which forces each run as an ephemeral session to build up in-memory browsing data until it has
+            enough observations to begin modifying loads.
+
+            We need to set the ResourceLoadStatisticsPersistentStorage object to a "read only" mode in this case, so
+            that it read (but does not write) from this database.
+
+            Tested by ephemeral website data TestWebKitAPI tests.
+
+            * UIProcess/ResourceLoadStatisticsPersistentStorage.cpp:
+            (WebKit::ResourceLoadStatisticsPersistentStorage::create): Added to allow creation of the right style of
+            Persistent Storage.
+            (WebKit::ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage): Initialize the
+            new data member.
+            (WebKit::ResourceLoadStatisticsPersistentStorage::asyncWriteTimerFired): RELEASE_ASSERT that we never run
+            this method when in "read only" mode.
+            (WebKit::ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk): Ditto.
+            (WebKit::ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore): Return early if asked to
+            schedule a write operation for a "read only" persistent store.
+            (WebKit::ResourceLoadStatisticsPersistentStorage::finishAllPendingWorkSynchronously): RELEASE_ASSERT if we
+            ever shut down in "read only" mode with an active write timer.
+            * UIProcess/ResourceLoadStatisticsPersistentStorage.h:
+            * UIProcess/WebResourceLoadStatisticsStore.cpp:
+            (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore): Pass a flag indicating whether the
+            storage session is ephemeral or not.
+            * UIProcess/WebResourceLoadStatisticsStore.h:
+
+2018-01-12  Jason Marcell  <[email protected]>
+
         Apply patch. rdar://problem/36303061
 
     Disable WebKit features we don't want to ship after branching

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.cpp (226923 => 226924)


--- branches/safari-605-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.cpp	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.cpp	2018-01-12 23:56:32 UTC (rev 226924)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -82,10 +82,11 @@
     return KeyedDecoder::decoder(reinterpret_cast<const uint8_t*>(buffer.data()), buffer.size());
 }
 
-ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage(WebResourceLoadStatisticsStore& store, const String& storageDirectoryPath)
+ResourceLoadStatisticsPersistentStorage::ResourceLoadStatisticsPersistentStorage(WebResourceLoadStatisticsStore& store, const String& storageDirectoryPath, IsReadOnly isReadOnly)
     : m_memoryStore(store)
     , m_storageDirectoryPath(storageDirectoryPath)
     , m_asyncWriteTimer(RunLoop::main(), this, &ResourceLoadStatisticsPersistentStorage::asyncWriteTimerFired)
+    , m_isReadOnly(isReadOnly)
 {
 }
 
@@ -239,6 +240,7 @@
 void ResourceLoadStatisticsPersistentStorage::asyncWriteTimerFired()
 {
     ASSERT(RunLoop::isMain());
+    RELEASE_ASSERT(m_isReadOnly != IsReadOnly::Yes);
     m_memoryStore.statisticsQueue().dispatch([this] () mutable {
         writeMemoryStoreToDisk();
     });
@@ -247,6 +249,7 @@
 void ResourceLoadStatisticsPersistentStorage::writeMemoryStoreToDisk()
 {
     ASSERT(!RunLoop::isMain());
+    RELEASE_ASSERT(m_isReadOnly != IsReadOnly::Yes);
 
     m_hasPendingWrite = false;
     stopMonitoringDisk();
@@ -281,6 +284,8 @@
 void ResourceLoadStatisticsPersistentStorage::scheduleOrWriteMemoryStore(ForceImmediateWrite forceImmediateWrite)
 {
     ASSERT(!RunLoop::isMain());
+    if (m_isReadOnly == IsReadOnly::Yes)
+        return;
 
     auto timeSinceLastWrite = MonotonicTime::now() - m_lastStatisticsWriteTime;
     if (forceImmediateWrite != ForceImmediateWrite::Yes && timeSinceLastWrite < minimumWriteInterval) {
@@ -312,6 +317,11 @@
 
 void ResourceLoadStatisticsPersistentStorage::finishAllPendingWorkSynchronously()
 {
+    if (m_isReadOnly == IsReadOnly::Yes) {
+        RELEASE_ASSERT(!m_asyncWriteTimer.isActive());
+        return;
+    }
+
     m_asyncWriteTimer.stop();
 
     BinarySemaphore semaphore;

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.h (226923 => 226924)


--- branches/safari-605-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.h	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/ResourceLoadStatisticsPersistentStorage.h	2018-01-12 23:56:32 UTC (rev 226924)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,7 +41,8 @@
 
 class ResourceLoadStatisticsPersistentStorage {
 public:
-    ResourceLoadStatisticsPersistentStorage(WebResourceLoadStatisticsStore&, const String& storageDirectoryPath);
+    enum class IsReadOnly { No, Yes };
+    ResourceLoadStatisticsPersistentStorage(WebResourceLoadStatisticsStore&, const String& storageDirectoryPath, IsReadOnly);
     ~ResourceLoadStatisticsPersistentStorage();
 
     void initialize();
@@ -78,6 +79,7 @@
     std::unique_ptr<WebCore::FileMonitor> m_fileMonitor;
     WallTime m_lastStatisticsFileSyncTime;
     MonotonicTime m_lastStatisticsWriteTime;
+    IsReadOnly m_isReadOnly { IsReadOnly::No };
     bool m_hasPendingWrite { false };
 };
 

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (226923 => 226924)


--- branches/safari-605-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-01-12 23:56:32 UTC (rev 226924)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -147,9 +147,9 @@
     return mergedDates;
 }
 
-WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(const String& resourceLoadStatisticsDirectory, Function<void(const String&)>&& testingCallback, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&& updatePrevalentDomainsToPartitionOrBlockCookiesHandler, HasStorageAccessForFrameHandler&& hasStorageAccessForFrameHandler, GrantStorageAccessForFrameHandler&& grantStorageAccessForFrameHandler, RemovePrevalentDomainsHandler&& removeDomainsHandler)
+WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(const String& resourceLoadStatisticsDirectory, Function<void(const String&)>&& testingCallback, bool isEphemeral, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&& updatePrevalentDomainsToPartitionOrBlockCookiesHandler, HasStorageAccessForFrameHandler&& hasStorageAccessForFrameHandler, GrantStorageAccessForFrameHandler&& grantStorageAccessForFrameHandler, RemovePrevalentDomainsHandler&& removeDomainsHandler)
     : m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility))
-    , m_persistentStorage(*this, resourceLoadStatisticsDirectory)
+    , m_persistentStorage(*this, resourceLoadStatisticsDirectory, isEphemeral ? ResourceLoadStatisticsPersistentStorage::IsReadOnly::Yes : ResourceLoadStatisticsPersistentStorage::IsReadOnly::No)
     , m_updatePrevalentDomainsToPartitionOrBlockCookiesHandler(WTFMove(updatePrevalentDomainsToPartitionOrBlockCookiesHandler))
     , m_hasStorageAccessForFrameHandler(WTFMove(hasStorageAccessForFrameHandler))
     , m_grantStorageAccessForFrameHandler(WTFMove(grantStorageAccessForFrameHandler))

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (226923 => 226924)


--- branches/safari-605-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2018-01-12 23:56:32 UTC (rev 226924)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -65,9 +65,9 @@
     using HasStorageAccessForFrameHandler = WTF::Function<void(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::Function<void(bool hasAccess)>&& callback)>;
     using GrantStorageAccessForFrameHandler = WTF::Function<void(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::Function<void(bool wasGranted)>&& callback)>;
     using RemovePrevalentDomainsHandler = WTF::Function<void (const Vector<String>&)>;
-    static Ref<WebResourceLoadStatisticsStore> create(const String& resourceLoadStatisticsDirectory, Function<void (const String&)>&& testingCallback, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&& updatePrevalentDomainsToPartitionOrBlockCookiesHandler = [](const Vector<String>&, const Vector<String>&, const Vector<String>&, ShouldClearFirst) { }, HasStorageAccessForFrameHandler&& hasStorageAccessForFrameHandler = [](const String&, const String&, uint64_t, uint64_t, WTF::Function<void(bool)>&&) { }, GrantStorageAccessForFrameHandler&& grantStorageAccessForFrameHandler = [](const String&, const String&, uint64_t, uint64_t, WTF::Function<void(bool)>&&) { }, RemovePrevalentDomainsHandler&& removeDomainsHandler = [] (const Vector<String>&) { })
+    static Ref<WebResourceLoadStatisticsStore> create(const String& resourceLoadStatisticsDirectory, Function<void (const String&)>&& testingCallback, bool isEphemeral, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&& updatePrevalentDomainsToPartitionOrBlockCookiesHandler = [](const Vector<String>&, const Vector<String>&, const Vector<String>&, ShouldClearFirst) { }, HasStorageAccessForFrameHandler&& hasStorageAccessForFrameHandler = [](const String&, const String&, uint64_t, uint64_t, WTF::Function<void(bool)>&&) { }, GrantStorageAccessForFrameHandler&& grantStorageAccessForFrameHandler = [](const String&, const String&, uint64_t, uint64_t, WTF::Function<void(bool)>&&) { }, RemovePrevalentDomainsHandler&& removeDomainsHandler = [] (const Vector<String>&) { })
     {
-        return adoptRef(*new WebResourceLoadStatisticsStore(resourceLoadStatisticsDirectory, WTFMove(testingCallback), WTFMove(updatePrevalentDomainsToPartitionOrBlockCookiesHandler), WTFMove(hasStorageAccessForFrameHandler), WTFMove(grantStorageAccessForFrameHandler), WTFMove(removeDomainsHandler)));
+        return adoptRef(*new WebResourceLoadStatisticsStore(resourceLoadStatisticsDirectory, WTFMove(testingCallback), isEphemeral, WTFMove(updatePrevalentDomainsToPartitionOrBlockCookiesHandler), WTFMove(hasStorageAccessForFrameHandler), WTFMove(grantStorageAccessForFrameHandler), WTFMove(removeDomainsHandler)));
     }
 
     ~WebResourceLoadStatisticsStore();
@@ -143,7 +143,7 @@
     void logTestingEvent(const String&);
 
 private:
-    WebResourceLoadStatisticsStore(const String&, Function<void(const String&)>&& testingCallback, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&&, HasStorageAccessForFrameHandler&&, GrantStorageAccessForFrameHandler&&, RemovePrevalentDomainsHandler&&);
+    WebResourceLoadStatisticsStore(const String&, Function<void(const String&)>&& testingCallback, bool isEphemeral, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&&, HasStorageAccessForFrameHandler&&, GrantStorageAccessForFrameHandler&&, RemovePrevalentDomainsHandler&&);
 
     void removeDataRecords();
 

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (226923 => 226924)


--- branches/safari-605-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2018-01-12 23:56:32 UTC (rev 226924)
@@ -28,6 +28,7 @@
 
 #include "APIProcessPoolConfiguration.h"
 #include "APIWebsiteDataRecord.h"
+#include "APIWebsiteDataStore.h"
 #include "NetworkProcessMessages.h"
 #include "StorageManager.h"
 #include "StorageProcessCreationParameters.h"
@@ -78,6 +79,11 @@
     return adoptRef(*new WebsiteDataStore(WTFMove(configuration), sessionID));
 }
 
+WebsiteDataStore::Configuration::Configuration()
+    : resourceLoadStatisticsDirectory(API::WebsiteDataStore::defaultResourceLoadStatisticsDirectory())
+{
+}
+
 WebsiteDataStore::WebsiteDataStore(Configuration configuration, PAL::SessionID sessionID)
     : m_sessionID(sessionID)
     , m_configuration(WTFMove(configuration))
@@ -1401,7 +1407,7 @@
     }
 
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
-    m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(m_configuration.resourceLoadStatisticsDirectory, WTFMove(callback), [this, protectedThis = makeRef(*this)] (const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst) {
+    m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(m_configuration.resourceLoadStatisticsDirectory, WTFMove(callback), m_sessionID.isEphemeral(), [this, protectedThis = makeRef(*this)] (const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst) {
         updatePrevalentDomainsToPartitionOrBlockCookies(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, shouldClearFirst);
     }, [this, protectedThis = makeRef(*this)] (const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool hasAccess)>&& callback) {
         hasStorageAccessForFrameHandler(resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(callback));
@@ -1411,7 +1417,7 @@
         removePrevalentDomains(domainsToRemove);
     });
 #else
-    m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(m_configuration.resourceLoadStatisticsDirectory, WTFMove(callback));
+    m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(m_configuration.resourceLoadStatisticsDirectory, WTFMove(callback), m_sessionID.isEphemeral());
 #endif
 
     for (auto& processPool : processPools())

Modified: branches/safari-605-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (226923 => 226924)


--- branches/safari-605-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h	2018-01-12 23:56:32 UTC (rev 226924)
@@ -86,6 +86,8 @@
         String resourceLoadStatisticsDirectory;
         String _javascript_ConfigurationDirectory;
         String cookieStorageFile;
+
+        explicit Configuration();
     };
     static Ref<WebsiteDataStore> createNonPersistent();
     static Ref<WebsiteDataStore> create(Configuration, PAL::SessionID);

Modified: branches/safari-605-branch/Tools/ChangeLog (226923 => 226924)


--- branches/safari-605-branch/Tools/ChangeLog	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Tools/ChangeLog	2018-01-12 23:56:32 UTC (rev 226924)
@@ -1,3 +1,23 @@
+2018-01-12  Jason Marcell  <[email protected]>
+
+        Cherry-pick r226838. rdar://problem/36480711
+
+    2018-01-11  Brent Fulgham  <[email protected]>
+
+            REGRESSION(r219530): ResourceLoadStatisticsPersistentStorage should be read-only in ephemeral sessions
+            https://bugs.webkit.org/show_bug.cgi?id=181136
+            <rdar://problem/36116604>
+
+            Reviewed by Chris Dumez.
+
+            Add a new API test to confirm that ResourceLoadStatistics can be turned on safely for ephemeral
+            browsing sessions.
+
+            * Scripts/run-gtk-tests:
+            (GtkTestRunner): Unskip test now that it passes.
+            * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+            (TEST): Add new WebsiteDataStoreEphemeral test.
+
 2018-01-11  Jason Marcell  <[email protected]>
 
         Cherry-pick r226753. rdar://problem/36429138

Modified: branches/safari-605-branch/Tools/Scripts/run-gtk-tests (226923 => 226924)


--- branches/safari-605-branch/Tools/Scripts/run-gtk-tests	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Tools/Scripts/run-gtk-tests	2018-01-12 23:56:32 UTC (rev 226924)
@@ -43,7 +43,6 @@
         SkippedTest("WebKit2Gtk/TestWebViewEditor", "/webkit2/WebKitWebView/editable/editable", "Test hits an assertion in Debug builds", 151654, "Debug"),
         SkippedTest("WebKit2Gtk/TestWebExtensions", "/webkit2/WebKitWebView/install-missing-plugins-permission-request", "Test times out", 147822),
         SkippedTest("WebKit2Gtk/TestWebsiteData", "/webkit2/WebKitWebsiteData/databases", "Test fails to clear database data", 181251),
-        SkippedTest("WebKit2Gtk/TestWebsiteData", "/webkit2/WebKitWebsiteData/ephemeral", "Test hits an assertion in Debug builds", 181136, "Debug"),
         SkippedTest("WebKit/TestWebKit", "WebKit.MouseMoveAfterCrash", "Test is flaky", 85066),
         SkippedTest("WebKit/TestWebKit", "WebKit.NewFirstVisuallyNonEmptyLayoutForImages", "Test is flaky", 85066),
         SkippedTest("WebKit/TestWebKit", "WebKit.NewFirstVisuallyNonEmptyLayoutFrames", "Test fails", 85037),

Modified: branches/safari-605-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm (226923 => 226924)


--- branches/safari-605-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2018-01-12 23:56:28 UTC (rev 226923)
+++ branches/safari-605-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm	2018-01-12 23:56:32 UTC (rev 226924)
@@ -219,4 +219,46 @@
     EXPECT_FALSE([WKWebsiteDataStore _defaultDataStoreExists]);
 }
 
+TEST(WebKit, WebsiteDataStoreEphemeral)
+{
+    RetainPtr<WebsiteDataStoreCustomPathsMessageHandler> handler = adoptNS([[WebsiteDataStoreCustomPathsMessageHandler alloc] init]);
+    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
+
+    NSURL *defaultResourceLoadStatisticsPath = [NSURL fileURLWithPath:[@"~/Library/WebKit/TestWebKitAPI/WebsiteData/ResourceLoadStatistics/" stringByExpandingTildeInPath] isDirectory:YES];
+
+    [[NSFileManager defaultManager] removeItemAtURL:defaultResourceLoadStatisticsPath error:nil];
+
+    EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsPath.path]);
+
+    configuration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
+    [configuration.get().websiteDataStore _setResourceLoadStatisticsEnabled:YES];
+
+    // We expect the directory to be created by starting up the data store machinery, but not the data file.
+    EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsPath.path]);
+
+    NSURL *defaultResourceLoadStatisticsFilePath = [NSURL fileURLWithPath:[@"~/Library/WebKit/TestWebKitAPI/WebsiteData/ResourceLoadStatistics/full_browsing_session_resourceLog.plist" stringByExpandingTildeInPath] isDirectory:NO];
+    EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsFilePath.path]);
+
+    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"WebsiteDataStoreCustomPaths" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+
+    [[[webView configuration] processPool] _syncNetworkProcessCookies];
+
+    // Forcibly shut down everything of WebKit that we can.
+    [[[webView configuration] processPool] _terminateStorageProcess];
+    auto pid = [webView _webProcessIdentifier];
+    if (pid)
+        kill(pid, SIGKILL);
+
+    webView = nil;
+    handler = nil;
+    configuration = nil;
+
+    EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsPath.path]);
+    EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:defaultResourceLoadStatisticsFilePath.path]);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to