Open Bug 2007071 Opened 9 months ago Updated 8 months ago

Align MIDI errors with the web-midi-api spec. Deprecated `SecurityError` and `InvalidAccessError` in favor of `NotAllowedError`

Categories

(Core :: DOM: Device Interfaces, defect, P3)

defect

Tracking

()

ASSIGNED

People

(Reporter: nikelborm, Assigned: nikelborm, NeedInfo)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 3 obsolete files)

(I already made the necessary changes to the Firefox codebase, just currently figuring out how to properly submit the patch)

InvalidAccessError replaced by NotAllowedError:

The change in spec: WebAudio/web-midi-api@3795f22
According PR: WebAudio/web-midi-api#278
MDN update PR: mdn/content#42334

Affected APIs

  1. .send method of output MIDI ports
  2. .open method of MIDI ports

Reasoning

According to Web IDL spec on InvalidAccessError:

Deprecated. Use TypeError for invalid arguments, "NotSupportedError" DOMException for unsupported operations, and "NotAllowedError" DOMException for denied requests instead.

Previously, while trying to open MIDIPort, "InvalidAccessError" DOMException was thrown when...

the device is unavailable (e.g., is already in use by another process and cannot be opened, or is disconnected)

In this case, I believe NotAllowedError fits well, according to its Web IDL spec description:

The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Security and permissions reasons are only a subset of the appropriate causes, according to this definition. An attempt to open the port can fail. Somebody's exclusive lock on the port, or the port being disconnected, is the current context driving the platform's decision not to allow the operation.

And in the context of forbidden .send calls:

If data is a System Exclusive message, and the MIDIAccess did not enable System Exclusive access, throw an InvalidAccessError exception.

NotAllowedError fits even better, because it fits an explicitly defined subset of permission errors.

SecurityError replaced by NotAllowedError:

The change in spec: WebAudio/web-midi-api@b7806b8
According PR: WebAudio/web-midi-api#267
MDN update PR: mdn/content#41956

Affected APIs

  1. navigator.requestMIDIAccess method

Reasoning

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.

Blocks: webmidi

InvalidAccessError replaced by NotAllowedError:

The change in spec: WebAudio/web-midi-api@3795f22
According PR: WebAudio/web-midi-api#278
MDN update PR: mdn/content#42334

Affected APIs

  1. .send method of output MIDI ports
  2. .open method of MIDI ports

Reasoning

According to Web IDL spec on InvalidAccessError:

Deprecated. Use TypeError for invalid arguments, "NotSupportedError" DOMException for unsupported operations, and "NotAllowedError" DOMException for denied requests instead.

Previously, while trying to open MIDIPort, "InvalidAccessError" DOMException was thrown when...

the device is unavailable (e.g., is already in use by another process and cannot be opened, or is disconnected)

In this case, I believe NotAllowedError fits well, according to its Web IDL spec description:

The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Security and permissions reasons are only a subset of the appropriate causes, according to this definition. An attempt to open the port can fail. Somebody's exclusive lock on the port, or the port being disconnected, is the current context driving the platform's decision not to allow the operation.

And in the context of forbidden .send calls:

If data is a System Exclusive message, and the MIDIAccess did not enable System Exclusive access, throw an InvalidAccessError exception.

NotAllowedError fits even better, because it fits an explicitly defined subset of permission errors.

SecurityError replaced by NotAllowedError:

The change in spec: WebAudio/web-midi-api@b7806b8
According PR: WebAudio/web-midi-api#267
MDN update PR: mdn/content#41956

Affected APIs

  1. navigator.requestMIDIAccess method

Reasoning

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.

Attachment #9534151 - Attachment description: Align MIDI errors with the web-midi-api spec. Deprecated `SecurityError` and `InvalidAccessError` in favor of `NotAllowedError` → Bug 2007071 - Align MIDI errors with the web-midi-api spec. Deprecated `SecurityError` and `InvalidAccessError` in favor of `NotAllowedError`
Assignee: nobody → evadev
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Sorry for the messy history of this bug. I'm new to this platform 👉👈 🥺

Attachment #9534287 - Attachment description: 0001-Bug-2007071-Align-MIDI-errors-with-the-web-midi-api-.patch → [PATCH] Bug 2007071 - Align MIDI errors with the web-midi-api spec. Deprecated `SecurityError` and `InvalidAccessError` in favor of `NotAllowedError`
Attachment #9534151 - Attachment description: Bug 2007071 - Align MIDI errors with the web-midi-api spec. Deprecated `SecurityError` and `InvalidAccessError` in favor of `NotAllowedError` → Bug 2007071 - Align MIDI errors with the web-midi-api spec. Deprecated `SecurityError` and `InvalidAccessError` in favor of `NotAllowedError` r=gsvelto

= InvalidAccessError replaced by NotAllowedError:

The change in spec: WebAudio/web-midi-api@3795f22
According PR: WebAudio/web-midi-api#278
MDN update PR: mdn/content#42334

== Affected APIs

  1. .send method of output MIDI ports
  2. .open method of MIDI ports

= SecurityError replaced by NotAllowedError:

The change in spec: WebAudio/web-midi-api@b7806b8
According PR: WebAudio/web-midi-api#267
MDN update PR: mdn/content#41956

== Affected APIs

  1. navigator.requestMIDIAccess method
Attachment #9534151 - Attachment is obsolete: true
Attachment #9534287 - Attachment is obsolete: true

The severity field is not set for this bug.
:cmartin, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(cmartin)
Severity: -- → S3
Flags: needinfo?(cmartin) → needinfo?(gsvelto)
Priority: -- → P3
Flags: needinfo?(padenot)
Attachment #9534889 - Attachment description: Bug 2007071 - Align MIDI errors with the web-midi-api spec. Deprecated `SecurityError` and `InvalidAccessError` in favor of `NotAllowedError` r=gsvelto → Bug 2007071 - Align MIDI errors with the web-midi-api spec. Deprecated `SecurityError` and `InvalidAccessError` in favor of `NotAllowedError` r=padenot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: