<!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-origin iframe can open a window if storage access is denied without prompt.");
        jsTestIsAsync = true;

        const hostUnderTest = "localhost:8000";
        const statisticsUrl = "http://" + hostUnderTest + "/temp";

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

        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);
            setEnableFeature(false, finishJSTest);
        }

        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.");
                        setEnableFeature(false, finishJSTest);
                    }
                },
                function () {
                    testFailed("Promise rejected.");
                    setEnableFeature(false, finishJSTest);
                }
            );
        }

        function runTest() {
            setEnableFeature(true, function() {
                testRunner.setCanOpenWindows(false);
                testRunner.setPopupBlockingEnabled(true);
                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 get logged for user interaction.");
                        testRunner.statisticsUpdateCookieBlocking(function() {
                            let iframeElement = document.createElement("iframe");
                            iframeElement.onload = function() {
                                activateElement("TheIframeThatRequestsStorageAccess");
                            };
                            iframeElement.id = "TheIframeThatRequestsStorageAccess";
                            iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe-and-pop-window.html#userShouldNotGrantAccess,userShouldNotBeConsulted,policyShouldNotGrantAccess,isNotSameOriginIframe";
                            document.body.appendChild(iframeElement);
                        });
                    });
                });
            });
        }
    </script>
</head>
<body onload="runTest()">
</body>
</html>
