Browse Source

fix: cannot access nativeTheme via electron.remote (#20938)

Milan Burda 5 years ago
parent
commit
01e18c2fc3
3 changed files with 6 additions and 4 deletions
  1. 1 0
      lib/browser/api/module-keys.js
  2. 4 4
      spec/api-remote-spec.js
  3. 1 0
      spec/static/main.js

+ 1 - 0
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' },

+ 4 - 4
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()', () => {

+ 1 - 0
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)