[WPT] Update resource-timing WPT tests to use the right cross origin
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / resource-timing / resource_timing_cross_origin_redirect_chain.html
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <title>This test validates resource timing information for a cross-origin redirect chain.</title>
6 <link rel="author" title="Intel" href="http://www.intel.com/" />
7 <link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
8 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script>
10 <script src=/common/get-host-info.sub.js></script>
11 <script src="resources/webperftestharness.js"></script>
12 <script src="resources/webperftestharnessextension.js"></script>
13
14 <script>
15     setup({explicit_done: true});
16     test_namespace('getEntriesByName');
17
18     function onload_test()
19     {
20         const context = new PerformanceContext(performance);
21         const entries = context.getEntriesByName(document.getElementById('frameContext').src, 'resource');
22         test_equals(entries.length, 1, 'There should be one entry.');
23         const entry = entries[0];
24
25         test_equals(entry.redirectStart, 0, 'redirectStart == 0 in cross-origin redirect.');
26         test_equals(entry.redirectEnd, 0, 'redirectEnd == 0 in cross-origin redirect.');
27         test_greater_than(entry.fetchStart, 0, 'fetchStart > 0 in cross-origin redirect.');
28         test_equals(entry.startTime, entry.fetchStart, 'startTime == fetchStart in cross-origin redirect.');
29         done();
30     }
31 </script>
32
33 </head>
34 <body>
35 <iframe id="frameContext" src="" style="width: 250px; height: 250px;"></iframe>
36 <script>
37     let destUrl = get_host_info().HTTP_REMOTE_ORIGIN + '/resource-timing/resources/multi_redirect.py?';
38     destUrl += 'page_origin=' + 'http://' + document.location.host;
39     destUrl += '&cross_origin=' + get_host_info().HTTP_REMOTE_ORIGIN;
40     const frameContext = document.getElementById('frameContext');
41     frameContext.onload = onload_test;
42     frameContext.src = destUrl;
43 </script>
44 </body>
45 </html>