<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test counting of third-party script imports in workers</title>
    <script src="/js-test-resources/js-test.js"></script>
    <script src="resources/util.js"></script>
</head>
<body onload="runTest()">
<script>
    function finishTest() {
        testRunner.dumpResourceLoadStatistics();
        setEnableFeature(false, function() {
            testRunner.notifyDone();
        });
    }

    function receiveMessage(event) {
        if (event.data.indexOf("PASS") === -1)
            testFailed(event.data.replace("FAIL ", ""));

        testRunner.statisticsNotifyObserver();
    }

    function runTest() {
        switch (document.location.hash) {
            case "":
                if (window.testRunner && window.internals) {
                    testRunner.waitUntilDone();
                    setEnableFeature(true, function() {
                        testRunner.installStatisticsDidScanDataRecordsCallback(finishTest);
                        document.location.hash = "LoadWorker";
                        runTest();
                    });
                }
                break;
            case "#LoadWorker":
                let w1 = new Worker("resources/worker-importing-localhost-script.js");
                w1.onmessage = receiveMessage;
                w1.postMessage("shouldNotReceiveCookies");
                break;
        }
    }
</script>
</body>
</html>
