Commit 137522b4 authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

serviece worker: Fix PerformanceNavigationTiming#fetchStart

This is a follow-up CL of crrev.com/c/1212423 and fixes timing ordering of
PerformanceNavigationTiming attributes.

Background:
`fetchStart` of PerformanceNavigationTiming comes from |fetch_start| of
NavigationTiming, which is set by NavigationRequest. Since
NavigationRequest isn't aware of service worker interception
`fetchStart` could come earlier than `workerStart` when the navigation is
routed to a service worker. However, `fetchStart` is supposed to come
after `workerStart`.

We can address this mis-ordering by using worker ready time. When
worker ready time is greater than |fetch_start| of NavigationTiming,
use worker ready time as |fetch_start|. Justifications:
- `fetchStart` is should be recorded after redirects end.
- `fetchStart` is should be recorded after `workerStart` if a service worker
  intercepted the navigation.
- There seems no particular ordering between `redirectEnd` and `workerStart`.
- NavigationRequest already updates |fetch_start| for redirects.

Bug: 782958
Change-Id: I90bdeaee73d361c9d35024f13fd0d3f91ba42b02
Reviewed-on: https://chromium-review.googlesource.com/1215426Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589851}
parent 389d563b
...@@ -960,6 +960,16 @@ void NavigationRequest::OnResponseStarted( ...@@ -960,6 +960,16 @@ void NavigationRequest::OnResponseStarted(
? navigation_handle_->appcache_handle()->appcache_host_id() ? navigation_handle_->appcache_handle()->appcache_host_id()
: kAppCacheNoHostId; : kAppCacheNoHostId;
// Update fetch start timing. While NavigationRequest updates fetch start
// timing for redirects, it's not aware of service worker interception so
// fetch start timing could happen earlier than worker start timing. Use
// worker ready time if it is greater than the current value to make sure
// fetch start timing always comes after worker start timing (if a service
// worker intercepted the navigation).
request_params_.navigation_timing.fetch_start =
std::max(request_params_.navigation_timing.fetch_start,
response->head.service_worker_ready_time);
// A navigation is user activated if it contains a user gesture or the frame // A navigation is user activated if it contains a user gesture or the frame
// received a gesture and the navigation is renderer initiated. If the // received a gesture and the navigation is renderer initiated. If the
// navigation is browser initiated, it has to come from the context menu. // navigation is browser initiated, it has to come from the context menu.
......
This is a testharness.js-based test.
FAIL Service worker controlled navigation timing assert_unreached: unexpected rejection: assert_true: Expected workerStart <= fetchStart expected true got false Reached unreachable code
FAIL Service worker controlled navigation timing network fallback assert_unreached: unexpected rejection: assert_true: Expected workerStart <= fetchStart expected true got false Reached unreachable code
PASS Service worker controlled navigation timing redirect
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL Service worker controlled navigation timing assert_unreached: unexpected rejection: assert_true: Expected workerStart <= fetchStart expected true got false Reached unreachable code
PASS Service worker controlled navigation timing network fallback
PASS Service worker controlled navigation timing redirect
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL Service worker controlled navigation timing assert_unreached: unexpected rejection: assert_true: Expected workerStart <= fetchStart expected true got false Reached unreachable code
PASS Service worker controlled navigation timing network fallback
PASS Service worker controlled navigation timing redirect
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL Service worker controlled navigation timing assert_unreached: unexpected rejection: assert_true: Expected workerStart <= fetchStart expected true got false Reached unreachable code
PASS Service worker controlled navigation timing network fallback
PASS Service worker controlled navigation timing redirect
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment