From ce00f26c3c55ad89cb488b380310a96c56eb04f2 Mon Sep 17 00:00:00 2001 From: Siye Liu <44512924+siliu1@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:54:20 -0700 Subject: [PATCH 01/11] Spec change for focus-without-user-activation Cherry-picked from https://github.com/whatwg/html/pull/4585 --- source | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source b/source index 3299988e433..3e95a2cdfa0 100644 --- a/source +++ b/source @@ -4876,6 +4876,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute data-x="">cross-origin-isolated", which has a default allowlist of 'self'. +
  • "focus-without-user-activation", which has a default allowlist of *.
  • @@ -80506,6 +80509,11 @@ dictionary ToggleEventInit : EventInit {
  • If current is null, then return.

  • +
  • If this algorithm is not triggered by user activation and + current's active document is not allowed to use the "focus-without-user-activation" feature, + then return.

  • +
  • Run the focusing steps with current.

  • If current is a top-level traversable, user agents are encouraged @@ -80525,6 +80533,11 @@ dictionary ToggleEventInit : EventInit { method on elements, when invoked, must run the following steps:

      +
    1. If this algorithm is not triggered by user activation and the element's + node document is not allowed to use the "focus-without-user-activation" feature, + then return.

    2. +
    3. If the element is marked as locked for focus, then return.

    4. Mark the element as locked for focus.

    5. @@ -80631,6 +80644,11 @@ dictionary ToggleEventInit : EventInit {
    6. If target's active sandboxing flag set has the sandboxed automatic features browsing context flag, then return.

    7. +
    8. If this algorithm is not triggered by user activation and the + target is not allowed to use the "focus-without-user-activation" feature, + then return.

    9. +
    10. For each ancestorNavigable of target's ancestor navigables: if ancestorNavigable's active document's Date: Wed, 2 Oct 2024 14:08:03 -0700 Subject: [PATCH 02/11] change default allowlist of `user-without-user-activation` to `self`. --- source | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source b/source index 3e95a2cdfa0..4fa218bd37e 100644 --- a/source +++ b/source @@ -4877,8 +4877,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute data-x="concept-default-allowlist">default allowlist of 'self'.

    11. "focus-without-user-activation", which has a default allowlist of *.
    12. + data-x="">focus-without-user-activation", which has a default allowlist of `self`. From 4ba98645eb84f1f4c1cea31d659703e6987efb8b Mon Sep 17 00:00:00 2001 From: Siye Liu <44512924+siliu1@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:31:21 -0700 Subject: [PATCH 03/11] Allow focus delegation in iframe when `focus-without-user-activation` policy is disabled. --- source | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source b/source index 4fa218bd37e..fe9e48ffe02 100644 --- a/source +++ b/source @@ -80510,7 +80510,8 @@ dictionary ToggleEventInit : EventInit {
    13. If current is null, then return.

    14. -
    15. If this algorithm is not triggered by user activation and +

    16. If this algorithm is not triggered by user activation and is not + triggered by script execution from current's ancestor navigables, and current's active document is not allowed to use the "focus-without-user-activation" feature, then return.

    17. @@ -80534,7 +80535,8 @@ dictionary ToggleEventInit : EventInit { method on elements, when invoked, must run the following steps:

        -
      1. If this algorithm is not triggered by user activation and the element's +

      2. If this algorithm is not triggered by user activation and is not + triggered by script execution from element's ancestor navigables, and the element's node document is not allowed to use the "focus-without-user-activation" feature, then return.

      3. From 88200572488926e946fd115fc6f1e59258909732 Mon Sep 17 00:00:00 2001 From: Siye Liu <44512924+siliu1@users.noreply.github.com> Date: Thu, 3 Oct 2024 08:52:39 -0700 Subject: [PATCH 04/11] Fix logical error in `focus-without-user-activation` spec. --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index fe9e48ffe02..7b340fd0b21 100644 --- a/source +++ b/source @@ -80510,7 +80510,7 @@ dictionary ToggleEventInit : EventInit {
      4. If current is null, then return.

      5. -
      6. If this algorithm is not triggered by user activation and is not +

      7. If this algorithm is not triggered by user activation or is not triggered by script execution from current's ancestor navigables, and current's active document is not allowed to use the "focus-without-user-activation" feature, @@ -80535,7 +80535,7 @@ dictionary ToggleEventInit : EventInit { method on elements, when invoked, must run the following steps:

          -
        1. If this algorithm is not triggered by user activation and is not +

        2. If this algorithm is not triggered by user activation or is not triggered by script execution from element's ancestor navigables, and the element's node document is not allowed to use the "focus-without-user-activation" feature, From 768a15b69c29943446579a1fd287e8ecf7fd5fac Mon Sep 17 00:00:00 2001 From: Siye Liu <44512924+siliu1@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:52:50 -0700 Subject: [PATCH 05/11] Add Siye Liu to the `Thanks to` list. --- source | 1 + 1 file changed, 1 insertion(+) diff --git a/source b/source index 04db9e46c03..02bf3dd90a8 100644 --- a/source +++ b/source @@ -145054,6 +145054,7 @@ INSERT INTERFACES HERE Yu Han, Simon Spiegel, Simon Wülker, + Siye Liu, skeww, Smylers, Srirama Chandra Sekhar Mogali, From 35661cf8bcde7660aff0b24077d3968e0bf85305 Mon Sep 17 00:00:00 2001 From: Siye Liu <44512924+siliu1@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:20:58 -0700 Subject: [PATCH 06/11] Attempt to fix build break. --- source | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source b/source index 02bf3dd90a8..f2c79d44e18 100644 --- a/source +++ b/source @@ -80536,11 +80536,11 @@ dictionary ToggleEventInit : EventInit {

        3. If current is null, then return.

        4. -
        5. If this algorithm is not triggered by user activation or is not - triggered by script execution from current's ancestor navigables, and - current's active document is not allowed to use the "focus-without-user-activation" feature, - then return.

        6. +
        7. If this algorithm is triggered without transient user + activation or is not triggered by script execution from current's + ancestor navigables, and current's active document is not + allowed to use the " + focus-without-user-activation" feature, then return.

        8. Run the focusing steps with current.

        9. @@ -80561,11 +80561,11 @@ dictionary ToggleEventInit : EventInit { method on elements, when invoked, must run the following steps:

            -
          1. If this algorithm is not triggered by user activation or is not - triggered by script execution from element's ancestor navigables, and the element's - node document is not allowed to use the "focus-without-user-activation" feature, - then return.

          2. +
          3. If this algorithm is triggered without transient user + activation or is not triggered by script execution from element's ancestor + navigables, and the element's node document is not allowed to use + the "focus-without-user-activation" + feature, then return.

          4. If the element is marked as locked for focus, then return.

          5. @@ -80673,8 +80673,8 @@ dictionary ToggleEventInit : EventInit {
          6. If target's active sandboxing flag set has the sandboxed automatic features browsing context flag, then return.

          7. -
          8. If this algorithm is not triggered by user activation and the - target is not allowed to use the "

            If this algorithm is triggered without transient use + activation and the target is not allowed to use the "focus-without-user-activation" feature, then return.

          9. From 4eab7237d6beb2fb42e6befb8a6d3bcec5856ad2 Mon Sep 17 00:00:00 2001 From: Siye Liu <44512924+siliu1@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:48:33 -0700 Subject: [PATCH 07/11] Attempt to fix build break. Also fix logic error. --- source | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source b/source index f2c79d44e18..89897f88922 100644 --- a/source +++ b/source @@ -80537,9 +80537,9 @@ dictionary ToggleEventInit : EventInit {
          10. If current is null, then return.

          11. If this algorithm is triggered without transient user - activation or is not triggered by script execution from current's - ancestor navigables, and current's active document is not - allowed to use the " + activation and is not triggered by script execution from current's + ancestor navigables, and current's active document is not + allowed to use the " focus-without-user-activation" feature, then return.

          12. Run the focusing steps with current.

          13. @@ -80562,7 +80562,7 @@ dictionary ToggleEventInit : EventInit {
            1. If this algorithm is triggered without transient user - activation or is not triggered by script execution from element's ancestor + activation and is not triggered by script execution from element's ancestor navigables, and the element's node document is not allowed to use the "focus-without-user-activation" feature, then return.

            2. From bfde2ecbe5f8eae46781ffc646eab6110f6945dd Mon Sep 17 00:00:00 2001 From: Siye Liu <44512924+siliu1@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:25:48 -0700 Subject: [PATCH 08/11] Add focus-without-user-activation logic to `dialog focusing steps` and `popover focusing steps` --- source | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source b/source index 89897f88922..aeef67099a5 100644 --- a/source +++ b/source @@ -61524,6 +61524,11 @@ interface HTMLDialogElement : HTMLElement { are as follows:

                +
              1. If this algorithm is triggered without transient use + activation and the target is not allowed to use the "focus-without-user-activation" feature, + then return.

              2. +
              3. Let control be null.

              4. If subject has the autofocus @@ -85739,6 +85744,11 @@ dictionary DragEventInit : MouseEventInit { element subject:

                  +
                1. If this algorithm is triggered without transient use + activation and the target is not allowed to use the "focus-without-user-activation" feature, + then return.

                2. +
                3. If subject is a dialog element, then run the dialog focusing steps given subject and return.

                4. From f49ccf5ec446d14651206758a54aa5cbc7c0a69f Mon Sep 17 00:00:00 2001 From: Siye Liu <44512924+siliu1@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:22:12 -0800 Subject: [PATCH 09/11] Fix identation and quote format. --- source | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source b/source index aeef67099a5..ff8f870c5c4 100644 --- a/source +++ b/source @@ -4879,7 +4879,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
                5. "focus-without-user-activation", which has a default allowlist of `self`.
                6. + data-x="">'self'
                  . @@ -80542,10 +80542,10 @@ dictionary ToggleEventInit : EventInit {
                7. If current is null, then return.

                8. If this algorithm is triggered without transient user - activation and is not triggered by script execution from current's - ancestor navigables, and current's active document is not - allowed to use the " - focus-without-user-activation" feature, then return.

                9. + activation and is not triggered by script execution from current's + ancestor navigables, and current's active document is not + allowed to use the " + focus-without-user-activation" feature, then return.

                10. Run the focusing steps with current.

                11. @@ -80567,10 +80567,10 @@ dictionary ToggleEventInit : EventInit {
                  1. If this algorithm is triggered without transient user - activation and is not triggered by script execution from element's ancestor - navigables, and the element's node document is not allowed to use - the "focus-without-user-activation" - feature, then return.

                  2. + activation and is not triggered by script execution from element's ancestor + navigables, and the element's node document is not allowed to use + the "focus-without-user-activation" + feature, then return.

                  3. If the element is marked as locked for focus, then return.

                  4. @@ -80679,9 +80679,9 @@ dictionary ToggleEventInit : EventInit { sandboxed automatic features browsing context flag, then return.

                  5. If this algorithm is triggered without transient use - activation and the target is not allowed to use the "focus-without-user-activation" feature, - then return.

                  6. + activation and the target is not allowed to use the "focus-without-user-activation" feature, + then return.

                  7. For each ancestorNavigable of target's ancestor navigables: if ancestorNavigable's Date: Thu, 19 Dec 2024 09:38:54 -0800 Subject: [PATCH 10/11] Address PR comments. --- source | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/source b/source index ff8f870c5c4..247f4d97619 100644 --- a/source +++ b/source @@ -61525,7 +61525,8 @@ interface HTMLDialogElement : HTMLElement {

                    1. If this algorithm is triggered without transient use - activation and the target is not allowed to use the " in current's relevant global object and current's + active document is not allowed to use the "focus-without-user-activation" feature, then return.

                    2. @@ -80542,9 +80543,10 @@ dictionary ToggleEventInit : EventInit {
                    3. If current is null, then return.

                    4. If this algorithm is triggered without transient user - activation and is not triggered by script execution from current's - ancestor navigables, and current's active document is not - allowed to use the " + activation in current's relevant global object and is not triggered + by invoking focus() method on a child + of current's ancestor navigables' active document, and current's + active document is not allowed to use the " focus-without-user-activation" feature, then return.

                    5. Run the focusing steps with current.

                    6. @@ -80567,10 +80569,11 @@ dictionary ToggleEventInit : EventInit {
                      1. If this algorithm is triggered without transient user - activation and is not triggered by script execution from element's ancestor - navigables, and the element's node document is not allowed to use - the "focus-without-user-activation" - feature, then return.

                      2. + activation in current's relevant global object and is not triggered + by invoking focus() method on a child + of current's ancestor navigables' active document, and the element's + node document is not allowed to use the " + focus-without-user-activation" feature, then return.

                      3. If the element is marked as locked for focus, then return.

                      4. @@ -80679,9 +80682,9 @@ dictionary ToggleEventInit : EventInit { sandboxed automatic features browsing context flag, then return.

                      5. If this algorithm is triggered without transient use - activation and the target is not allowed to use the "focus-without-user-activation" feature, - then return.

                      6. + activation in current's relevant global object and target + is not allowed to use the " + focus-without-user-activation" feature, then return.

                      7. For each ancestorNavigable of target's ancestor navigables: if ancestorNavigable's DragEventInit : MouseEventInit {

                        1. If this algorithm is triggered without transient use - activation and the target is not allowed to use the " in current's relevant global object and subject's + active document is not allowed to use the "focus-without-user-activation" feature, then return.

                        2. From 22b9553149b3a22ab622db80457dcc6402e7049f Mon Sep 17 00:00:00 2001 From: Siye Liu Date: Thu, 16 Jan 2025 10:56:52 -0800 Subject: [PATCH 11/11] Address PR comments. --- source | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/source b/source index 247f4d97619..cc7107a8a06 100644 --- a/source +++ b/source @@ -61524,8 +61524,8 @@ interface HTMLDialogElement : HTMLElement { are as follows:

                            -
                          1. If this algorithm is triggered without transient use - activation in current's relevant global object and current's +

                          2. If there is no transient user activation in + subject's relevant global object and subject's active document is not allowed to use the "focus-without-user-activation" feature, then return.

                          3. @@ -80542,9 +80542,9 @@ dictionary ToggleEventInit : EventInit {
                          4. If current is null, then return.

                          5. -
                          6. If this algorithm is triggered without transient user - activation in current's relevant global object and is not triggered - by invoking focus() method on a child +

                          7. If there is no transient user activation in + current's relevant global object and is not triggered by invoking + focus() method on a child of current's ancestor navigables' active document, and current's active document is not allowed to use the " focus-without-user-activation" feature, then return.

                          8. @@ -80568,10 +80568,10 @@ dictionary ToggleEventInit : EventInit { method on elements, when invoked, must run the following steps:

                              -
                            1. If this algorithm is triggered without transient user - activation in current's relevant global object and is not triggered - by invoking focus() method on a child - of current's ancestor navigables' active document, and the element's +

                            2. If there is no transient user activation in + the element's relevant global object and is not triggered by invoking + focus() method on a child + of the element's ancestor navigables' active document, and the element's node document is not allowed to use the " focus-without-user-activation" feature, then return.

                            3. @@ -80681,8 +80681,8 @@ dictionary ToggleEventInit : EventInit {
                            4. If target's active sandboxing flag set has the sandboxed automatic features browsing context flag, then return.

                            5. -
                            6. If this algorithm is triggered without transient use - activation in current's relevant global object and target +

                            7. If there is no transient use activation in + target's relevant global object and target is not allowed to use the " focus-without-user-activation" feature, then return.

                            8. @@ -85747,8 +85747,8 @@ dictionary DragEventInit : MouseEventInit { element subject:

                                -
                              1. If this algorithm is triggered without transient use - activation in current's relevant global object and subject's +

                              2. If there is no transient user activation in + subject's relevant global object and subject's active document is not allowed to use the "focus-without-user-activation" feature, then return.