Skip to content

Navigation: Add optimization to ignore duplicate navigations#11765

Open
llannasatoll wants to merge 9 commits into
whatwg:mainfrom
llannasatoll:ignore-duplicate-navigation
Open

Navigation: Add optimization to ignore duplicate navigations#11765
llannasatoll wants to merge 9 commits into
whatwg:mainfrom
llannasatoll:ignore-duplicate-navigation

Conversation

@llannasatoll

@llannasatoll llannasatoll commented Oct 8, 2025

Copy link
Copy Markdown
Contributor

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 params struct, 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 )

Comment thread source Outdated
@llannasatoll
llannasatoll force-pushed the ignore-duplicate-navigation branch from 27be0e6 to 4d255eb Compare November 17, 2025 05:05
@llannasatoll
llannasatoll requested a review from rakina November 17, 2025 05:23
@llannasatoll
llannasatoll force-pushed the ignore-duplicate-navigation branch 3 times, most recently from cac111e to 1ffc5d1 Compare April 15, 2026 11:44
@llannasatoll

Copy link
Copy Markdown
Contributor Author

@rakina Could you take another look? I've added a new struct navigation initiation snapshot params to store information about the most recent navigation so that we can compare the navigations?

@rakina rakina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread source
Comment thread source Outdated
Comment on lines +107301 to +107303
<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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this both be checking the entry list? Also should this check documentResource as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@llannasatoll
llannasatoll force-pushed the ignore-duplicate-navigation branch from f07484b to 7e7c910 Compare June 4, 2026 07:25
Comment thread source Outdated

<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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some suggestion to set this to an actual value, so maybe use the value used in Chromium (3s?): #11743 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

Comment thread source
Comment thread source Outdated
Comment thread source Outdated
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, sure! I'll create a separate PR in the cookiestore repo, and link it here once it's up.

@llannasatoll llannasatoll left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, Rakina! Could you take another look?

Comment thread source Outdated
Comment thread source Outdated

<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>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

Comment thread source Outdated
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, sure! I'll create a separate PR in the cookiestore repo, and link it here once it's up.

@rakina
rakina requested review from annevk and zcorpan June 8, 2026 05:47

@rakina rakina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good at this point, so let me add reviewers from other browsers who commented in #11743 (feel free to reassign/unassign)

beckysiegel pushed a commit to chromium/chromium that referenced this pull request Jun 18, 2026
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}
@llannasatoll

Copy link
Copy Markdown
Contributor Author

Hi @zcorpan @annevk, gentle ping for review when you have time.

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
<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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we give a more detailed reason?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@llannasatoll
llannasatoll force-pushed the ignore-duplicate-navigation branch from 0675e6d to 38fe050 Compare July 7, 2026 08:34

@llannasatoll llannasatoll left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review! Could you take another look?

Comment thread source Outdated
Comment thread source
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
Comment thread source Outdated
<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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@llannasatoll
llannasatoll requested a review from annevk July 9, 2026 10:20
@noamr noamr added the agenda+ To be discussed at a triage meeting label Jul 16, 2026
Comment thread source Outdated
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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing a PR for this over at https://github.com/whatwg/cookiestore/pulls

Also, what does "such as" mean?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

@jstenback jstenback removed the agenda+ To be discussed at a triage meeting label Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants