Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Policy: focus-without-user-activation #10672

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
33 changes: 33 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -4876,6 +4876,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
data-x="">cross-origin-isolated</code></dfn>", which has a <span
data-x="concept-default-allowlist">default allowlist</span> of <code
data-x="">'self'</code>.</li>
<li>"<dfn data-x="focus-without-user-activation-feature"><code
data-x="">focus-without-user-activation</code></dfn>", which has a <span
data-x="concept-default-allowlist">default allowlist</span> of <code
data-x="">'self'</code>.</li>
siliu1 marked this conversation as resolved.
Show resolved Hide resolved
</ul>


Expand Down Expand Up @@ -61520,6 +61524,11 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> {
are as follows:</p>

<ol>
<li><p>If this algorithm is triggered without <span data-x="transient activation">transient use
Copy link
Member

Choose a reason for hiding this comment

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

I didn't notice this when reading this PR the first time, but this seems wrong. "transient activation" is something you can say about a Window object. So instead of talking about this algorithm, you need to get hold of a window object. Perhaps target's relevant global object?

(This applies multiple times in this PR.)

activation</span> and the <var>target</var> is not <span>allowed to use</span> the "<code
Copy link
Member

Choose a reason for hiding this comment

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

A variable should not have "the" in front of it.

data-x="focus-without-user-activation-feature">focus-without-user-activation</code>" feature,
then return.</p></li>

<li><p>Let <var>control</var> be null.</p></li>

<li><p>If <var>subject</var> has the <code data-x="attr-fe-autofocus">autofocus</code>
Expand Down Expand Up @@ -80532,6 +80541,12 @@ dictionary <dfn dictionary>ToggleEventInit</dfn> : <span>EventInit</span> {

<li><p>If <var>current</var> is null, then return.</p></li>

<li><p>If this algorithm is triggered without <span data-x="transient activation">transient user
activation</span> and is not triggered by script execution from <var>current</var>'s
siliu1 marked this conversation as resolved.
Show resolved Hide resolved
<span>ancestor navigables</span>, and <var>current</var>'s <span>active document</span> is not
Comment on lines +80545 to +80546
Copy link
Member

Choose a reason for hiding this comment

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

"triggered by script execution" is not a concept that exists or is defined. It's rather unclear to me what this is trying to accomplish.

<span>allowed to use</span> the "<code data-x="focus-without-user-activation-feature">
focus-without-user-activation</code>" feature, then return.</p></li>

<li><p>Run the <span>focusing steps</span> with <var>current</var>.</p></li>

<li><p>If <var>current</var> is a <span>top-level traversable</span>, user agents are encouraged
Expand All @@ -80551,6 +80566,12 @@ dictionary <dfn dictionary>ToggleEventInit</dfn> : <span>EventInit</span> {
method on elements, when invoked, must run the following steps:</p>

<ol>
<li><p>If this algorithm is triggered without <span data-x="transient activation">transient user
activation</span> and is not triggered by script execution from element's <span>ancestor
navigables</span>, and the element's <span>node document</span> is not <span>allowed to use</span>
the "<code data-x="focus-without-user-activation-feature">focus-without-user-activation</code>"
feature, then return.</p></li>

<li><p>If the element is marked as <i data-x="locked for focus">locked for focus</i>, then return.</p></li>

<li><p>Mark the element as <dfn>locked for focus</dfn>.</p></li>
Expand Down Expand Up @@ -80657,6 +80678,11 @@ dictionary <dfn dictionary>ToggleEventInit</dfn> : <span>EventInit</span> {
<li><p>If <var>target</var>'s <span>active sandboxing flag set</span> has the
<span>sandboxed automatic features browsing context flag</span>, then return.</p></li>

<li><p>If this algorithm is triggered without <span data-x="transient activation">transient use
activation</span> and the <var>target</var> is not <span>allowed to use</span> the "<code
data-x="focus-without-user-activation-feature">focus-without-user-activation</code>" feature,
then return.</p></li>

<li><p><span data-x="list iterate">For each</span> <var>ancestorNavigable</var> of
<var>target</var>'s <span>ancestor navigables</span>: if <var>ancestorNavigable</var>'s <span
data-x="nav-document">active document</span>'s <span
Expand Down Expand Up @@ -85718,6 +85744,11 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
element</span> <var>subject</var>:</p>

<ol>
<li><p>If this algorithm is triggered without <span data-x="transient activation">transient use
activation</span> and the <var>target</var> is not <span>allowed to use</span> the "<code
data-x="focus-without-user-activation-feature">focus-without-user-activation</code>" feature,
then return.</p></li>

<li><p>If <var>subject</var> is a <code>dialog</code> element, then run the <span>dialog focusing
steps</span> given <var>subject</var> and return.</p></li>

Expand Down Expand Up @@ -144394,6 +144425,7 @@ INSERT INTERFACES HERE
Edward Welbourne,
Edward Z. Yang,
Ehsan Akhgari,
Ehsan Karamad,
Eira Monstad,
Eitan Adler,
Eli Friedman,
Expand Down Expand Up @@ -145032,6 +145064,7 @@ INSERT INTERFACES HERE
Yu Han, <!-- yuzhe-han on GitHub -->
Simon Spiegel,
Simon Wülker, <!-- Wuelle on GitHub -->
Siye Liu,
skeww, <!-- on reddit -->
Smylers,
Srirama Chandra Sekhar Mogali,
Expand Down