[ Jazz ] http/tests/resourceLoadStatistics/cookie-deletion.html is timing out
https://bugs.webkit.org/show_bug.cgi?id=203813
<rdar://problem/54316765>

Reviewed by Alexey Proskuryakov.

Added console logging to narrow down cause of flaky test which does not
reproduce locally. Changed test expectations to timeout so the bots
actually run the test and the issue can be determined.

* http/tests/resourceLoadStatistics/cookie-deletion-expected.txt:
* http/tests/resourceLoadStatistics/cookie-deletion.html:
* platform/wk2/TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@252630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 909cc3e..a3bcb88 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2019-11-19  Kate Cheney  <katherine_cheney@apple.com>
+
+        [ Jazz ] http/tests/resourceLoadStatistics/cookie-deletion.html is timing out
+        https://bugs.webkit.org/show_bug.cgi?id=203813
+        <rdar://problem/54316765>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Added console logging to narrow down cause of flaky test which does not
+        reproduce locally. Changed test expectations to timeout so the bots
+        actually run the test and the issue can be determined.
+
+        * http/tests/resourceLoadStatistics/cookie-deletion-expected.txt:
+        * http/tests/resourceLoadStatistics/cookie-deletion.html:
+        * platform/wk2/TestExpectations:
+
 2019-11-19  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [Clipboard API] Add support for Clipboard.readText()
diff --git a/LayoutTests/http/tests/resourceLoadStatistics/cookie-deletion-expected.txt b/LayoutTests/http/tests/resourceLoadStatistics/cookie-deletion-expected.txt
index 8b3fcfa..838d165 100644
--- a/LayoutTests/http/tests/resourceLoadStatistics/cookie-deletion-expected.txt
+++ b/LayoutTests/http/tests/resourceLoadStatistics/cookie-deletion-expected.txt
@@ -1,3 +1,21 @@
+CONSOLE MESSAGE: line 116: Test is beginning. document.location.hash is empty.
+CONSOLE MESSAGE: line 122: About to call runTest() for the first time.
+CONSOLE MESSAGE: line 61: step1. About to set a cookie
+CONSOLE MESSAGE: line 126: About to call runTest() after cookie was set. document hash is #step2
+CONSOLE MESSAGE: line 66: step2. About to open an iFrame to test for third party cookie access (should be successful)
+CONSOLE MESSAGE: line 72: step3. About to classify localhost as prevalent
+CONSOLE MESSAGE: line 76: step3. In the callback for testRunner.setStatisticsPrevalentResource
+CONSOLE MESSAGE: line 83: step4. About to open an iFrame to test for third party cookie access (should not be successful)
+CONSOLE MESSAGE: line 89: step5. About to open an iFrame to try to set a cookie as a third party (should fail)
+CONSOLE MESSAGE: line 95: step6. About to open an iFrame and fireDataModificationHandlerAndContinue
+CONSOLE MESSAGE: line 39: In fireDataModificationHandlerAndContinue
+CONSOLE MESSAGE: line 44: Calling statisticsProcessStatisticsAndDataRecords
+CONSOLE MESSAGE: line 41: In callback function for installStatisticsDidScanDataRecordsCallback
+CONSOLE MESSAGE: line 101: step7. About to open an iFrame and setAsNonPrevalentAndContinue
+CONSOLE MESSAGE: line 49: In setAsNonPrevalentAndContinue
+CONSOLE MESSAGE: line 51: In callback function for setStatisticsPrevalentResource
+CONSOLE MESSAGE: line 107: step8. About to open an iFrame and confirm third party has no cookie access
+CONSOLE MESSAGE: line 24: in finishTest
 Test for partitioned and unpartitioned cookie deletion.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
diff --git a/LayoutTests/http/tests/resourceLoadStatistics/cookie-deletion.html b/LayoutTests/http/tests/resourceLoadStatistics/cookie-deletion.html
index 17d8530..58ab96d 100644
--- a/LayoutTests/http/tests/resourceLoadStatistics/cookie-deletion.html
+++ b/LayoutTests/http/tests/resourceLoadStatistics/cookie-deletion.html
@@ -21,6 +21,7 @@
     const subPathToGetCookies = "/get-cookies.php?name1=" + firstPartyCookieName + "&name2=" + thirdPartyCookieName;
 
     function finishTest() {
+        console.log("in finishTest")
         setEnableFeature(false, finishJSTest);
     }
 
@@ -35,14 +36,19 @@
 
 
     function fireDataModificationHandlerAndContinue() {
+        console.log("In fireDataModificationHandlerAndContinue")
         testRunner.installStatisticsDidScanDataRecordsCallback(function() {
+            console.log("In callback function for installStatisticsDidScanDataRecordsCallback")
             setTimeout(runTest, 500);
         });
+        console.log("Calling statisticsProcessStatisticsAndDataRecords")
         testRunner.statisticsProcessStatisticsAndDataRecords();
     }
 
     function setAsNonPrevalentAndContinue() {
+        console.log("In setAsNonPrevalentAndContinue")
         testRunner.setStatisticsPrevalentResource(thirdPartyOrigin, false, function() {
+            console.log("In callback function for setStatisticsPrevalentResource")
             if (testRunner.isStatisticsPrevalentResource(thirdPartyOrigin))
                 testFailed("Host still set as prevalent resource.");
             testRunner.statisticsUpdateCookieBlocking(runTest);
@@ -52,44 +58,53 @@
     function runTest() {
         switch (document.location.hash) {
             case "#step1":
+                console.log("step1. About to set a cookie")
                 // Set first-party cookie for localhost.
                 document.location.href = thirdPartyBaseUrl + subPathToSetFirstPartyCookie + "#" + fragmentWithReturnUrl + "#step2";
                 break;
             case "#step2":
+                console.log("step2. About to open an iFrame to test for third party cookie access (should be successful)")
                 // Check that the third-party has access to its first-party cookies.
                 document.location.hash = "step3";
                 openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should receive first-party cookie.", runTest);
                 break;
             case "#step3":
+                console.log("step3. About to classify localhost as prevalent")
                 // Classify localhost as prevalent.
                 document.location.hash = "step4";
                 testRunner.setStatisticsPrevalentResource(thirdPartyOrigin, true, function() {
+                    console.log("step3. In the callback for testRunner.setStatisticsPrevalentResource")
                     if (!testRunner.isStatisticsPrevalentResource(thirdPartyOrigin))
                         testFailed("Host did not get set as prevalent resource.");
                     testRunner.statisticsUpdateCookieBlocking(runTest);
                 });
                 break;
             case "#step4":
+                console.log("step4. About to open an iFrame to test for third party cookie access (should not be successful)")
                 // Check that the third-party no longer has access to its first-party cookies.
                 document.location.hash = "step5";
                 openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should receive no cookies.", runTest);
                 break;
             case "#step5":
+                console.log("step5. About to open an iFrame to try to set a cookie as a third party (should fail)")
                 // Try setting a cookie as third-party.
                 document.location.hash = "step6";
                 openIframe(thirdPartyBaseUrl + subPathToSetThirdPartyCookie + "&message=Try to set third party cookie.", runTest);
                 break;
             case "#step6":
+                console.log("step6. About to open an iFrame and fireDataModificationHandlerAndContinue")
                 // Check that the third-party still has no access to cookies and then fire data record removal.
                 document.location.hash = "step7";
                 openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Should receive no cookies.", fireDataModificationHandlerAndContinue);
                 break;
             case "#step7":
+                console.log("step7. About to open an iFrame and setAsNonPrevalentAndContinue")
                 // Check that the third-party still has no access to cookies and then declassify localhost.
                 document.location.hash = "step8";
                 openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=After removal, should receive no cookies.", setAsNonPrevalentAndContinue);
                 break;
             case "#step8":
+                console.log("step8. About to open an iFrame and confirm third party has no cookie access")
                 // Check that the third-party still has no access to cookies.
                 openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=After declassified, should receive no cookies.", finishTest);
                 break;
@@ -98,15 +113,17 @@
 
     if (document.location.host === partitionHost && document.location.hash === "" && window.testRunner && window.internals) {
         setEnableFeature(true, function() {
+            console.log("Test is beginning. document.location.hash is empty.")
             testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
             testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
 
             testRunner.dumpChildFramesAsText();
             document.location.hash = "step1";
-
+            console.log("About to call runTest() for the first time.")
             runTest();
         });
     } else {
+        console.log("About to call runTest() after cookie was set. document hash is " + document.location.hash)
         runTest();
     }
 
diff --git a/LayoutTests/platform/wk2/TestExpectations b/LayoutTests/platform/wk2/TestExpectations
index f2e9b0a..8e259ed 100644
--- a/LayoutTests/platform/wk2/TestExpectations
+++ b/LayoutTests/platform/wk2/TestExpectations
@@ -737,7 +737,7 @@
 http/tests/resourceLoadStatistics [ Pass ]
 http/tests/websocket/connection-refusal-in-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/cookie-deletion.html [ Pass Timeout ]
 http/tests/resourceLoadStatistics/cookies-with-and-without-user-interaction.html [ Skip ]
 http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-third-party-redirects.html [ Skip ]
 http/tests/resourceLoadStatistics/strip-referrer-to-origin-for-third-party-requests.html [ Skip ]