<!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>
    <script src="resources/util.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);
        setEnableFeature(false, 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();
        setEnableFeature(true, function() {
            runTestRunnerTest();
        });
    }
</script>
</body>
</html>
