summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/loading/early-hints/resources/preconnect-in-early-hints.html
blob: 8ec8fde5e67683a41b3e998e872e4f22251ec646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="early-hints-helpers.sub.js"></script>
<body>
<script>
promise_test(async (t) => {
    const params = new URLSearchParams(window.location.search);
    const resource_url = params.get("resource-url");
    await fetchScript(resource_url);

    // Check the resource's connect timing.
    const entries = performance.getEntriesByName(resource_url);
    assert_equals(entries.length, 1);
    const connect_start = entries[0].connectStart;
    const connect_end = entries[0].connectEnd;
    assert_equals(connect_start, connect_end,
        "Connection establishment should not take time for a resource from a preconnected origin.");
}, "Preconnect in early hints.");
</script>
</body>