Intent to Prototype: WebHID in Extension Service Workers

Skip to first unread message

Jack Hsieh

Jun 22, 2022, 1:39:17 PM6/22/22

Contact emails,




Allows web developers to use WebHID API when responding to extension events by exposing WebHID API to Service Workers registered by browser extensions. This API will not yet be exposed to Service Workers registered by sites but the implementation experience gained by supporting the API for extensions will be valuable for such a future project.

Blink component



As Chrome Apps APIs chrome.hid will soon be deprecated, developers are encouraged to migrate to web apps or Chrome Extensions. For the Chrome Extension case, Manifest V3 deprecates the background page and requires developers to migrate to service workers. As a result, it is required to support WebHID in Extension Service Workers.


Interoperability and Compatibility

Gecko: No signal, we have asked for a position on WebHID in extensions (

WebKit: No signal, opposed to the Web Serial API in general.

Web developers: Extension developers previously used WebHID and other device APIs from the background page and have requested that it continues to be available after migrating to Manifest V3.

Other signals: Extension team approves of exposing these APIs to extension service workers. (, internal-only)

WebView application risks

N/A. WebHID isn’t available on Android.



Is this feature fully tested by web-platform-tests?


Flag name


Requires code in //chrome?


Tracking bug

Launch bug

Estimated milestones


Link to entry on the Chrome Platform Status

Jack Hsieh

Jun 30, 2022, 1:05:40 PM6/30/22
to blink-dev, Jack Hsieh, Tarek ElBahnasawy
+ telbahnasawy (device-api team TPM)

Stanislav Titenko

Oct 14, 2022, 12:56:46 PM10/14/22
to blink-dev,,

Is there any prototype for this? I'm trying to connect from my manifest v3 extension to HID device. Currently just trying to send message from popup in response for user action, and handle this message in service worker, creating request for devices.
Unfortunately for now I only have `Failed to execute 'requestDevice' on 'HID': Script context has shut down.` error :\

Would appreciate any help on this

Jack Hsieh

Oct 14, 2022, 1:50:37 PM10/14/22
to Stanislav Titenko, blink-dev,
Hi Stanislav,

You can try to use the prototype in, this is a very simple and raw prototype but it should work for demo purposes.

Please be aware HID access on service workers is required explicitly enabling chrome://flags#enable-web-hid-on-extension-service-worker to have this feature (by default it is disabled).

If you still have an issue then please open a bug in against component blink>HID. I will follow up further there for you.

Best Regards

Stanislav Titenko

Oct 17, 2022, 12:49:27 PM10/17/22
to blink-dev,,, Stanislav Titenko
Cool, thanks! Will try

Jack Hsieh

Oct 17, 2022, 1:58:14 PM10/17/22
to Stanislav Titenko, blink-dev,
Hi Stanislav,

Additionally, regarding your error of "`Failed to execute 'requestDevice' on 'HID': Script context has shut down.` error :\"
I assumed you hit this by invoking navigator.hid.requestDevice(...) in service worker context. The requestDevice API isn't available to service workers context per design.
You could refer to the sample I provided earlier to know how to grant permission to HID devices for the extension with service workers.

FYI, thank you for reporting this issue and we found we shouldn't even reveal requestDevice API in service worker context so we have to fix this. Hope with this fix it will be more clear requestDevice isn't available in service worker context.

Best Regards

Reply all
Reply to author
0 new messages