Re: [vibration] Require user activation for navigator.vibrate (#29)

Thanks @johannhof for confirming Chrome's implementation choice.

Per [APIs gated by user activation](https://html.spec.whatwg.org/multipage/interaction.html#user-activation-gated-apis) and as suggested by folks on this issue, we have two alternatives: transient activation and sticky activation. Given the major implementation has chosen sticky activation, it is reasonable to recommend that in the spec unless good reasons surface not to.

Proposed spec change:

Inject the following step as the first one in https://w3c.github.io/vibration/#dfn-perform-vibration:

>If [this](https://webidl.spec.whatwg.org/#this)'s [relevant global object](https://html.spec.whatwg.org/#concept-relevant-global) does not have [sticky activation](https://html.spec.whatwg.org/#sticky-activation), return false and terminate these steps.

Note that there's already a step in this place that allows implementations to bail out for whatever reason which makes also existing sticky activation gated implementations compliant:

>An implementation MAY return false and terminate these steps.

(I'm not a fan of such a catchall "may" but that is the escape hatch we put there long time ago after some debate IIRC.)

@johannhof looks good? I'll put up a PR if good.

<details>
  <summary>FTR: Web APIs that reference either transient activation or sticky activation.</summary>

- [Transient activation](https://dontcallmedom.github.io/webdex/t.html#Transient%20activation%40%40html%25%25dfn): Referenced in [Fullscreen API](https://fullscreen.spec.whatwg.org/), [The Storage Access API](https://privacycg.github.io/storage-access/), [The Capture-Handle Actions Mechanism](https://w3c.github.io/mediacapture-handle/actions/), [Viewport Capture](https://w3c.github.io/mediacapture-viewport/), [Multi-Screen Window Placement](https://w3c.github.io/window-placement/), [Capability Delegation](https://wicg.github.io/capability-delegation/spec.html), [Close Watcher API](https://wicg.github.io/close-watcher/), [Compute Pressure 1](https://wicg.github.io/compute-pressure/), [EyeDropper API](https://wicg.github.io/eyedropper-api/), [File System Access](https://wicg.github.io/file-system-access/), [Idle Detection API](https://wicg.github.io/idle-detection/), [Local Font Access API](https://wicg.github.io/local-font-access/), [Text Fragments](https://wicg.github.io/scroll-to-text-fragment/), [Web Serial API](https://wicg.github.io/serial/), [WebHID API](https://wicg.github.io/webhid/), [WebUSB API](https://wicg.github.io/webusb/), [Audio Output Devices API](https://w3c.github.io/mediacapture-output/), [Clipboard API and events](https://w3c.github.io/clipboard-apis/), [Payment Request API](https://w3c.github.io/payment-request/), [Picture-in-Picture](https://w3c.github.io/picture-in-picture/), [Pointer Lock 2.0](https://w3c.github.io/pointerlock/), [Presentation API](https://w3c.github.io/presentation-api/), [Remote Playback API](https://w3c.github.io/remote-playback/), [Screen Capture](https://w3c.github.io/mediacapture-screen-share/), [Secure Payment Confirmation](https://w3c.github.io/secure-payment-confirmation/), [Web Share API](https://w3c.github.io/web-share/), [WebXR Device API](https://immersive-web.github.io/webxr/)
- [Sticky activation](https://dontcallmedom.github.io/webdex/s.html#Sticky%20activation%40%40html%25%25dfn): Referenced in [Autoplay Policy Detection](https://w3c.github.io/autoplay/), [VirtualKeyboard API](https://w3c.github.io/virtual-keyboard/), [Web Audio API](https://webaudio.github.io/web-audio-api/)
</summary>


-- 
GitHub Notification of comment by anssiko
Please view or discuss this issue at https://github.com/w3c/vibration/issues/29#issuecomment-1129981670 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 18 May 2022 12:56:05 UTC