<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Security-Policy" content="prefetch-src 'self'">
    <script>
        if (window.testRunner) {
            testRunner.waitUntilDone();
            testRunner.dumpAsText();
        }
        function runTest() {
            var link = document.createElement("link");
            link.rel = "prefetch";
            link.href = "http://localhost:8000/cache/resources/prefetched-main-resource.py";
            window.addEventListener("securitypolicyviolation", () => {
                document.getElementById("log").innerText = "PASS";
                testRunner.notifyDone();
            });
            if (internals) {
                internals.addPrefetchLoadEventListener(link, () => {
                    document.getElementById("log").innerText = "FAIL: prefetch was not blocked by CSP.";
                    testRunner.notifyDone();
                });
            }

            document.body.appendChild(link);
        }
    </script>
</head>
<body onload="runTest()">
<div id="log"></div>
</body>
</html>
