OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <title>Navigation Preload Resource Timing</title> |
| 4 <script src="/resources/testharness.js"></script> |
| 5 <script src="/resources/testharnessreport.js"></script> |
| 6 <script src="../resources/test-helpers.sub.js"></script> |
| 7 <script> |
| 8 |
| 9 function check_timing_entry(entry) { |
| 10 var name = entry.name; |
| 11 assert_greater_than(entry.startTime, 0, 'startTime of ' + name); |
| 12 assert_greater_than_equal(entry.fetchStart, entry.startTime, |
| 13 'fetchStart >= startTime of ' + name); |
| 14 assert_greater_than_equal(entry.domainLookupStart, entry.fetchStart, |
| 15 'domainLookupStart >= fetchStart of ' + name); |
| 16 assert_greater_than_equal(entry.domainLookupEnd, entry.domainLookupStart, |
| 17 'domainLookupEnd >= domainLookupStart of ' + name); |
| 18 assert_greater_than_equal(entry.connectStart, entry.domainLookupEnd, |
| 19 'connectStart >= domainLookupEnd of ' + name); |
| 20 assert_greater_than_equal(entry.connectEnd, entry.connectStart, |
| 21 'connectEnd >= connectStart of ' + name); |
| 22 assert_greater_than_equal(entry.requestStart, entry.connectEnd, |
| 23 'requestStart >= connectEnd of ' + name); |
| 24 assert_greater_than_equal(entry.responseStart, entry.requestStart, |
| 25 'domainLookupStart >= requestStart of ' + name); |
| 26 assert_greater_than_equal(entry.responseEnd, entry.responseStart, |
| 27 'responseEnd >= responseStart of ' + name); |
| 28 assert_greater_than(entry.duration, 0, 'duration of ' + name); |
| 29 } |
| 30 |
| 31 promise_test(t => { |
| 32 var script = 'resources/resource-timing-worker.js'; |
| 33 var scope = 'resources/resource-timing-scope.py'; |
| 34 var registration; |
| 35 return service_worker_unregister_and_register(t, script, scope) |
| 36 .then(reg => { |
| 37 registration = reg; |
| 38 add_completion_callback(_ => registration.unregister()); |
| 39 return wait_for_state(t, registration.installing, 'activated'); |
| 40 }) |
| 41 .then(_ => with_iframe(scope)) |
| 42 .then(frame => { |
| 43 var result = JSON.parse(frame.contentDocument.body.textContent); |
| 44 assert_equals( |
| 45 result.timingEntries.length, 1, |
| 46 'performance.getEntriesByName() must returns one ' + |
| 47 'PerformanceResourceTiming entry for the navigation preload.'); |
| 48 var entry = result.timingEntries[0]; |
| 49 assert_equals( |
| 50 entry.entryType, 'resource', |
| 51 'The entryType of preload response timing entry must be "resource' + |
| 52 '".'); |
| 53 assert_equals( |
| 54 entry.initiatorType, 'other', |
| 55 'The initiatorType of preload response timing entry must be ' + |
| 56 '"other".'); |
| 57 assert_equals( |
| 58 entry.decodedBodySize, Number(result.decodedBodySize), |
| 59 'decodedBodySize must same as the decoded size in the server.'); |
| 60 assert_equals( |
| 61 entry.encodedBodySize, Number(result.encodedBodySize), |
| 62 'encodedBodySize must same as the encoded size in the server.'); |
| 63 assert_greater_than( |
| 64 entry.transferSize, entry.decodedBodySize, |
| 65 'transferSize must greater then encodedBodySize.'); |
| 66 check_timing_entry(entry); |
| 67 frame.remove(); |
| 68 return registration.unregister(); |
| 69 }); |
| 70 }, 'Navigation Preload Resource Timing.'); |
| 71 |
| 72 </script> |
OLD | NEW |