<!-- webkit-test-runner [ useEphemeralSession=true ] -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="/js-test-resources/js-test.js"></script>
    <script src="resources/util.js"></script>
</head>
<body onload="run()">
<script>
    description("Tests that all third-party cookies are blocked (ephemeral session).");
    jsTestIsAsync = true;

    const partitionHost = "127.0.0.1:8000";
    const partitionOrigin = "http://" + partitionHost;
    const thirdPartyOrigin = "http://localhost:8000";
    const resourcePath = "/resourceLoadStatistics/resources";
    const thirdPartyBaseUrl = thirdPartyOrigin + resourcePath;
    const firstPartyCookieName = "firstPartyCookie";
    const subPathToSetFirstPartyCookie = "/set-cookie.py?name=" + firstPartyCookieName + "&value=value";
    const returnUrl = partitionOrigin + "/resourceLoadStatistics/third-party-cookie-blocking-ephemeral.html";
    const subPathToGetCookies = "/get-cookies.py?name1=" + firstPartyCookieName;

    function openIframe(url, onLoadHandler) {
        const element = document.createElement("iframe");
        element.src = url;
        if (onLoadHandler) {
            element.onload = onLoadHandler;
        }
        document.body.appendChild(element);
    }

    function runTest() {
        switch (document.location.hash) {
            case "#step1":
                // Set first-party cookie for localhost.
                document.location.href = thirdPartyBaseUrl + subPathToSetFirstPartyCookie + "#" + returnUrl + "#step2";
                break;
            case "#step2":
                document.location.hash = "step3";
                // Check that the cookie is blocked for localhost under 127.0.0.1 even though localhost is not prevalent.
                openIframe(thirdPartyBaseUrl + subPathToGetCookies + "&message=Before user interaction, should receive no cookies.", runTest);
                break;
            case "#step3":
                document.location.hash = "step4";
                // Produce user interaction for the first-party.
                testRunner.setStatisticsHasHadUserInteraction(partitionOrigin, true, function() {
                    // Check that the cookie is still blocked for localhost under 127.0.0.1.
                    openIframe(thirdPartyBaseUrl + subPathToGetCookies +  "&message=After user interaction, should receive no cookies.", runTest);
                });
                break;
            case "#step4":
                testRunner.setStatisticsShouldBlockThirdPartyCookies(false, function() {
                    setEnableFeature(false, finishJSTest);
                });
                break;
        }
    }

    function run() {
        if (document.location.hash === "") {
            setEnableFeature(true, function () {
                testRunner.dumpChildFramesAsText();
                document.location.hash = "step1";
                testRunner.setStatisticsShouldBlockThirdPartyCookies(true, runTest);
            });
        } else {
            if (testRunner.isStatisticsEphemeral())
                testPassed("Resource load statistics is running in ephemeral mode.");
            runTest();
        }
    }
</script>
</body>
</html>
