Add completion handlers to TestRunner functions setStatisticsLastSeen(), setStatistic...
[WebKit-https.git] / LayoutTests / http / tests / resourceLoadStatistics / classify-as-prevalent-based-on-top-frame-redirect-collusion.html
index ab2a372..459bb17 100644 (file)
         testRunner.setStatisticsTopFrameUniqueRedirectFrom(topFrameOrigin2, topFrameOrigin3);
         testRunner.setStatisticsTopFrameUniqueRedirectFrom(topFrameOrigin3, topFrameOrigin4);
 
-        testRunner.setStatisticsPrevalentResource(statisticsUrl, true);
-        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
-            testFailed("Host explicity set did not get set as prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin1))
-            testPassed("Colluding host 1 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin1))
-            testFailed("Colluding host 1 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin2))
-            testPassed("Colluding host 2 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin2))
-            testFailed("Colluding host 2 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin3))
-            testPassed("Colluding host 3 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin3))
-            testFailed("Colluding host 3 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin4))
-            testPassed("Colluding host 4 got set as prevalent resource.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin4))
-            testFailed("Colluding host 4 got classified as very prevalent resource.");
-        if (testRunner.isStatisticsPrevalentResource(topFrameOrigin5))
-            testPassed("Colluding localhost got set as prevalent resource after actual navigational redirect.");
-        if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin5))
-            testFailed("Colluding localhost got classified as very prevalent resource.");
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() {
+            if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                testFailed("Host explicity set did not get set as prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin1))
+                testPassed("Colluding host 1 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin1))
+                testFailed("Colluding host 1 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin2))
+                testPassed("Colluding host 2 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin2))
+                testFailed("Colluding host 2 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin3))
+                testPassed("Colluding host 3 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin3))
+                testFailed("Colluding host 3 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin4))
+                testPassed("Colluding host 4 got set as prevalent resource.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin4))
+                testFailed("Colluding host 4 got classified as very prevalent resource.");
+            if (testRunner.isStatisticsPrevalentResource(topFrameOrigin5))
+                testPassed("Colluding localhost got set as prevalent resource after actual navigational redirect.");
+            if (testRunner.isStatisticsVeryPrevalentResource(topFrameOrigin5))
+                testFailed("Colluding localhost got classified as very prevalent resource.");
 
-        setEnableFeature(false, finishJSTest);
+            setEnableFeature(false, finishJSTest);
+        });
     }
 
     if (document.location.hash === "" && window.testRunner && window.internals) {
         setEnableFeature(true, function() {
-            testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
-            if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
-                testFailed("Host did not get set as non-prevalent resource.");
+            testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
+                if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+                    testFailed("Host did not get set as non-prevalent resource.");
 
-            document.location.href = topFrameOrigin5 + "resourceLoadStatistics/resources/redirect.php?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html#continue";
+                document.location.href = topFrameOrigin5 + "resourceLoadStatistics/resources/redirect.php?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html#continue";
+            });
         });
     } else {
         testRunner.statisticsNotifyObserver();