WebAudio / web-midi-api

The Web MIDI API, developed by the W3C Audio WG
http://webaudio.github.io/web-midi-api/
Other
323 stars 49 forks source link

Rejecting the MIDI permission should use NotAllowedError, not SecurityError #261

Closed rebane2001 closed 3 weeks ago

rebane2001 commented 4 months ago

https://webaudio.github.io/web-midi-api/#dom-navigator-requestmidiaccess

At the moment a SecurityError (The operation is insecure.) is thrown when a user rejects a permissions prompt for MIDI access requested through the requestMIDIAccess() method, but it would make more sense to use a NotAllowedError (The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.) for this.

mjwilson-google commented 4 months ago

Thank you for the links, and yes I think you are correct. My guess is that NotAllowedError wasn't available when that part of the spec was first written.

One possible risk of changing this is if developers are relying on checking the specific error type to find out if the permission has been denied.

It's clear from the description of the error types that NotAllowedError is the best fit, so I'll set this as ready for editing.