Rename LineLayoutInterface to LineLayoutTraversal
[WebKit-https.git] / LayoutTests / http / tests / resourceLoadStatistics / non-prevalent-resource-with-user-interaction-database.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <meta charset="UTF-8">
5     <title>Tests for Non-Prevalent Resource With User Interaction</title>
6     <script src="/js-test-resources/js-test.js"></script>
7     <script src="resources/util.js"></script>
8 </head>
9 <body>
10 <script>
11     const hostUnderTest = "127.0.0.1:8000";
12     const statisticsUrl = "http://" + hostUnderTest + "/temp";
13     const otherPrevalentUrl = "http://localhost:8000/temp";
14
15     function runTestRunnerTest() {
16         if (document.cookie !== "")
17             testFailed("document.cookie not empty.");
18         const cookie = "testCookie=testValue";
19         document.cookie = cookie + "; max-age=100;";
20         if (document.cookie !== cookie)
21             testFailed("document.cookie did not get set.");
22
23         testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() {
24             if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
25                 testFailed("Host did not get set as non-prevalent resource.");
26
27             // This is done to not have an empty set of prevalent resources.
28             // Otherwise data records are never scanned.
29             testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true, function() {
30                 if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl))
31                     testFailed("Other host did not get set as prevalent resource.");
32
33                 testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() {
34                     if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl))
35                         testFailed("Host did not get logged for user interaction.");
36
37                     testRunner.installStatisticsDidScanDataRecordsCallback(function() {
38                         if (document.cookie === cookie)
39                             testPassed("Cookie not deleted.");
40                         else
41                             testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
42
43                         setEnableFeature(false, function() {
44                             testRunner.notifyDone();
45                         });
46                     });
47                     testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
48                     testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
49                     testRunner.statisticsProcessStatisticsAndDataRecords();
50                 });
51             });
52         });
53     }
54
55     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
56         testRunner.setUseITPDatabase(true);
57         testRunner.waitUntilDone();
58         setEnableFeature(true, function() {
59             testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
60             runTestRunnerTest();
61         });
62     }
63 </script>
64 </body>
65 </html>