<!-- webkit-test-runner [ useEphemeralSession=true ] -->
<!DOCTYPE html>
<html>
<head>
    <script src="/js-test-resources/js-test.js"></script>
    <script src="/js-test-resources/ui-helper.js"></script>
    <script src="/resourceLoadStatistics/resources/util.js"></script>
    <script>
        description("Tests that a cross-site iframe can not request storage access under general third-party cookie blocking if it has not received user interaction as first-party (ephemeral).");
        jsTestIsAsync = true;

        const firstPartyUrl = "http://127.0.0.1:8000";
        const thirdPartyUrl = "http://localhost:8000";

        function finishTest() {
            testRunner.setStatisticsShouldBlockThirdPartyCookies(false, function() {
                setEnableFeature(false, finishJSTest);
            });
        }

        function receiveMessage(event) {
            if (event.origin === "http://localhost:8000") {
                if (event.data.indexOf("PASS ") !== -1)
                    testPassed(event.data.replace("PASS ", ""));
                else
                    testFailed(event.data.replace("FAIL ", ""));
            } else
                testFailed("Received a message from an unexpected origin: " + event.origin);
            finishTest();
        }

        window.addEventListener("message", receiveMessage, false);

        function activateElement(elementId) {
            var element = document.getElementById(elementId);
            var centerX = element.offsetLeft + element.offsetWidth / 2;
            var centerY = element.offsetTop + element.offsetHeight / 2;
            UIHelper.activateAt(centerX, centerY).then(
                function () {
                    if (window.eventSender)
                        eventSender.keyDown("escape");
                    else {
                        testFailed("No eventSender.");
                        finishTest();
                    }
                },
                function () {
                    testFailed("Promise rejected.");
                    finishTest();
                }
            );
        }

        function runTest() {
            if (document.location.hash !== "#cookieSet") {
                setEnableFeature(true, function() {
                    testRunner.setStatisticsShouldBlockThirdPartyCookies(true, function() {
                        document.location.href = thirdPartyUrl + "/storageAccess/resources/set-cookie.php?name=firstPartyCookie&value=value#" + firstPartyUrl + "/storageAccess/deny-due-to-no-interaction-under-general-third-party-cookie-blocking-ephemeral.html#cookieSet";
                    });
                });
            } else {
                let iframeElement = document.createElement("iframe");
                iframeElement.onload = function() {
                    activateElement("TheIframeThatRequestsStorageAccess");
                };
                iframeElement.id = "TheIframeThatRequestsStorageAccess";
                iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe.html#userShouldGrantAccess,userShouldNotBeConsulted,policyShouldNotGrantAccess,isNotSameOriginIframe";
                document.body.appendChild(iframeElement);
            }
        }
    </script>
</head>
<body onload="runTest()">
</body>
</html>