project icon indicating copy to clipboard operation
project copied to clipboard

An MDN page that lists all the web APIs gated by user activation

Open simevidas opened this issue 4 years ago • 2 comments

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

Web developers might find it useful if there was a page on MDN that lists all the web APIs that can only be called in response to a user action (e.g., a button press). One such API is navigator.share(). There are probably some differences between browsers, so that could be documented as well.

simevidas avatar Dec 31 '21 05:12 simevidas

Is it something like https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts/features_restricted_to_secure_contexts#secure_context_restrictions_that_vary_by_browser but for user-gesture requirement?

myakura avatar Jan 05 '22 09:01 myakura

Yes, that is pretty much what I had in mind.

simevidas avatar Jan 05 '22 19:01 simevidas

Thanks for your issue! I created a PR https://github.com/mdn/content/pull/20358 and it would be great if it could be expanded if any of you have additional information.

Elchi3 avatar Sep 06 '22 18:09 Elchi3

This is great! The next step would be to add information about differences between browsers. For example, Clipboard.writeText() requires activation in Safari and Firefox, but not in Chromium-based browsers (see https://github.com/w3c/clipboard-apis/issues/182). Ideally, browser vendors themselves would document these details on MDN.

simevidas avatar Sep 06 '22 20:09 simevidas

I added Clipboard.writeText() to the PR and will ask around if anyone (especially browser vendor folks) have more to share.

Meanwhile it was also proposed we update each affected API page to mention user activation. I think it is a good idea.

Elchi3 avatar Sep 07 '22 09:09 Elchi3

Maybe a note card at the top, like the one for secure context? I really hope that this card is stored in a single place and dynamically inserted to the page based on a flag, and not manually copy-pasted to each page.

Screenshot 2022-09-07 at 13 27 31

simevidas avatar Sep 07 '22 11:09 simevidas

Yes, I think some consistent note card or banner would be good.

It's not yet based on data unfortunately. The browser-compat-data (BCD) project is thinking about adding secure context data, though, see https://github.com/openwebdocs/project/issues/102. A project to generate MDN banners from data is filed here: https://github.com/openwebdocs/project/issues/81 (for the "experimental" status for a start).

Elchi3 avatar Sep 07 '22 11:09 Elchi3

An MDN page listing the APIs was created in https://github.com/mdn/content/pull/20358 The API pages have been updated so they all mention user activation in https://github.com/mdn/content/pull/20435

Thanks again for this great suggestion! 👍

Elchi3 avatar Sep 22 '22 17:09 Elchi3