tests: Fix Node.js shim for Node 21+ (webusb/emscripten)

Fixes #1648
Closes #1656
This commit is contained in:
Ingvar Stepanyan
2025-06-09 00:27:53 +01:00
committed by Tormod Volden
parent 15a7ebb4d4
commit 4b9cf1fb04
2 changed files with 7 additions and 6 deletions

View File

@@ -1 +1 @@
#define LIBUSB_NANO 11953
#define LIBUSB_NANO 11954

View File

@@ -5,8 +5,9 @@
const { WebUSB } = require('usb');
globalThis.navigator = {
usb: new WebUSB({
allowAllDevices: true
})
};
// Node.js 21 introduced a global `navigator` object, so assign an empty one only if it's not present yet.
globalThis.navigator ??= {};
navigator.usb = new WebUSB({
allowAllDevices: true
});