mirror of
https://github.com/servo/servo.git
synced 2025-07-12 01:43:43 +01:00
15 lines
No EOL
441 B
JavaScript
15 lines
No EOL
441 B
JavaScript
importScripts('/webusb/resources/usb-helpers.js');
|
|
'use strict';
|
|
|
|
onmessage = messageEvent => {
|
|
if (messageEvent.data.type === 'Ready') {
|
|
navigator.usb.addEventListener('connect', connectEvent => {
|
|
connectEvent.device.open().then(() => {
|
|
postMessage({ type: 'Success' });
|
|
}).catch(error => {
|
|
postMessage({ type: `FAIL: open rejected ${error}` });
|
|
});
|
|
});
|
|
postMessage({ type: 'Ready' });
|
|
}
|
|
}; |