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

Clarify prerendering documents cannot have focus. #55

Closed
Clqsin45 opened this issue Mar 16, 2021 · 7 comments
Closed

Clarify prerendering documents cannot have focus. #55

Clqsin45 opened this issue Mar 16, 2021 · 7 comments

Comments

@Clqsin45
Copy link
Contributor

Some APIs's specs[1][2] require documents to have focus[3] when using these APIs. So for prerendering, maybe we should clarify that prerendering documents cannot be focused and executing document.hasFocus() on these pages always returns false[4].

Maybe we should also clarify that prerendering browsing context cannot be active?

cc: @nhiroki

[1] https://w3c.github.io/clipboard-apis/#privacy-async
[2] https://www.w3.org/TR/pointerlock/#extensions-to-the-element-interface
[3] https://html.spec.whatwg.org/multipage/interaction.html#focus
[4] https://chromium-review.googlesource.com/c/chromium/src/+/2743865/5..9/third_party/blink/web_tests/wpt_internal/prerender/resources/document-has-focus.html#b17

@jeremyroman
Copy link
Collaborator

@a4sriniv might have thoughts about focus in prerendering/portal contexts

@domenic
Copy link
Collaborator

domenic commented Mar 16, 2021

We only very recently added the concept of system focus to the HTML spec. Although, we didn't hook it up to document.hasFocus(), hmm. We did, I just forgot.

My take, based on previous discussions, is that prerendering browsing contexts can have their contents focused (e.g., they can have a nontrivial document.activeElement; someElement.focus() works; autofocus="" works). But, they cannot have system focus.

@a4sriniv
Copy link
Contributor

I agree with @domenic, prerendering browsing contexts should behave the same as portals do currently (they don't have system focus and only get it on activation). See WICG/portals#257 for the portals discussion on focus.

@Clqsin45
Copy link
Contributor Author

Thank you for discussing!
I've added wpt-internal tests.

@mfalken
Copy link
Collaborator

mfalken commented Apr 21, 2021

Thanks @Clqsin45 for raising this. We could probably extend the section on Activation-gated APIs to also cover System Focus-gated APIs:
https://jeremyroman.github.io/alternate-loading-modes/#activation-gated

@mfalken
Copy link
Collaborator

mfalken commented Apr 27, 2021

It appears some APIs like Picture-In-Picture may also be gated on visibility state as well as user activation (e.g., https://w3c.github.io/picture-in-picture/#auto-pip can be used without user activation if visibility state changes??), so we may also add visibility state to this section. Filed related #59

mfalken added a commit to mfalken/alternate-loading-modes that referenced this issue May 15, 2021
This expands "Activated-Gated APIs" to cover other reasons that an API
can be implicitly restricted, namely, if it requires system focus or
page visiblity.

It also clarifies that prerendering browsing contexts never have system
focus or page visibility, as per discussion in WICG#59 and WICG#55.
mfalken added a commit to mfalken/alternate-loading-modes that referenced this issue May 15, 2021
This expands "Activated-Gated APIs" to cover other reasons that an API
can be implicitly restricted, namely, if it requires system focus or
page visibility.

It also clarifies that prerendering browsing contexts never have system
focus or page visibility, as per discussion in WICG#59 and WICG#55.
domenic pushed a commit that referenced this issue May 19, 2021
This expands "Activated-Gated APIs" to cover other reasons that an API
can be implicitly restricted, namely, if it requires system focus or
page visibility.

It also clarifies that prerendering browsing contexts never have system
focus or page visibility, as per discussion in #59 and #55.
@mfalken
Copy link
Collaborator

mfalken commented Jun 2, 2021

This is fixed in #62 and the Clipboard case specifically in #69. Thanks @Clqsin45 for raising this!

@mfalken mfalken closed this as completed Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants