REGRESSION (~244100) [Mac WK2 Debug] Layout Test http/tests/resourceLoadStatistics/prune-statistics.html is a flaky failure (197285)
https://bugs.webkit.org/show_bug.cgi?id=197285
<rdar://problem/50208370>

Patch by Kate Cheney <katherine_cheney@apple.com> on 2019-10-15
Reviewed by Chris Dumez.

Source/WebKit:

This patch fixes a flaky failure which was being caused by other
resourceLoadStatistics tests scheduling processing checks which
were called during execution of prune-statistics.html.
Now, any pending processing checks are cancelled between tests.

* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):

LayoutTests:

Remove a "skipped" expectation for a previously flaky test that should
be fixed by this patch.
* platform/mac-wk2/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251176 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 1e93c15..4b4848a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2019-10-15  Kate Cheney  <katherine_cheney@apple.com>
+
+        REGRESSION (~244100) [Mac WK2 Debug] Layout Test http/tests/resourceLoadStatistics/prune-statistics.html is a flaky failure (197285)
+        https://bugs.webkit.org/show_bug.cgi?id=197285
+        <rdar://problem/50208370>
+
+        Reviewed by Chris Dumez.
+
+        Remove a "skipped" expectation for a previously flaky test that should 
+        be fixed by this patch.
+        * platform/mac-wk2/TestExpectations:
+
 2019-10-15  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         editing/async-clipboard/clipboard-item-basic.html is a flaky failure on macOS and iOS
diff --git a/LayoutTests/platform/mac-wk2/TestExpectations b/LayoutTests/platform/mac-wk2/TestExpectations
index 3961db1..fddec70 100644
--- a/LayoutTests/platform/mac-wk2/TestExpectations
+++ b/LayoutTests/platform/mac-wk2/TestExpectations
@@ -896,8 +896,6 @@
 
 webkit.org/b/197283 fast/css-custom-paint/animate-repaint.html [ Pass Failure ]
 
-webkit.org/b/197285 http/tests/resourceLoadStatistics/prune-statistics.html [ Pass Failure ]
-
 webkit.org/b/197207 http/wpt/resource-timing/rt-resources-per-frame.html [ Pass Failure ]
 
 webkit.org/b/197425 [ Mojave Debug ] scrollingcoordinator/scrolling-tree/scrolling-tree-includes-frame.html [ Pass Failure ]
@@ -932,4 +930,4 @@
 
 webkit.org/b/199089 [ Mojave+ Debug ] plugins/window-open.html [ Skip ]
 
-webkit.org/b/202500 [ Mojave ] crypto/workers/subtle/aes-indexeddb.html [ Timeout ]
\ No newline at end of file
+webkit.org/b/202500 [ Mojave ] crypto/workers/subtle/aes-indexeddb.html [ Timeout ]
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index d87419c..01bcbf1 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,19 @@
+2019-10-15  Kate Cheney  <katherine_cheney@apple.com>
+
+        REGRESSION (~244100) [Mac WK2 Debug] Layout Test http/tests/resourceLoadStatistics/prune-statistics.html is a flaky failure (197285)
+        https://bugs.webkit.org/show_bug.cgi?id=197285
+        <rdar://problem/50208370>
+
+        Reviewed by Chris Dumez.
+
+        This patch fixes a flaky failure which was being caused by other
+        resourceLoadStatistics tests scheduling processing checks which
+        were called during execution of prune-statistics.html.
+        Now, any pending processing checks are cancelled between tests.
+
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent):
+
 2019-10-15  Chris Dumez  <cdumez@apple.com>
 
         [iOS] Maintain the last Back/Forward cache entry when the application gets suspended
diff --git a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
index cb7e859..e08ab5d 100644
--- a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
+++ b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
@@ -898,6 +898,8 @@
                     RELEASE_LOG(ResourceLoadStatistics, "WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent After being cleared, m_statisticsStore is null when trying to grandfather data.");
             }
         });
+        
+        m_statisticsStore->cancelPendingStatisticsProcessingRequest();
     });
 }