| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <title>Tests for Non-Prevalent Resource Without User Interaction</title> |
| <script src="/js-test-resources/js-test.js"></script> |
| <script src="resources/util.js"></script> |
| </head> |
| <body> |
| <script> |
| const hostUnderTest = "127.0.0.1:8000"; |
| const statisticsUrl = "http://" + hostUnderTest + "/temp"; |
| const otherPrevalentUrl = "http://localhost:8000/temp"; |
| |
| function runTestRunnerTest() { |
| if (document.cookie !== "") |
| testFailed("document.cookie not empty."); |
| const cookie = "testCookie=testValue"; |
| document.cookie = cookie + "; max-age=100;"; |
| if (document.cookie !== cookie) |
| testFailed("document.cookie did not get set."); |
| |
| testRunner.setStatisticsPrevalentResource(statisticsUrl, false, function() { |
| if (testRunner.isStatisticsPrevalentResource(statisticsUrl)) |
| testFailed("Host did not get set as non-prevalent resource."); |
| |
| // This is done to not have an empty set of prevalent resources. |
| // Otherwise data records are never scanned. |
| testRunner.setStatisticsPrevalentResource(otherPrevalentUrl, true, function() { |
| if (!testRunner.isStatisticsPrevalentResource(otherPrevalentUrl)) |
| testFailed("Other host did not get set as prevalent resource."); |
| |
| testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, false, function() { |
| if (testRunner.isStatisticsHasHadUserInteraction(statisticsUrl)) |
| testFailed("Host did not get cleared of user interaction."); |
| |
| testRunner.installStatisticsDidScanDataRecordsCallback(function() { |
| if (document.cookie === cookie) |
| testPassed("Cookie not deleted."); |
| else |
| testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie); |
| |
| setEnableFeature(false, function() { |
| testRunner.notifyDone(); |
| }); |
| }); |
| testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false); |
| testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0); |
| testRunner.statisticsProcessStatisticsAndDataRecords(); |
| }); |
| }); |
| }); |
| } |
| |
| if (document.location.host === hostUnderTest && window.testRunner && window.internals) { |
| testRunner.setUseITPDatabase(true); |
| testRunner.waitUntilDone(); |
| setEnableFeature(true, runTestRunnerTest); |
| } |
| </script> |
| </body> |
| </html> |