Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(934)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/chromium/navigation-preload-resource-timing.html

Issue 2837943006: [WIP] Support PerformanceResourceTiming for Service Worker Navigation Preload (Closed)
Patch Set: clean up Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <title>Navigation Preload Resource Timing after terminating SW</title>
4 <script src="../../../resources/testharness.js"></script>
5 <script src="../../../resources/testharnessreport.js"></script>
6 <script src="../../resources/test-helpers.js"></script>
7 <script>
8 function check_timing_entry(entry, allow_negative_value) {
9 var name = entry.name;
10 if (!allow_negative_value) {
11 assert_greater_than(entry.startTime, 0, 'startTime of ' + name);
12 assert_greater_than(entry.fetchStart, 0, 'fetchStart of ' + name);
13 assert_greater_than(entry.domainLookupStart, 0,
14 'domainLookupStart of ' + name);
15 assert_greater_than(entry.domainLookupEnd, 0,
16 'domainLookupEnd of ' + name);
17 assert_greater_than(entry.connectStart, 0, 'connectStart of ' + name);
18 assert_greater_than(entry.connectEnd, 0, 'connectEnd of ' + name);
19 assert_greater_than(entry.requestStart, 0, 'requestStart of ' + name);
20 assert_greater_than(entry.responseStart, 0, 'responseStart of ' + name);
21 assert_greater_than(entry.responseEnd, 0, 'responseEnd of ' + name);
22 }
23 assert_greater_than_equal(entry.fetchStart, entry.startTime,
24 'fetchStart >= startTime of ' + name);
25 assert_greater_than_equal(entry.domainLookupStart, entry.fetchStart,
26 'domainLookupStart >= fetchStart of ' + name);
27 assert_greater_than_equal(entry.domainLookupEnd, entry.domainLookupStart,
28 'domainLookupEnd >= domainLookupStart of ' + name);
29 assert_greater_than_equal(entry.connectStart, entry.domainLookupEnd,
30 'connectStart >= domainLookupEnd of ' + name);
31 assert_greater_than_equal(entry.connectEnd, entry.connectStart,
32 'connectEnd >= connectStart of ' + name);
33 assert_greater_than_equal(entry.requestStart, entry.connectEnd,
34 'requestStart >= connectEnd of ' + name);
35 assert_greater_than_equal(entry.responseStart, entry.requestStart,
36 'domainLookupStart >= requestStart of ' + name);
37 assert_greater_than_equal(entry.responseEnd, entry.responseStart,
38 'responseEnd >= responseStart of ' + name);
39 assert_greater_than(entry.duration, 0, 'duration of ' + name);
40 }
41
42 promise_test(t => {
43 var script = 'resources/navigation-preload-resource-timing-worker.js';
44 var scope = 'resources/navigation-preload-resource-timing-scope.html';
45 var registration;
46 var frames = [];
47
48 return service_worker_unregister_and_register(t, script, scope)
49 .then(reg => {
50 registration = reg;
51 add_completion_callback(_ => registration.unregister());
52 return wait_for_state(t, registration.installing, 'activated');
53 })
54 .then(_ => with_iframe(scope + '?1'))
55 .then(frame => {
56 frames.push(frame);
57 return with_iframe(scope + '?2');
58 })
59 .then(frame => {
60 frames.push(frame);
61 return internals.terminateServiceWorker(registration.active);
62 })
63 .then(_ => with_iframe(scope + '?3'))
64 .then(frame => {
65 frames.push(frame);
66 var results = frames.map(frame => {
67 var result = JSON.parse(frame.contentDocument.body.textContent);
68 return result.timingEntries.filter(entry => {
69 return entry.name.indexOf(scope) != -1;
70 })
71 });
72 assert_equals(results.length, 3);
73 assert_equals(results[0].length, 1,
74 'The first result must contain only one entry.');
75 assert_equals(results[0][0].name, frames[0].src,
76 'The entry of the first result must be the entry for ' +
77 'the first iframe.');
78 assert_equals(results[1].length, 2,
79 'The second result must contain two entry.');
80 assert_object_equals(results[1][0], results[0][0],
81 'The first entry of the second result must be ' +
82 'same as the entry of the first result.');
83 assert_equals(results[1][1].name, frames[1].src,
84 'The second entry of the second result must be the ' +
85 'entry for the second iframe.');
86 assert_equals(results[2].length, 1,
87 'The third result must contain only one entry.');
88 assert_equals(results[2][0].name, frames[2].src,
89 'The entry of the third result must be the entry for ' +
90 'the third iframe.');
91 check_timing_entry(results[1][0], false /* allow_negative_value */);
92 check_timing_entry(results[1][1], false /* allow_negative_value */);
93 check_timing_entry(results[2][0], true /* allow_negative_value */);
94 frames.forEach(frame => frame.remove());
95 return registration.unregister();
96 });
97 }, 'Navigation Preload Resource Timing after terminating SW.');
98
99 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698