Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fire the navigate event earlier for cross-document traversals
This earlier timing ensures that we fire the navigate event in the old document when a traversal is served from the bfcache, and is more consistent with non-history cross-document navigate events. Currently, cross-document traversals fire the navigate event at the last possible time: during commit in the renderer, the navigate event is fired in the old document immediately before it is unloaded. The navigate event is not allowed to cancel or intercept a cross-document traversal, otherwise this timing would be too late. We did not reach a firm conclusion on when to fire the navigate event for cross-document traversals during the design of the Navigation API (see WICG/navigation-api#207), and this was the latest of the options considered. This timing has two problems: 1. Traversals served by the back forward cache don't "commit". So the navigate event is erroneously omitted. 2. The navigate event fires after redirects, where for other cross-document navigations, it fires before redirects. This CL adds plumbing for the browser to trigger the navigate event to fire in the renderer in the cross-document traversal case, and moves the time of the navigate event earlier. It now fires after the browser process has decided to allow the traversal to start (i.e., after beforeunload has been fired in any relevant frames, and after start throttles). In the cross-document traversal case where the navigation is not served from bfcache, this will fire the navigate event in parallel with the network request (which is ok because the navigate event can't intercept or cancel the navigation, this timing would not be permissible for other navigation types where the navigate event has more power over the navigation). In the case where no network request is needed (bfcache, about:blank, etc.), the navigate event task gets sent to the renderer immediately before the commit/activation task. Bug: 1475907 Change-Id: I1ef7337e2d85f9cdbfc0110f9f4fe3bcd4dea75d
- Loading branch information