From 879b42943b14ceb388ab0a833c548947586dc291 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sun, 3 Nov 2019 12:00:01 +0100 Subject: [PATCH] fix: cannot access nativeTheme via electron.remote --- lib/browser/api/module-keys.js | 1 + spec/api-remote-spec.js | 8 ++++---- spec/static/main.js | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/browser/api/module-keys.js b/lib/browser/api/module-keys.js index fca9e65b5fdd2..b7c617ff758e4 100644 --- a/lib/browser/api/module-keys.js +++ b/lib/browser/api/module-keys.js @@ -21,6 +21,7 @@ module.exports = [ { name: 'inAppPurchase' }, { name: 'Menu' }, { name: 'MenuItem' }, + { name: 'nativeTheme' }, { name: 'net' }, { name: 'netLog' }, { name: 'Notification' }, diff --git a/spec/api-remote-spec.js b/spec/api-remote-spec.js index 25ab18f76f0dc..b45c419a2f9c2 100644 --- a/spec/api-remote-spec.js +++ b/spec/api-remote-spec.js @@ -155,10 +155,10 @@ ifdescribe(features.isRemoteModuleEnabled())('remote module', () => { }) describe('remote modules', () => { - it('includes browser process modules as properties', () => { - expect(remote.app.getPath).to.be.a('function') - expect(remote.webContents.getFocusedWebContents).to.be.a('function') - expect(remote.clipboard.readText).to.be.a('function') + it('includes browser process modules as properties', async () => { + const mainModules = await ipcRenderer.invoke('get-modules') + const remoteModules = mainModules.filter(name => remote[name]) + expect(remoteModules).to.be.deep.equal(mainModules) }) it('returns toString() of original function via toString()', () => { diff --git a/spec/static/main.js b/spec/static/main.js index 624c0a8404ff1..53fef70e5af37 100644 --- a/spec/static/main.js +++ b/spec/static/main.js @@ -42,6 +42,7 @@ ipcMain.on('message', function (event, ...args) { event.sender.send('message', ...args) }) +ipcMain.handle('get-modules', () => Object.keys(electron)) ipcMain.handle('get-temp-dir', () => app.getPath('temp')) ipcMain.handle('ping', () => null)