Add stability to tests for web API statistics
[WebKit-https.git] / LayoutTests / http / tests / webAPIStatistics / navigator-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 navigator 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 navigator functions accessed data collection in ResourceLoadStatistics plist by querying for all the navigator 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 useragent = navigator.userAgent;
27         var javaenabled = navigator.javaEnabled();
28         var cookieEnabled = navigator.cookieEnabled;
29         var mimetypes = navigator.mimeTypes;
30         var plugins = navigator.plugins;
31         var appversion = navigator.appVersion;
32         testRunner.statisticsNotifyObserver();
33     }
34
35     if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
36         testRunner.dumpAsText();
37         testRunner.dumpResourceLoadStatistics();
38         testRunner.waitUntilDone();
39         internals.setResourceLoadStatisticsEnabled(true);
40         testRunner.setWebAPIStatisticsEnabled(true);
41         runTestRunnerTest();
42     }
43 </script>
44 </body>
45 </html>