-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
base: main
Are you sure you want to change the base?
Conversation
Cherry-picked from whatwg#4585
… policy is disabled.
There are more APIs that call the focusing steps. For example |
…d `popover focusing steps`
This is a good catch. I added extra steps in |
There seem to be more APIs than just the above ones that reference "focusing steps".
Were you able to go through all of them and confirm that the ones you are updating herewith are the only ones that need updates? |
Could you mark the entries in the checklist that have been completed via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable, but it looks like you got in a race with the bot when updating OP. Each time you make an edit (including checking a checkbox) the bot will run. So it's best to click edit and change it all in one go and then wait for the bot to update before making another change.
Though also, if you filed bugs against Gecko/WebKit those need to be linked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found some more substantial issues. Please also create an MDN issue.
source
Outdated
<li><p>If this algorithm is triggered without <span data-x="transient activation">transient use | ||
activation</span> in <var>current</var>'s <span>relevant global object</span> and <var>current</var>'s | ||
<span>active 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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does current come from here? Perhaps you mean the current global object? That won't work if we're also concerned about postMessage()
like scenarios, but I don't think we are?
You don't have to say "if this algorithm is triggered". At least I'm not sure what that adds if all you want to do is check state and then return if the state is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in next iteration.
@@ -61520,6 +61524,12 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> { | |||
are as follows:</p> | |||
|
|||
<ol> | |||
<li><p>If there is no <span data-x="transient activation">transient user activation</span> in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be worded slightly differently still:
If subject's relevant global object has no transient user activation ...
Are you sure this is the correct global to check though?
@@ -61520,6 +61524,12 @@ interface <dfn interface>HTMLDialogElement</dfn> : <span>HTMLElement</span> { | |||
are as follows:</p> | |||
|
|||
<ol> | |||
<li><p>If there is no <span data-x="transient activation">transient user activation</span> in | |||
<var>subject</var>'s <span>relevant global object</span> and <var>subject</var>'s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presumably this should be OR?
@@ -80532,6 +80542,13 @@ dictionary <dfn dictionary>ToggleEventInit</dfn> : <span>EventInit</span> { | |||
|
|||
<li><p>If <var>current</var> is null, then return.</p></li> | |||
|
|||
<li><p>If there is no <span data-x="transient activation">transient user activation</span> in | |||
<var>current</var>'s <span>relevant global object</span> and is not triggered by invoking | |||
<code data-x="dom-focus">focus()</code> method on a <span data-x="concept-tree-child">child</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be done differently. We can't rely directly on a public method. That method manipulates some state. That state in turn is something we could rely on.
focus-without-user-activation
is a new feature policy that can be used to block programmatic focus changes that are not triggered through user activation (explainer).The motivation behind this feature policy is to provide better security for websites that embed third party contexts.
This change makes modifications to the following focus API:
autofocus
element.focus(options)
window.focus()
The WHATWG resolved to add a new feature policy,
focus-without-user-activation
, to control whether third-party iframes can take focus programmatically. (w3c/webappsec-permissions-policy#273 (comment))The original PR contains all prior discussions regarding the feature policy. However, since I don't have editor access to it, I've created this new PR.
focus-without-user-activation
feature policy mozilla/standards-positions#1080focus-without-user-activation
feature policy WebKit/standards-positions#406focus-without-user-activation
permissions policy mdn/content#37532(See WHATWG Working Mode: Changes for more details.)
/acknowledgements.html ( diff )
/infrastructure.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/popover.html ( diff )