From 361b6675a3c0ba31b91cdc96714dcb3d5182a20b Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Tue, 15 Jul 2025 14:03:03 +0900 Subject: [PATCH 1/6] Carry over sticky activation for same-origin navs and traversals See discussion in https://github.com/WICG/view-transitions/issues/239 and https://github.com/whatwg/html/issues/11328#issuecomment-2937353307. --- source | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/source b/source index 61d173f9d79..5421aff155b 100644 --- a/source +++ b/source @@ -80190,8 +80190,8 @@ interface VisibilityStateEntry : PerformanceEntryData model -

For the purpose of tracking user activation, each Window W has two - relevant values:

+

For the purpose of tracking user activation, each Window W has the + following relevant values:

A user agent also defines a transient activation duration, which is a constant @@ -80217,12 +80219,14 @@ interface VisibilityStateEntry : PerformanceEntrySticky activation

When the current high resolution time given W is greater than or - equal to the last activation timestamp in W, W is said to - have sticky activation.

+ equal to the last activation timestamp in W, or W's + sticky activation override is true, W is said to have sticky + activation.

This is W's historical activation state, indicating whether the user has ever interacted in W. It starts false, then changes to true (and never changes back to - false) when W gets the very first activation notification.

+ false) when W gets the very first activation notification. It is also + carried over between windows for same-origin navigations and traversals.

Transient activation
@@ -106369,6 +106373,13 @@ location.href = '#foo'; realmExecutionContext, navigationParams's reserved environment, topLevelCreationURL, and topLevelOrigin.

+ +
  • If navigable's active window has + sticky activation, and navigable's active + document's origin is same + origin with navigationParams's origin, then set window's sticky + activation override to true.

  • This is the usual case, where the new Document we're about to From ad0e6b8914fdabe01cf83ed6cb4ae927b6950b8c Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 20 Aug 2025 14:25:45 +0900 Subject: [PATCH 2/6] Simplify per code review, also for history --- source | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/source b/source index 5421aff155b..fae2c9f409e 100644 --- a/source +++ b/source @@ -80199,10 +80199,9 @@ interface VisibilityStateEntry : PerformanceEntryconsumed). Initially positive infinity.

    -
  • A last history-action activation timestamp, which is either a - DOMHighResTimeStamp or positive infinity, initially positive infinity.

  • +
  • A has history-action activation boolean, initially false.

  • -
  • A sticky activation override, a boolean, initially false.

  • +
  • A has sticky activation boolean, initially false.

  • A user agent also defines a transient activation duration, which is a constant @@ -80218,10 +80217,8 @@ interface VisibilityStateEntry : PerformanceEntry

    Sticky activation
    -

    When the current high resolution time given W is greater than or - equal to the last activation timestamp in W, or W's - sticky activation override is true, W is said to have sticky - activation.

    +

    When W's has sticky activation is true, W is said to have + sticky activation.

    This is W's historical activation state, indicating whether the user has ever interacted in W. It starts false, then changes to true (and never changes back to @@ -80249,9 +80246,8 @@ interface VisibilityStateEntry : PerformanceEntryHistory-action activation

    -

    When the last history-action activation timestamp of W is not equal - to the last activation timestamp of W, then W is said to have - history-action activation.

    +

    When W's has history-action activation is true, then W is + said to have history-action activation.

    This is a special variant of user activation, used to allow access to certain session history APIs which, if used too frequently, would make it harder for the user to traverse back using VisibilityStateEntry : PerformanceEntry -

    The last activation timestamp and last history-action - activation timestamp are retained even after the Document changes its - fully active status (e.g., after navigating away from a Document, or - navigating to a cached Document). This means sticky activation state - spans multiple navigations as long as the same Document gets reused. For the - transient activation state, the original expiry time - remains unchanged (i.e., the state still expires within the transient activation - duration limit from the original activation triggering input event). It is - important to consider this when deciding whether to base certain things off sticky - activation or transient activation.

    +

    The underlying values are retained even + after the Document changes its fully active status (e.g., after + navigating away from a Document, or navigating to a cached Document). + This means sticky activation and history-action activation spans + multiple navigations as long as the same Document gets reused. For the transient + activation state, the original expiry time remains + unchanged (i.e., the state still expires within the transient activation duration + limit from the original activation triggering input event). It is important to + consider this when deciding what type of activation to base certain things off of.

    Processing model

    @@ -80306,6 +80301,10 @@ interface VisibilityStateEntry : PerformanceEntry

    Set window's last activation timestamp to the current high resolution time.

    +
  • Set window's has history-action activation to true.

  • + +
  • Set window's has sticky activation to true.

  • +
  • Notify the close watcher manager about user activation given window.

  • @@ -80373,8 +80372,7 @@ interface VisibilityStateEntry : PerformanceEntrynavigables.

  • For each window in windows, set - window's last history-action activation timestamp to window's - last activation timestamp.

  • + window's has history-action activation to false.

    Note the asymmetry in the sets of browsing @@ -106378,8 +106376,8 @@ location.href = '#foo'; sticky activation, and navigable's active document's origin is same origin with navigationParams's origin, then set window's sticky - activation override to true.

    + data-x="navigation-params-origin">origin
    , then set window's has sticky + activation to true.

    This is the usual case, where the new Document we're about to From fae6b36ecdb2822a9c1f3adf764d550dec444d4b Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 22 Aug 2025 14:34:01 +0900 Subject: [PATCH 3/6] Minor cleanups noticed while in the area --- source | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source b/source index fae2c9f409e..0d959ccc3de 100644 --- a/source +++ b/source @@ -106372,12 +106372,11 @@ location.href = '#foo'; data-x="navigation-params-reserved-environment">reserved environment, topLevelCreationURL, and topLevelOrigin.

    -
  • If navigable's active window has - sticky activation, and navigable's active - document's origin is same - origin with navigationParams's origin, then set window's has sticky - activation to true.

  • +
  • If browsingContext's active window has sticky + activation, and browsingContext's active document's origin is same origin with + navigationParams's origin, then set + window's has sticky activation to true.

  • This is the usual case, where the new Document we're about to From 3939d915c4fe5989d7d4ac9ffafde2dae72ac6dd Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 22 Aug 2025 14:46:11 +0900 Subject: [PATCH 4/6] Carry it over during bfcache restoration --- source | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/source b/source index 0d959ccc3de..e8bca0fde73 100644 --- a/source +++ b/source @@ -80223,7 +80223,8 @@ interface VisibilityStateEntry : PerformanceEntryThis is W's historical activation state, indicating whether the user has ever interacted in W. It starts false, then changes to true (and never changes back to false) when W gets the very first activation notification. It is also - carried over between windows for same-origin navigations and traversals.

    + carried over between windows for same-origin navigations and traversals (including
    during reactivation from bfcache).

    Transient activation
    @@ -104900,6 +104901,15 @@ location.href = '#foo'; entries for the navigation API
    given navigable and targetStep.

    +
  • Let stickyActivationToCarryOver be false.

  • + +
  • If displayedDocument's relevant global object has sticky + activation, and displayDocument's origin is same origin with + targetEntry's document's origin, then set stickyActivationToCarryOver + to true.

  • +
  • If changingNavigableContinuation's update-only is true, or @@ -104952,7 +104962,8 @@ location.href = '#foo'; changingNavigableContinuation's update-only, scriptHistoryLength, scriptHistoryIndex, navigationType, - entriesForNavigationAPI, and previousEntry.

  • + entriesForNavigationAPI, previousEntry, and + stickyActivationToCarryOver.

  • If targetEntry's document is equal to displayedDocument, then perform updateDocument.

  • @@ -105482,8 +105493,9 @@ location.href = '#foo'; doNotReactivate, integers scriptHistoryLength and scriptHistoryIndex, NavigationType-or-null navigationType, an optional list of session history entries - entriesForNavigationAPI, and an optional session history entry - previousEntryForActivation:

    + entriesForNavigationAPI, an optional session history entry + previousEntryForActivation, and an optional boolean + stickyActivationToCarryOver (default false):

    1. Let documentIsNew be true if document's latest entry @@ -105659,7 +105671,8 @@ location.href = '#foo';

    2. Assert: entriesForNavigationAPI is given.

    3. Reactivate document given - entry and entriesForNavigationAPI.

      + entry, entriesForNavigationAPI, and + stickyActivationToCarryOver.

    documentsEntryChanged can be false for one of two reasons: either we @@ -105710,8 +105723,9 @@ location.href = '#foo';

    To reactivate a Document document given a session history entry - reactivatedEntry and a list of session history entries entriesForNavigationAPI:

    + reactivatedEntry, a list of session + history entries entriesForNavigationAPI, and a boolean + stickyActivationToCarryOver:

    This algorithm updates document after it has come out of bfcache, i.e., after it has been made fully active @@ -105720,6 +105734,16 @@ location.href = '#foo'; of events that happen in effect of the change is clear.

      +
    1. +

      If stickyActivationToCarryOver is true, then set document's + relevant global object's has sticky activation to true.

      + +

      This means we are performing a + same-origin traverse from a document with sticky activation, in which case, we want to carry + over sticky activation if present, even if this bfcached Document did not + originally have it.

      +
    2. +
    3. For each formControl of form controls in document with an autofill field name of "off", invoke the data-x="navigation-params-origin">origin.

    4. -

      If navigable's container is not null, - then:

      +

      If navigationParams's navigable's container is not null, then:

      1. Let parentEnvironment be navigable's Date: Fri, 22 Aug 2025 14:59:29 +0900 Subject: [PATCH 5/6] Fix build oops --- source | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source b/source index e8bca0fde73..669d3d51f2c 100644 --- a/source +++ b/source @@ -105736,7 +105736,7 @@ location.href = '#foo';

        1. If stickyActivationToCarryOver is true, then set document's - relevant global object's has sticky activation to true.

          + relevant global object's has sticky activation to true.

          This means we are performing a same-origin traverse from a document with sticky activation, in which case, we want to carry @@ -106376,7 +106376,8 @@ location.href = '#foo'; data-x="navigation-params-origin">origin.

        2. -

          If navigationParams's navigable's If navigationParams's navigable's container is not null, then:

            From be03fd6b72967ba7822e2a721488489ad827d48b Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Thu, 18 Sep 2025 10:05:12 +0900 Subject: [PATCH 6/6] Fix nits --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 669d3d51f2c..434920285e4 100644 --- a/source +++ b/source @@ -80372,7 +80372,7 @@ interface VisibilityStateEntry : PerformanceEntryactive window of each item in navigables.

            -
          1. For each window in windows, set +

          2. For each window of windows, set window's has history-action activation to false.

          @@ -106378,7 +106378,7 @@ location.href = '#foo';
        3. If navigationParams's navigable's container is not null, then:

          + data-x="nav-container">container is not null:

          1. Let parentEnvironment be navigable's