summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/preload/download-resources.html
blob: 4da76980357037951b857cb357e024cff7ff44bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<title>Makes sure that preloaded resources are downloaded</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/preload/resources/preload_helper.js"></script>
<link rel=preload href="resources/dummy.js" as=script>
<link rel=preload href="resources/dummy.css" as=style>
<link rel=preload href="resources/square.png" as=image>
<link rel=preload href="/fonts/CanvasTest.ttf" as=font crossorigin>
<link rel=preload href="resources/white.mp4" as=video>
<link rel=preload href="resources/sound_5.oga" as=audio>
<link rel=preload href="resources/foo.vtt" as=track>
<link rel=preload href="resources/dummy.xml?foo=bar" as=foobarxmlthing>
<link rel=preload href="resources/dummy.xml?novalue">
<link rel=preload href="resources/dummy.xml" as="fetch">
<body>
<script>
    setup({single_test: true});

    var iterations = 0;

    function check_finished() {
        if (numberOfResourceTimingEntries("resources/dummy.js") == 1 &&
            numberOfResourceTimingEntries("resources/dummy.css") == 1 &&
            numberOfResourceTimingEntries("/fonts/CanvasTest.ttf") == 1 &&
            numberOfResourceTimingEntries("resources/white.mp4") == 1 &&
            numberOfResourceTimingEntries("resources/sound_5.oga") == 1 &&
            numberOfResourceTimingEntries("resources/foo.vtt") == 1 &&
            numberOfResourceTimingEntries("resources/dummy.xml?foo=bar") == 0 &&
            numberOfResourceTimingEntries("resources/dummy.xml?novalue") == 0 &&
            numberOfResourceTimingEntries("resources/dummy.xml") == 1) {
            done();
        }
        iterations++;
        if (iterations == 10) {
            // At least one is expected to fail, but this should give details to the exact failure(s).
            verifyNumberOfResourceTimingEntries("resources/dummy.js", 1);
            verifyNumberOfResourceTimingEntries("resources/dummy.css", 1);
            verifyNumberOfResourceTimingEntries("/fonts/CanvasTest.ttf", 1);
            verifyNumberOfResourceTimingEntries("resources/white.mp4", 1);
            verifyNumberOfResourceTimingEntries("resources/sound_5.oga", 1);
            verifyNumberOfResourceTimingEntries("resources/foo.vtt", 1);
            verifyNumberOfResourceTimingEntries("resources/dummy.xml?foo=bar", 0);
            verifyNumberOfResourceTimingEntries("resources/dummy.xml?novalue", 0);
            verifyNumberOfResourceTimingEntries("resources/dummy.xml", 1);
            done();
        } else {
            step_timeout(check_finished, 500);
        }
    }

    window.addEventListener("load", function() {
        verifyPreloadAndRTSupport();
        step_timeout(check_finished, 500);
    });
</script>
</body>