An MDN page that lists all the web APIs gated by user activation
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.
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?
Yes, that is pretty much what I had in mind.
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.
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.
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.
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.
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).
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! 👍