4 <meta charset="utf-8" />
5 <title>Resource Timing attribute order</title>
6 <link rel="author" title="Google" href="http://www.google.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="resources/webperftestharness.js"></script>
11 <script src="resources/webperftestharnessextension.js"></script>
14 // explicitly test the namespace before we start testing
15 test_namespace("getEntriesByName");
18 function setup_iframe() {
19 if (window.performance.getEntriesByName === undefined) {
22 iframe = document.getElementById('frameContext');
23 var d = iframe.contentWindow.document;
24 var body = d.createElement('body');
25 d.getElementsByTagName('html')[0].appendChild(body);
27 var image = d.createElement('img');
28 image.src = 'generate_resource.cgi?types=image';
29 body.appendChild(image);
31 function onload_test() {
32 if (window.performance.getEntriesByName === undefined) {
35 var context = new PerformanceContext(iframe.contentWindow.performance);
36 var index = window.location.pathname.lastIndexOf('/');
37 var pathname = window.location.pathname.substring(0, index) + '/';
38 var origin = window.location.protocol + "//" + window.location.host;
39 var entries = context.getEntriesByName(origin + pathname + 'resources/generate_resource.cgi?types=image');
40 test_equals(entries.length, 1, 'Only 1 PerformanceEntry should match');
41 var entry = entries[0];
43 test_equals(entry.redirectStart, 0, "redirectStart should be 0");
44 test_equals(entry.redirectEnd, 0, "redirectEnd should be 0");
45 test_greater_than(entry.fetchStart, 0, "fetchStart should be non-zero");
46 test_greater_or_equals(entry.domainLookupStart, entry.fetchStart, "domainLookupStart should be greater than or equal to fetchStart");
47 test_greater_or_equals(entry.domainLookupEnd, entry.domainLookupStart, "domainLookupEnd should be greater than or equal to domainLookupStart");
48 test_greater_or_equals(entry.connectStart, entry.domainLookupEnd, "connectStart should be greater than or equal to domainLookupEnd");
49 test_greater_or_equals(entry.connectEnd, entry.connectStart, "connectEnd should be greater than or equal to connectStart");
50 test_greater_or_equals(entry.requestStart, entry.connectEnd, "requestStart should be greater than or equal to connectEnd");
51 test_greater_or_equals(entry.responseStart, entry.requestStart, "responseStart should be greater than or equal to requestStart");
52 test_greater_or_equals(entry.responseEnd, entry.responseStart, "responseEnd should be greater than or equal to responseStart");
58 <p>This test validates that the PerformanceResourceTiming attributes appear in the correct chronological order.</p>
60 <iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>