Add stability to tests for web API statistics
[WebKit-https.git] / LayoutTests / http / tests / webAPIStatistics / screen-functions-accessed-data-collection.html
1 <!DOCTYPE html><!-- webkit-test-runner [ internal:WebAPIStatisticsEnabled=true ] -->
2 <head>
3     <meta charset="UTF-8">
4     <title>Test for screen functions accessed data collection in resource load statistics</title>
5 </head>
6 <script>
7     internals.setResourceLoadStatisticsEnabled(false);
8 </script>
9 <body>
10 <p> Tests for screen functions accessed data collection in ResourceLoadStatistics plist by querying for all the screen properties and dumping the entire resource load statistics map. </p>
11 <script>
12     const hostUnderTest = "127.0.0.1:8000";
13     const statisticsUrl = "http://" + hostUnderTest + "/temp";
14
15     function completeTest() { 
16         testRunner.statisticsResetToConsistentState(function() {
17             testRunner.notifyDone();
18         });
19     }
20
21     function runTestRunnerTest() {
22         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
23
24         testRunner.installStatisticsDidScanDataRecordsCallback(completeTest);
25     
26         var availTop = screen.availTop;
27         var colorDepth = screen.colorDepth;
28         var pixelDepth = screen.pixelDepth;
29         var height = screen.height;
30         var width = screen.width;
31         var availLeft = screen.availLeft;
32         var availHeight = screen.availHeight;
33         var availWidth = screen.availWidth;
34         testRunner.statisticsNotifyObserver();
35     }
36
37     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
38         testRunner.dumpAsText();
39         testRunner.dumpResourceLoadStatistics();
40         testRunner.waitUntilDone();
41         internals.setResourceLoadStatisticsEnabled(true);
42         testRunner.setWebAPIStatisticsEnabled(true);
43         runTestRunnerTest();
44     }
45 </script>
46 </body>
47 </html>