fix: media key globalShortcuts on macOS (#30552)
This commit is contained in:
parent
04aafcc5ef
commit
db8644ee7a
3 changed files with 82 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import { globalShortcut } from 'electron/main';
|
||||
import { globalShortcut, BrowserWindow } from 'electron/main';
|
||||
import { ifdescribe } from './spec-helpers';
|
||||
|
||||
ifdescribe(process.platform !== 'win32')('globalShortcut module', () => {
|
||||
|
@ -55,4 +55,20 @@ ifdescribe(process.platform !== 'win32')('globalShortcut module', () => {
|
|||
|
||||
globalShortcut.unregisterAll();
|
||||
});
|
||||
|
||||
it('successfully registers and calls the callback for media keys', function (done) {
|
||||
let robotjs;
|
||||
try {
|
||||
robotjs = require('robotjs');
|
||||
} catch (err) {
|
||||
this.skip();
|
||||
}
|
||||
|
||||
globalShortcut.register('MediaPlayPause', () => done());
|
||||
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.loadURL('about:blank');
|
||||
|
||||
robotjs.keyTap('audio_play');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue