feat: support Web Serial & WebUSB blocklists (#46600)

This commit is contained in:
Shelley Vohr 2025-04-17 20:34:34 +02:00 committed by GitHub
parent 352a403efd
commit a29e1170b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 106 additions and 4 deletions

View file

@ -14,6 +14,12 @@ This document uses the following convention to categorize breaking changes:
## Planned Breaking API Changes (37.0)
### Behavior Changed: WebUSB and WebSerial Blocklist Support
[WebUSB](https://developer.mozilla.org/en-US/docs/Web/API/WebUSB_API) and [Web Serial](https://developer.mozilla.org/en-US/docs/Web/API/Web_Serial_API) now support the [WebUSB Blocklist](https://wicg.github.io/webusb/#blocklist) and [Web Serial Blocklist](https://wicg.github.io/serial/#blocklist) used by Chromium and outlined in their respective specifications.
To disable these, users can pass `disable-usb-blocklist` and `disable-serial-blocklist` as command line flags.
### Removed: `null` value for `session` property in `ProtocolResponse`
This deprecated feature has been removed.

View file

@ -57,7 +57,7 @@ the WebHID API:
### Blocklist
By default Electron employs the same [blocklist](https://github.com/WICG/webhid/blob/main/blocklist.txt)
By default Electron employs the same [blocklist](https://wicg.github.io/webhid/#blocklist)
used by Chromium. If you wish to override this behavior, you can do so by
setting the `disable-hid-blocklist` flag:
@ -104,6 +104,16 @@ There are several additional APIs for working with the Web Serial API:
* [`ses.setPermissionCheckHandler(handler)`](../api/session.md#sessetpermissioncheckhandlerhandler)
can be used to disable serial access for specific origins.
### Blocklist
By default Electron employs the same [blocklist](https://wicg.github.io/serial/#blocklist)
used by Chromium. If you wish to override this behavior, you can do so by
setting the `disable-serial-blocklist` flag:
```js
app.commandLine.appendSwitch('disable-serial-blocklist')
```
### Example
This example demonstrates an Electron application that automatically selects
@ -145,6 +155,16 @@ Electron provides several APIs for working with the WebUSB API:
* [`ses.setUSBProtectedClassesHandler](../api/session.md#sessetusbprotectedclasseshandlerhandler)
can be used to allow usage of [protected USB classes](https://wicg.github.io/webusb/#usbinterface-interface) that are not available by default.
### Blocklist
By default Electron employs the same [blocklist](https://wicg.github.io/webusb/#blocklist)
used by Chromium. If you wish to override this behavior, you can do so by
setting the `disable-usb-blocklist` flag:
```js
app.commandLine.appendSwitch('disable-usb-blocklist')
```
### Example
This example demonstrates an Electron application that automatically selects