web-platform-tests / interop

web-platform-tests Interop project
https://wpt.fyi/interop
317 stars 27 forks source link

User activation (2024 edition) #428

Closed AshleyScirra closed 9 months ago

AshleyScirra commented 1 year ago

Description

Please note this is a re-submission of an Interop 2023 proposal that was not accepted last time around. There is an existing discussion on the original issue #142.

There was a long discussion on the prior issue. I will attempt to summarize it. The modern specification refers to "User activation" which is used to restrict certain actions that require user input, such as entering fullscreen mode. This involves two flags and a short timeout, and can be accessed via the navigator.userActivation JavaScript API.

Prior to that, the old user activation model was essentially that the API had to be called synchronously within an allowed event handler (or possibly some other non-standard restrictions). This causes problems using things like async code, where doing anything async means the call is no longer made synchronously inside the event handler, and so is blocked. The modern user activation rules solve this problem, providing the call is made in a reasonably timely fashion.

It appears that some web APIs use the modern user activation system, but some older web APIs use the old synchronous model (or some other restrictions). This makes the platform inconsistent, for example meaning developers can use async code with certain APIs but not others, and unnecessarily restricts the ability to use some older APIs.

This proposal is to align all web APIs that have any user activation requirement to use the modern model, and to support the navigator.userActivation API so web content can programmatically understand its own restrictions.

Possibly affected APIs

This is a non-exhaustive list of potentially affected APIs determined by basically listing every API mentioned in the original issue #142. They may all have a different status and some APIs may be affected but not listed here.

Specification

https://html.spec.whatwg.org/multipage/interaction.html#tracking-user-activation

Open Issues

Not aware of any

Tests

At a minimum these WPT tests: https://wpt.fyi/results/html/user-activation but there may need to be tests for each affected API as well.

Current Implementations

Standards Positions

AFAIK all major browsers implement modern user activation at least partially.

Browser bug reports

No response

Developer discussions

Extensive prior discussion at #142. This comment also mentioned:

User gestures is a P2 for Google's closure library

Polls & Surveys

No response

Existing Usage

No response

Workarounds

It's usually possible to work with the old model by deferring actions until the next user activation, or asking the user for a user activation, e.g. showing a dialog to collect a click.

Accessibility Impact

Web apps may be easier to use if it does not have to revert to workarounds such as showing a dialog and requiring another action to complete a task.

Privacy Impact

No response

Other

No response

mustaqahmed commented 1 year ago

Thanks @AshleyScirra. This is a very timely proposal, specially because the API to query User Activation state (which significantly eases testing) seems to be in "shipped" or "almost-shipped" state in all major browsers (Blink, Mozilla, WebKit).

I am expecting to propose a list of WPTs as a possible Interop 2024 goal here, ETA in a week.

marcoscaceres commented 1 year ago

Hopefully this gets picked. I'm sitting on a bunch of tests fixes that I haven't been able to get anyone to review on the WebKit side: https://github.com/WebKit/WebKit/pull/14229

Independently, @mustaqahmed, maybe I can bring the over to WPT and you can help review them so we can get them landed? (then I can import them into WebKit that way)

mustaqahmed commented 1 year ago

@marcoscaceres It's great to see your commitment to improve the WPTs here. Please go ahead with a PR to look into this together.

mustaqahmed commented 1 year ago

A possible list of WPTs for Interop 2024 could be all non-tentative tests in html/user-activation/ (dashboard).

zcorpan commented 1 year ago

I checked Blink and WebKit as current implementations, per https://caniuse.com/mdn-api_useractivation

Intent to Prototype and Ship for Gecko: https://groups.google.com/a/mozilla.org/g/dev-platform/c/YpjKfr4MQIE (cc @canadahonk)

foolip commented 9 months ago

Thank you for proposing user activation for inclusion in Interop 2024.

We wanted to let you know that this proposal was not selected to be part of Interop this year.

This is because we got many more proposals than we could include in this year's project. Note that individual vendors may nevertheless choose to advance work in this area during the forthcoming year. We would welcome this proposal being resubmitted again next year if necessary.

For an overview of our process, see proposal selection. Thank you again for contributing to Interop 2024!

Posted on behalf of the Interop team.