summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resource-timing/object-not-found-after-TAO-cross-origin-redirect.html
blob: d0dad9381ba42bc848ebeca86acaf7f10a7a1e82 (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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>This test validates resource timing information for a timing allowed cross-origin redirect chain.</title>
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src=/common/get-host-info.sub.js></script>
<script src="resources/webperftestharness.js"></script>
<script src="resources/webperftestharnessextension.js"></script>

<script>
    setup({explicit_done: true});
    test_namespace('getEntriesByName');

    function onload_test()
    {
        const context = new PerformanceContext(performance);
        const entries = context.getEntriesByName(document.querySelector('object').data, 'resource');
        test_equals(entries.length, 1, 'There should be one entry.');
        const entry = entries[0];

        test_greater_than(entry.redirectStart, 0, 'redirectStart > 0 in timing allowed cross-origin redirect.');
        test_equals(entry.redirectStart, entry.startTime, 'redirectStart == startTime in timing allowed cross-origin redirect.');
        test_greater_than(entry.redirectEnd, entry.redirectStart, 'redirectEnd > redirectStart in timing allowed cross-origin redirect.');
        test_greater_or_equals(entry.fetchStart, entry.redirectEnd, 'fetchStart >= redirectEnd in timing allowed cross-origin redirect.');
        done();
    }
</script>

</head>
<body>
<script>
    let destUrl = get_host_info().HTTP_REMOTE_ORIGIN + '/resource-timing/resources/multi_redirect.py?';
    destUrl += 'page_origin=' + 'http://' + document.location.host;
    destUrl += '&cross_origin=' + get_host_info().HTTP_REMOTE_ORIGIN;
    destUrl += '&final_resource=' + encodeURIComponent("/resource-timing/resources/status-code.py?status=404&tao_value=*");
    destUrl += '&tao_steps=3';
    const objElement = document.createElement('object');
    objElement.style = 'width: 0px; height: 0px;';
    objElement.data = destUrl;
    objElement.onerror = onload_test;
    document.body.appendChild(objElement);
</script>
</body>
</html>