From d5f3e962836cc9ea2718eb5aad88d9c2dcbb9a1b Mon Sep 17 00:00:00 2001 From: David Bokan Date: Mon, 20 Nov 2023 14:22:52 -0500 Subject: [PATCH] Use userInvolvement instead of sec-fetch-site sec-fetch-site was being checked for 'none' to indicate that a navigation was initiated from browser UI. However, we cannot inspect request headers from this part of the algorithm. Instead, the navigate algorithm now has a userInvolvement parameter which provides this information explicitly. Plumb that into navigation params and use it instead. --- index.bs | 78 +++++++++++++++++++++++++++++------------------------- index.html | 67 +++++++++++++++++++++++++--------------------- 2 files changed, 79 insertions(+), 66 deletions(-) diff --git a/index.bs b/index.bs index eebfe27..3bdf6c6 100644 --- a/index.bs +++ b/index.bs @@ -1143,40 +1143,47 @@ boolean [=document/text directive user activation=] field: allowed in all cases. +Amend the definition of navigation params to include a new field: + +> Monkeypatching [[HTML]]: +> +>
+>
user involvement
+>
A user navigation involvement value.
+>
+> +> +> Initialize [=user involvement=] value everywhere a navigation params is created, in particular, +> amend the definition of +> attempt to populate the history entry's document +> to take a user navigation involvement as a parameter, using it to populate the field when creating +> a new navigation params. + Amend the create and initialize a Document object steps by adding the following steps before returning |document|: > Monkeypatching [[HTML]]: > -> 15. Set |document|'s [=document/text directive user activation=] by following these sub-steps: -> 1. Let |is user activated| be true if the current navigation was initiated from -> a window that had a transient activation at the time the -> navigation was initiated, or the UA has reason to believe it comes from a -> direct user gesture (e.g. user typed into the address bar). ->
-> TODO: it'd be better to refer to the [=request/user-activation=] flag. ->
-> 1. If browsing context is a top-level browsing context and if either of |is -> user activated| or the [=request/text directive user activation=] of -> |navigationParam|'s -> request -> object is true, set the |document|'s [=document/text directive user activation=] -> to true. Otherwise, set it to false. ->
-> It's important that the flag not be copyable so that only one text fragment can be -> activated per user-activated navigation. ->
-> 16. Set |document|'s [=document/allow text fragment scroll=] by following these sub-steps: +> 19. Set |document|'s [=document/text directive user activation=] to true if any of the following +> conditions hold, false otherwise: +> * |navigationParams|'s [=user involvement=] is "activation"; +> * |navigationParams|'s [=user involvement=] is "browser UI"; or +> * |navigationParams|'s +> request's +> [=request/text directive user activation=] is true. +>
+> It's important that [=document/text directive user activation=] not be copyable so that +> only one text fragment can be activated per user-activated navigation. +>
+> 20. Set |document|'s [=document/allow text fragment scroll=] by following these sub-steps: > 1. If |document|'s [=Document/uninvoked directives=] field is null or empty, set > [=document/allow text fragment scroll=] to false and abort these sub-steps. > 1. Let |text directive user activation| be the value of |document|'s > [=document/text directive user activation=] and set |document|'s > [=document/text directive user activation=] to false. -> 1. If the |navigationParam|'s -> request -> has a sec-fetch-site -> header and its value is `"none"` set [=document/allow text fragment scroll=] to true and abort these sub-steps. +> 1. If the |navigationParam|'s [=user involvement=] is "browser UI", set +> [=document/allow text fragment scroll=] to true and abort these sub-steps. >
>

> If a navigation originates from browser UI, it's always ok to allow it @@ -1184,25 +1191,24 @@ and initialize a Document object steps by adding the following steps before > text snippet. >

>

-> Note: Depending on the UA, there can be cases where the -> incumbentNavigationOrigin parameter is null but -> it's not clear that the navigation is to be considered as -> initiated from browser UI. E.g. an "open in new window" context -> menu item when right clicking on a link. The intent in this item -> is to distinguish cases where the app/page is able to set the URL -> from those that are fully under the user's control. In the former -> we want to prevent activation of the text fragment unless the -> destination is loaded in a separate browsing context group (so that -> the source cannot both control the text snippet and observe -> side-effects in the navigation). +> Note: The intent in this item is to distinguish cases where the +> app/page is able to control the URL from those that are fully +> under the user's control. In the former we want to prevent +> scrolling of the text fragment unless the destination is loaded +> in a separate browsing context group (so that the source cannot +> both control the text snippet and observe side-effects in the +> navigation). There are some cases where "browser UI" may be a +> grey area in this regard. E.g. an "open in new window" context +> menu item when right clicking on a link. >

>

> See > sec-fetch-site -> in [[FETCH-METADATA]] for a more detailed discussion of how this applies. +> in [[FETCH-METADATA]] for a related discussion of how this applies. >

>
-> 1. If |text directive user activation| is false, set +> 1. If |text directive user activation| is false, or browsing context is +> not a top-level browsing context, set > [=document/allow text fragment scroll=] to false and abort these sub-steps. > 1. If the |navigationParam|'s > request diff --git a/index.html b/index.html index 03dd3dd..08c8763 100644 --- a/index.html +++ b/index.html @@ -1951,26 +1951,35 @@

TODO: This should really only prevent potentially observable side-effects like automatic scrolling. Unobservable effects like a highlight could be safely allowed in all cases. +

Amend the definition of navigation params to include a new field:

+
+

Monkeypatching [HTML]:

+
+
user involvement +
A user navigation involvement value. +
+

Initialize user involvement value everywhere a navigation params is created, in particular, +amend the definition of attempt to populate the history entry’s document to take a user navigation involvement as a parameter, using it to populate the field when creating +a new navigation params.

+

Amend the create and initialize a Document object steps by adding the following steps before returning document:

Monkeypatching [HTML]:

-
    +
    1. -

      Set document’s text directive user activation by following these sub-steps:

      -
        +

        Set document’s text directive user activation to true if any of the following +conditions hold, false otherwise:

        +
        • -

          Let is user activated be true if the current navigation was initiated from - a window that had a transient activation at the time the - navigation was initiated, or the UA has reason to believe it comes from a - direct user gesture (e.g. user typed into the address bar).

          -
          TODO: it’d be better to refer to the user-activation flag.
          +

          navigationParams’s user involvement is "activation";

        • -

          If browsing context is a top-level browsing context and if either of is - user activated or the text directive user activation of navigationParam’s request object is true, set the document’s text directive user activation to true. Otherwise, set it to false.

          -
          It’s important that the flag not be copyable so that only one text fragment can be - activated per user-activated navigation.
          -
      +

      navigationParams’s user involvement is "browser UI"; or

      +
    2. +

      navigationParams’s request’s text directive user activation is true.

      +
      It’s important that text directive user activation not be copyable so that + only one text fragment can be activated per user-activated navigation.
      +
    3. Set document’s allow text fragment scroll by following these sub-steps:

        @@ -1979,25 +1988,25 @@