blob: f2003124d1edaf9d4b81bf328d162f7e07d4761e [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tests for Prevalent Resource Without User Interaction</title>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<script>
const hostUnderTest = "127.0.0.1:8000";
const statisticsUrl = "http://" + hostUnderTest + "/temp";
function finishTest () {
if (document.cookie !== "")
testFailed("Cookie not deleted: " + document.cookie);
else
testPassed("Cookie deleted.");
internals.setResourceLoadStatisticsEnabled(false);
testRunner.statisticsResetToConsistentState(function() {
testRunner.notifyDone();
});
}
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, true, function() {
if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
testFailed("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.installStatisticsDidModifyDataRecordsCallback(function() {
setTimeout("finishTest()", 1000);
});
testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
testRunner.setStatisticsMinimumTimeBetweenDataRecordsRemoval(0);
testRunner.statisticsProcessStatisticsAndDataRecords();
});
});
}
if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
testRunner.waitUntilDone();
internals.setResourceLoadStatisticsEnabled(true);
testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
runTestRunnerTest();
}
</script>
</body>
</html>