fix: navigator.bluetooth.requestDevice (#27902)
* fix: navigator.bluetooth.requestDevice * cleanup lint and add test * update bluetooth test to handle no bluetooth adapter available * update bluetooth test to handle bluetooth permission denied
This commit is contained in:
parent
bd940b2904
commit
d57fd6cef0
9 changed files with 269 additions and 2 deletions
|
@ -1613,3 +1613,24 @@ ifdescribe((process.platform !== 'linux' || app.isUnityRunning()))('navigator.se
|
|||
expect(waitForBadgeCount(0)).to.eventually.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('navigator.bluetooth', () => {
|
||||
let w: BrowserWindow;
|
||||
before(async () => {
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
enableBlinkFeatures: 'WebBluetooth'
|
||||
}
|
||||
});
|
||||
await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
|
||||
});
|
||||
|
||||
after(closeAllWindows);
|
||||
|
||||
it('can request bluetooth devices', async () => {
|
||||
const bluetooth = await w.webContents.executeJavaScript(`
|
||||
navigator.bluetooth.requestDevice({ acceptAllDevices: true}).then(device => "Found a device!").catch(err => err.message);`, true);
|
||||
expect(bluetooth).to.be.oneOf(['Found a device!', 'Bluetooth adapter not available.', 'User cancelled the requestDevice() chooser.']);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue