Navigation: Add optimization to ignore duplicate navigations#11765
Navigation: Add optimization to ignore duplicate navigations#11765llannasatoll wants to merge 9 commits into
Conversation
27be0e6 to
4d255eb
Compare
cac111e to
1ffc5d1
Compare
|
@rakina Could you take another look? I've added a new struct |
rakina
left a comment
There was a problem hiding this comment.
Thanks. I think it mostly looks good. There might be some wording around the cookie checks that might need to be updated later depending on the cookie check discussions.
| <li><p><var>cspNavigationType</var> is "<code data-x="">other</code>" and | ||
| <var>navigationInitiationSnapshotParams</var>'s <span | ||
| data-x="nav-initiation-snapshot-params-entry-list">entry list</span> is null;</p></li> |
There was a problem hiding this comment.
Should this both be checking the entry list? Also should this check documentResource as well?
There was a problem hiding this comment.
I've updated the PR to check both, thanks! (I was implicitly checking the entry list via cspNavigationType, but explicitly checking formDataEntryList should be much clearer).
f07484b to
7e7c910
Compare
|
|
||
| <li><p>If <var>navigationStartTime</var> minus <var>navigationInitiationSnapshotParams</var>'s | ||
| <span data-x="nav-initiation-snapshot-params-nav-start-time">navigation start time</span> is | ||
| less than a user-agent provided threshold;</p></li> |
There was a problem hiding this comment.
There's some suggestion to set this to an actual value, so maybe use the value used in Chromium (3s?): #11743 (comment)
There was a problem hiding this comment.
I've updated the threshold to a hardcoded 3 seconds. (also, please let me know if you think we should add a note explaining why 3s.)
| potentially changed</span> to true.</p> | ||
|
|
||
| <p class="note">Other operations that could set cookies, such as the <a | ||
| href="https://wicg.github.io/cookie-store/">Cookie Store API</a> or receiving a Set-Cookie |
There was a problem hiding this comment.
We probably need to create a Cookie Store API PR as well. Maybe we need to change this part: https://cookiestore.spec.whatwg.org/#set-cookie-algorithm to get the document's node navigable and update this bit.
There was a problem hiding this comment.
I see, sure! I'll create a separate PR in the cookiestore repo, and link it here once it's up.
llannasatoll
left a comment
There was a problem hiding this comment.
Thanks for the review, Rakina! Could you take another look?
|
|
||
| <li><p>If <var>navigationStartTime</var> minus <var>navigationInitiationSnapshotParams</var>'s | ||
| <span data-x="nav-initiation-snapshot-params-nav-start-time">navigation start time</span> is | ||
| less than a user-agent provided threshold;</p></li> |
There was a problem hiding this comment.
I've updated the threshold to a hardcoded 3 seconds. (also, please let me know if you think we should add a note explaining why 3s.)
| potentially changed</span> to true.</p> | ||
|
|
||
| <p class="note">Other operations that could set cookies, such as the <a | ||
| href="https://wicg.github.io/cookie-store/">Cookie Store API</a> or receiving a Set-Cookie |
There was a problem hiding this comment.
I see, sure! I'll create a separate PR in the cookiestore repo, and link it here once it's up.
This CL introduces a `cookie_modification_count` in Document and NavigationClient. When a renderer-initiated navigation starts, NavigationClient captures a snapshot of the document's current cookie modification count. Subsequent checks for duplicate navigations now compare this captured count with the current document's count. If the counts differ, the navigation is not considered a duplicate, preventing it from being ignored. New browser tests are added to verify this behavior for both `document.cookie` and `cookieStore.set` modifications. Spec Link: whatwg/html#11765 Bug: 366060351 Change-Id: If5b3e2da6ca233c0eb85df6b08caa6a5959dcfe2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7787903 Reviewed-by: Rakina Zata Amni <rakina@chromium.org> Reviewed-by: Scott Haseley <shaseley@chromium.org> Commit-Queue: Anna Sato <annasato@chromium.org> Reviewed-by: Mingyu Lei <leimy@chromium.org> Cr-Commit-Position: refs/heads/main@{#1648863}
annevk
left a comment
There was a problem hiding this comment.
Overall this looks like it does what it set out to do. I found a lot of formatting issues and a couple more substantive issues.
| <span>WebDriver BiDi navigation status</span> whose <span | ||
| data-x="navigation-status-id">id</span> is <var>navigationId</var>, <span | ||
| data-x="navigation-status-status">status</span> is "<code | ||
| data-x="navigation-status-canceled">canceled</code>", and <span |
There was a problem hiding this comment.
Should we give a more detailed reason?
There was a problem hiding this comment.
I checked the definition of WebDriver BiDi navigation status, and it currently doesn't have a reason or message field. Should we expand the struct in this PR to include an optional reason, or leave it as "canceled" for now?
0675e6d to
38fe050
Compare
llannasatoll
left a comment
There was a problem hiding this comment.
Thank you for the review! Could you take another look?
| <span>WebDriver BiDi navigation status</span> whose <span | ||
| data-x="navigation-status-id">id</span> is <var>navigationId</var>, <span | ||
| data-x="navigation-status-status">status</span> is "<code | ||
| data-x="navigation-status-canceled">canceled</code>", and <span |
There was a problem hiding this comment.
I checked the definition of WebDriver BiDi navigation status, and it currently doesn't have a reason or message field. Should we expand the struct in this PR to include an optional reason, or leave it as "canceled" for now?
| potentially changed</span> to true.</p> | ||
|
|
||
| <p class="note">Other operations that could set cookies, such as the <cite>Cookie Store API</cite>, | ||
| also cause the <span>navigation conditions potentially changed</span> to be set to true.</p> |
There was a problem hiding this comment.
I'm not seeing a PR for this over at https://github.com/whatwg/cookiestore/pulls
Also, what does "such as" mean?
There was a problem hiding this comment.
I was waiting for this PR to land first to avoid cross-reference build errors, but now I've created whatwg/cookiestore#302 with a tentative reference in <pre class="anchors"> (maybe can be removed it once this PR landed?)
Also, what does "such as" mean?
Updated the note to be explicit: "The Cookie Store API also sets navigation conditions potentially changed to true when setting cookies."
As proposed in #11743, this prevents an ongoing navigation from being canceled by a new, identical navigation that is initiated within the threshould. This introduces the
navigation initiation snapshot paramsstruct, which is used to capture the state of the most recent navigation attempt, allowing the user agent to compare it with subsequent requests at the beginning of the navigation./browsing-the-web.html ( diff )
/document-sequences.html ( diff )
/dom.html ( diff )