-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
navigate event timing on history traversals #207
Comments
Basically this is a question of what "navigation", and in particular the
In current browsers the architecture is that a traversal kicks off navigations, and in some sense it only does so after the responses have been received. (I.e., it only reaches into the target frame to trigger its "you're going to be navigated" code after the appropriate response has been received.) |
I'm disliking (3). For (1) vs. (2), i.e., will we fire
From this perspective, (1) is incurring a lot of complexity in order to give cross-document-traversing subframes non-actionable information sooner, plus give the top-level frame actionable information sooner. (2) is avoiding that complexity at the cost of potentially wasting some network fetching for the top-level frame, if it ends up wanting to cancel This opens the possibility of:
This is probably a good bit easier to implement than (1), and gives most of the benefit. The cost is an inconsistency between top-level frames and subframes. Although maybe it's OK, since that inconsistency stems from the fact that top-level frames are the only ones that we give control over the traversal... |
Is it the top-level document or the navigating document that is the deciding factor? Consider A -> B -> C and B navigates cross-document. Under 4, wouldn't we want |
It depends on why we want
|
But if B itself initiated the traversal? Even then it cannot cancel it? (Admittedly I lost track of the traversal / non-traversal distinction of this issue for a bit, but I think the question still makes sense.) |
It basically comes down to how much complexity we are willing to bite off. Is the goal to make everything that can be non-abusively canceled, cancelable? In that case we can indeed get pretty far. E.g. I think you can end up with: any programmatic traversal initiated by a same-origin-domain page, that only traverses same-origin-domain frames higher in the tree or any iframes lower in the tree, and is allowed by all the relevant sandboxing flags, can be canceled without a potential for back-trapping or security problems. But is that really worthwhile? Will it make sense to developers? I've been tentatively arguing for a very simple model, where the only cancelable traversals are top-level ones. I think that meets most of the use cases in #32. (The use cases it doesn't meet that well are for pages where the entire web app is hosted in a full-page iframe. Those would need to have their containing page do the actual navigation API stuff. I think that's OK... if you create such an application architecture, you're probably used to some compromises.) |
It might be worth checking with YouTube at least? |
We discussed this offline and didn't come to any firm conclusions; everyone was pretty flexible. It felt like the leading candidates were (1) and (4). Since nobody was arguing for (3), I'd like to eliminate it from the running, and thus remove this from the "might block v1" issues list since the compat problems are minimized. (Because the event will always be async, even if we're still discussing the exact timing, i.e. discussing (1) vs. (2) vs. (4).) |
This fires navigate events for subframes during a traversal earlier, before the unload event and in parallel with any fetches that occur. This is more consistent with non-traverse navigate events, and with top-level traverse navigate events. WICG/navigation-api#207 has some previous relevant discussion. This represents moving from that issue's "late" navigate events to "early-but-still-async". It turns out the complexity was not too bad, when we got around to it in Chromium, and was actually helpful in order to fix a bug where traverse navigate events weren't firing when pages were bfcached.
This earlier timing ensures that we fire the navigate event in the old document when a traversal is served from the bfcache. 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
This fires navigate events for subframes during a traversal earlier, before the unload event and in parallel with any fetches that occur. This is more consistent with non-traverse navigate events, and with top-level traverse navigate events. WICG/navigation-api#207 has some previous relevant discussion. This represents moving from that issue's "late" navigate events to "early-but-still-async". It turns out the complexity was not too bad, when we got around to it in Chromium, and was actually helpful in order to fix a bug where traverse navigate events weren't firing when pages were bfcached.
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
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
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
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
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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5011394 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Nate Chapin <[email protected]> Reviewed-by: Charlie Reis <[email protected]> Reviewed-by: Will Harris <[email protected]> Cr-Commit-Position: refs/heads/main@{#1229455}
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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5011394 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Nate Chapin <[email protected]> Reviewed-by: Charlie Reis <[email protected]> Reviewed-by: Will Harris <[email protected]> Cr-Commit-Position: refs/heads/main@{#1229455}
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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5011394 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Nate Chapin <[email protected]> Reviewed-by: Charlie Reis <[email protected]> Reviewed-by: Will Harris <[email protected]> Cr-Commit-Position: refs/heads/main@{#1229455}
…s-document traversals, a=testonly Automatic update from web-platform-tests 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5011394 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Nate Chapin <[email protected]> Reviewed-by: Charlie Reis <[email protected]> Reviewed-by: Will Harris <[email protected]> Cr-Commit-Position: refs/heads/main@{#1229455} -- wpt-commits: b92c3a8c78b102518261a78e17a27b5e6f2efb8a wpt-pr: 43008
…s-document traversals, a=testonly Automatic update from web-platform-tests 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5011394 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Nate Chapin <[email protected]> Reviewed-by: Charlie Reis <[email protected]> Reviewed-by: Will Harris <[email protected]> Cr-Commit-Position: refs/heads/main@{#1229455} -- wpt-commits: b92c3a8c78b102518261a78e17a27b5e6f2efb8a wpt-pr: 43008
…s-document traversals, a=testonly Automatic update from web-platform-tests 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5011394 Reviewed-by: Domenic Denicola <domenicchromium.org> Commit-Queue: Nate Chapin <japhetchromium.org> Reviewed-by: Charlie Reis <creischromium.org> Reviewed-by: Will Harris <wfhchromium.org> Cr-Commit-Position: refs/heads/main{#1229455} -- wpt-commits: b92c3a8c78b102518261a78e17a27b5e6f2efb8a wpt-pr: 43008 UltraBlame original commit: 86b3ba75ab49e48c031d5abaebdf2aa406ca5cc8
…s-document traversals, a=testonly Automatic update from web-platform-tests 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5011394 Reviewed-by: Domenic Denicola <domenicchromium.org> Commit-Queue: Nate Chapin <japhetchromium.org> Reviewed-by: Charlie Reis <creischromium.org> Reviewed-by: Will Harris <wfhchromium.org> Cr-Commit-Position: refs/heads/main{#1229455} -- wpt-commits: b92c3a8c78b102518261a78e17a27b5e6f2efb8a wpt-pr: 43008 UltraBlame original commit: 86b3ba75ab49e48c031d5abaebdf2aa406ca5cc8
…s-document traversals, a=testonly Automatic update from web-platform-tests 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5011394 Reviewed-by: Domenic Denicola <domenicchromium.org> Commit-Queue: Nate Chapin <japhetchromium.org> Reviewed-by: Charlie Reis <creischromium.org> Reviewed-by: Will Harris <wfhchromium.org> Cr-Commit-Position: refs/heads/main{#1229455} -- wpt-commits: b92c3a8c78b102518261a78e17a27b5e6f2efb8a wpt-pr: 43008 UltraBlame original commit: 86b3ba75ab49e48c031d5abaebdf2aa406ca5cc8
When working on tests for #137, we noticed something about the Chromium implementation, and I believe about the current spec, which is a bit strange. Which is that, for traversals, we fire
navigate
events only after getting a response back from the server, i.e. just aroundunload
event time.This is in contrast to non-traverse navigations, where we fire
navigate
immediately and synchronously.Recall that non-traverse navigations and traversals are fundamentally different because traversals can affect many different frames. In particular, one frame can cause multiple other frames (including cross-origin/cross-process ones) to traverse. So traversals are in a crucial sense always async: they go from the initiating frame, up to the main browser process, which potentially does a bunch of network fetches, and only then to they descend into the traversed frames, firing
unload
and replacing the documents with the new ones. Whereas non-traverse navigations just go to the single destination frame, and navigate it.In addition to the consistency question between non-traverse and traverse navigations, this is related to #32 and #178. In particular, if we eventually want to make some traversals cancelable, it might make more sense for the event to fire earlier rather than later?
Keeping that desired end state in mind, we basically have three options here:
Stick with the status quo for now, of
navigate
firing late for traversals. In the future, when we want to make it cancelable, move it to fire early, but still async.navigate
events, waits to see if anyone canceled them, then proceeds with the network stuff, before eventually fanning back out to the traversed frames with the results. This is annoying to implement but not impossible, and seems like whatbeforeunload
might be doing already. (Although nobody really thinksbeforeunload
is a great precedent to build on...)navigate
would always fire "soon" for both traverse and non-traverse navigations. Even though the former would be async and the latter would be sync, at least neither would be network-dependent, whereas right now traversalnavigate
timing is network-dependent.Stick with
navigate
firing late for traversals forever, including in the future when we make traversals cancelable.unload
in order to firenavigate
.navigate
timing is also network-dependent.Try to hack
navigate
to fire sync for some traversals.history.back()
ornavigation.traverseTo()
.navigate
), or not.navigate
before hitting the server when using the browser back button. So, the browser back button would not be included in this option; only (1) would remove the server-dependent component from that case.I think the main near-term question is whether (3) is valuable.
/cc @annevk @smaug---- @japhet as I'm adding this to the "Might block v1" milestone, to decide on whether (3) is worthwhile.
The text was updated successfully, but these errors were encountered: