<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
    var loaded = 0;
    var expectedToLoad = 6;
</script>
<link rel=preload href="/WebKit/preload/resources/square.png?img_good_type" as=image type="image/jpeg" onload="++loaded;">
<link rel=preload href="/WebKit/preload/resources/square.png?img_svg_type" as=image type="image/jpeg" onload="++loaded;">
<link rel=preload href="/WebKit/preload/resources/square.png?img_bad_type" as=image type="image/bla">
<link rel=preload href="/WebKit/preload/resources/square.png?script_good_type" as=script type="text/javascript" onload="++loaded;">
<link rel=preload href="/WebKit/preload/resources/square.png?script_bad_type" as=script type="text/fooscript">
<link rel=preload href="/WebKit/preload/resources/square.png?style_good_type" as=style type="text/css" onload="++loaded;">
<link rel=preload href="/WebKit/preload/resources/square.png?style_bad_type" as=style type="text/stylefoo">
<link rel=preload href="/WebKit/preload/resources/square.png?font_good_type" as=font type="font/woff2" onload="++loaded;">
<link rel=preload href="/WebKit/preload/resources/square.png?font_bad_type" as=font type="font/woffff">
<link rel=preload href="/WebKit/preload/resources/square.png?track_good_type" as=track type="text/vtt" onload="++loaded;">
<link rel=preload href="/WebKit/preload/resources/square.png?track_bad_type" as=track type="text/bar">
<script src="/WebKit/preload/resources/dummy.js?pipe=trickle(d0.5)"></script>
<script>
    var t = async_test('Makes sure that preloaded resources are not downloaded when the type is not supported.');
    window.setInterval(t.step_func(function() {
        function verifyDownloadNumber(url, number) {
            var absolute_url = new URL(url, window.location.href);
            assert_equals(performance.getEntriesByName(absolute_url).length, number, url);
        }
        if (loaded == expectedToLoad) {
            verifyDownloadNumber("/WebKit/preload/resources/square.png?img_good_type", 1);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?img_svg_type", 1);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?img_bad_type", 0);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?script_good_type", 1);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?script_bad_type", 0);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?style_good_type", 1);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?style_bad_type", 0);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?font_good_type", 1);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?font_bad_type", 0);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?track_good_type", 1);
            verifyDownloadNumber("/WebKit/preload/resources/square.png?track_bad_type", 0);
            document.write('<img src="/WebKit/preload/resources/square.png?img_good_type">');
            document.write('<img src="/WebKit/preload/resources/square.png?img_svg_type">');
            document.write('<script src="/WebKit/preload/resources/square.png?script_good_type">');
            document.write('<link href="/WebKit/preload/resources/square.png?script_good_type" rel=stylesheet>');
            document.write('<style>@font-face { font-family:ahem; src: url(/WebKit/preload/resources/square.png?font_good_type); } span { font-family: ahem, Arial; } </style>');
            document.write('<video><track kind=subtitles src="/WebKit/preload/resources/square.png?track_good_type" srclang=en></video>');
            t.done();
        }
    }), 200);
</script>
<span>foo</span>
