fix: media key globalShortcuts on macOS (#30552)

This commit is contained in:
Shelley Vohr 2021-08-17 19:44:17 +02:00 committed by GitHub
parent 04aafcc5ef
commit db8644ee7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 82 additions and 1 deletions

View file

@ -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');
});
});