moebius#158: The Performance Resource Timing (added support for "workerStart")

https://github.com/MoonchildProductions/moebius/pull/158
This commit is contained in:
janekptacijarabaci 2018-04-29 11:49:50 +02:00 committed by Roy Tam
commit 6885700c5b
26 changed files with 746 additions and 70 deletions

View file

@ -13,6 +13,10 @@ function verify(performance, resource, description) {
assert_greater_than(entry.workerStart, 0, description);
assert_greater_than_equal(entry.workerStart, entry.startTime, description);
assert_less_than_equal(entry.workerStart, entry.fetchStart, description);
assert_greater_than_equal(entry.responseStart, entry.fetchStart, description);
assert_greater_than_equal(entry.responseEnd, entry.responseStart, description);
assert_greater_than(entry.responseEnd, entry.fetchStart, description);
assert_greater_than(entry.duration, 0, description);
if (resource.indexOf('redirect.py') != -1) {
assert_less_than_equal(entry.workerStart, entry.redirectStart,
description);

View file

@ -1,5 +1,9 @@
self.addEventListener('fetch', function(event) {
if (event.request.url.indexOf('dummy.js') != -1) {
event.respondWith(new Response());
event.respondWith(new Promise(resolve => {
// Slightly delay the response so we ensure we get a non-zero
// duration.
setTimeout(_ => resolve(new Response()), 100);
}));
}
});