<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Test for Telemetry Generation</title>
    <script src="/js-test-resources/js-test.js"></script>
    <script src="resources/util.js"></script>
</head>
<body>
<script>
    description("Tests that telemetry for prevalent resources is calculated correctly.");
    jsTestIsAsync = true;

    const topFrameUrl1 = "http://127.0.0.1:8000/temp";
    const topFrameUrl2 = "http://127.0.0.2:8000/temp";
    const topFrameUrl3 = "http://127.0.0.3:8000/temp";
    const topFrameUrl4 = "http://127.0.0.4:8000/temp";
    const prevalentResourceUrl1 = "http://127.0.1.1:8000/temp";
    const prevalentResourceUrl2 = "http://127.0.1.2:8000/temp";
    const prevalentResourceUrl3 = "http://127.0.1.3:8000/temp";
    const prevalentResourceUrl4 = "http://127.0.1.4:8000/temp";

    function checkInsufficientClassificationAndContinue() {
        if (!testRunner.isStatisticsPrevalentResource(prevalentResourceUrl1)) {
            testFailed("Host 1 did not get classified as prevalent resource.");
            setEnableFeature(false, finishJSTest);
        } else if (!testRunner.isStatisticsPrevalentResource(prevalentResourceUrl2)) {
            testFailed("Host 2 did not get classified as prevalent resource.");
            setEnableFeature(false, finishJSTest);
        } else {
            testPassed("Hosts classified as prevalent resources.");
            runTelemetryAndContinue();
        }
    }

    function checkSufficientClassificationAndContinue() {
        if (!testRunner.isStatisticsPrevalentResource(prevalentResourceUrl1)) {
            testFailed("Host 1 did not get classified as prevalent resource.");
            setEnableFeature(false, finishJSTest);
        } else if (!testRunner.isStatisticsPrevalentResource(prevalentResourceUrl2)) {
            testFailed("Host 2 did not get classified as prevalent resource.");
            setEnableFeature(false, finishJSTest);
        } else if (!testRunner.isStatisticsPrevalentResource(prevalentResourceUrl3)) {
            testFailed("Host 3 did not get classified as prevalent resource.");
            setEnableFeature(false, finishJSTest);
        } else if (!testRunner.isStatisticsPrevalentResource(prevalentResourceUrl4)) {
            testFailed("Host 4 did not get classified as prevalent resource.");
            setEnableFeature(false, finishJSTest);
        } else {
            testPassed("Hosts classified as prevalent resources.");
            runTelemetryAndContinue();
        }
    }

    function makeUrlPrevalent(prevalentResourceUrl) {
        testRunner.setStatisticsSubframeUnderTopFrameOrigin(prevalentResourceUrl, topFrameUrl1);
        testRunner.setStatisticsSubframeUnderTopFrameOrigin(prevalentResourceUrl, topFrameUrl2);
        testRunner.setStatisticsSubframeUnderTopFrameOrigin(prevalentResourceUrl, topFrameUrl3);
        testRunner.setStatisticsSubframeUnderTopFrameOrigin(prevalentResourceUrl, topFrameUrl4);

        testRunner.setStatisticsSubresourceUniqueRedirectTo(prevalentResourceUrl, topFrameUrl1);
        testRunner.setStatisticsSubresourceUniqueRedirectTo(prevalentResourceUrl, topFrameUrl2);
        testRunner.setStatisticsSubresourceUniqueRedirectTo(prevalentResourceUrl, topFrameUrl3);
        testRunner.setStatisticsSubresourceUniqueRedirectTo(prevalentResourceUrl, topFrameUrl4);

        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(prevalentResourceUrl, topFrameUrl1);
        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(prevalentResourceUrl, topFrameUrl2);
        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(prevalentResourceUrl, topFrameUrl3);
        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(prevalentResourceUrl, topFrameUrl4);
    }

    function setUpInsufficientStatisticsAndContinue() {
        makeUrlPrevalent(prevalentResourceUrl1);
        makeUrlPrevalent(prevalentResourceUrl2);

        testRunner.installStatisticsDidScanDataRecordsCallback(checkInsufficientClassificationAndContinue);
        testRunner.installStatisticsDidRunTelemetryCallback(checkInsufficientTelemetry);
        testRunner.statisticsProcessStatisticsAndDataRecords();
    }

    function setUpSufficientStatisticsAndContinue() {
        makeUrlPrevalent(prevalentResourceUrl3);
        makeUrlPrevalent(prevalentResourceUrl4);

        testRunner.setStatisticsHasHadUserInteraction(prevalentResourceUrl4, true, function() {
            testRunner.installStatisticsDidScanDataRecordsCallback(checkSufficientClassificationAndContinue);
            testRunner.installStatisticsDidRunTelemetryCallback(checkSufficientTelemetry);
            testRunner.statisticsProcessStatisticsAndDataRecords();
        });
    }

    function runTelemetryAndContinue() {
        testRunner.statisticsSubmitTelemetry();
    }

    var testResult;
    function checkInsufficientTelemetry(result) {
        testResult = result;
        shouldBe("testResult.totalPrevalentResources", "0");
        shouldBe("testResult.totalPrevalentResourcesWithUserInteraction", "0");
        shouldBe("testResult.top3SubframeUnderTopFrameOrigins", "0");
        setUpSufficientStatisticsAndContinue();
    }

    function checkSufficientTelemetry(result) {
        testResult = result;
        shouldBe("testResult.totalPrevalentResources", "4");
        shouldBe("testResult.totalPrevalentResourcesWithUserInteraction", "1");
        shouldBe("testResult.top3SubframeUnderTopFrameOrigins", "4");
        setEnableFeature(false, finishJSTest);
    }

    if (window.testRunner) {
        setEnableFeature(true, function() {
            testRunner.setStatisticsNotifyPagesWhenTelemetryWasCaptured(true);
            setUpInsufficientStatisticsAndContinue();
        });
    }
</script>
</body>
</html>
