|
@@ -9,6 +9,9 @@ import split = require('split')
|
|
|
import { app, BrowserWindow, Menu } from 'electron'
|
|
|
import { emittedOnce } from './events-helpers';
|
|
|
import { closeWindow } from './window-helpers';
|
|
|
+import { ifdescribe } from './spec-helpers';
|
|
|
+
|
|
|
+const features = process.electronBinding('features')
|
|
|
|
|
|
const { expect } = chai
|
|
|
|
|
@@ -405,103 +408,107 @@ describe('app module', () => {
|
|
|
expect(webContents).to.equal(w.webContents)
|
|
|
})
|
|
|
|
|
|
- it('should emit desktop-capturer-get-sources event when desktopCapturer.getSources() is invoked', async () => {
|
|
|
- w = new BrowserWindow({
|
|
|
- show: false,
|
|
|
- webPreferences: {
|
|
|
- nodeIntegration: true
|
|
|
- }
|
|
|
- })
|
|
|
- await w.loadURL('about:blank')
|
|
|
-
|
|
|
- const promise = emittedOnce(app, 'desktop-capturer-get-sources')
|
|
|
- w.webContents.executeJavaScript(`require('electron').desktopCapturer.getSources({ types: ['screen'] }, () => {})`)
|
|
|
+ ifdescribe(features.isDesktopCapturerEnabled())('desktopCapturer module filtering', () => {
|
|
|
+ it('should emit desktop-capturer-get-sources event when desktopCapturer.getSources() is invoked', async () => {
|
|
|
+ w = new BrowserWindow({
|
|
|
+ show: false,
|
|
|
+ webPreferences: {
|
|
|
+ nodeIntegration: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ await w.loadURL('about:blank')
|
|
|
|
|
|
- const [, webContents] = await promise
|
|
|
- expect(webContents).to.equal(w.webContents)
|
|
|
- })
|
|
|
+ const promise = emittedOnce(app, 'desktop-capturer-get-sources')
|
|
|
+ w.webContents.executeJavaScript(`require('electron').desktopCapturer.getSources({ types: ['screen'] }, () => {})`)
|
|
|
|
|
|
- it('should emit remote-require event when remote.require() is invoked', async () => {
|
|
|
- w = new BrowserWindow({
|
|
|
- show: false,
|
|
|
- webPreferences: {
|
|
|
- nodeIntegration: true
|
|
|
- }
|
|
|
+ const [, webContents] = await promise
|
|
|
+ expect(webContents).to.equal(w.webContents)
|
|
|
})
|
|
|
- await w.loadURL('about:blank')
|
|
|
+ })
|
|
|
|
|
|
- const promise = emittedOnce(app, 'remote-require')
|
|
|
- w.webContents.executeJavaScript(`require('electron').remote.require('test')`)
|
|
|
+ describe('remote module filtering', () => {
|
|
|
+ it('should emit remote-require event when remote.require() is invoked', async () => {
|
|
|
+ w = new BrowserWindow({
|
|
|
+ show: false,
|
|
|
+ webPreferences: {
|
|
|
+ nodeIntegration: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ await w.loadURL('about:blank')
|
|
|
|
|
|
- const [, webContents, moduleName] = await promise
|
|
|
- expect(webContents).to.equal(w.webContents)
|
|
|
- expect(moduleName).to.equal('test')
|
|
|
- })
|
|
|
+ const promise = emittedOnce(app, 'remote-require')
|
|
|
+ w.webContents.executeJavaScript(`require('electron').remote.require('test')`)
|
|
|
|
|
|
- it('should emit remote-get-global event when remote.getGlobal() is invoked', async () => {
|
|
|
- w = new BrowserWindow({
|
|
|
- show: false,
|
|
|
- webPreferences: {
|
|
|
- nodeIntegration: true
|
|
|
- }
|
|
|
+ const [, webContents, moduleName] = await promise
|
|
|
+ expect(webContents).to.equal(w.webContents)
|
|
|
+ expect(moduleName).to.equal('test')
|
|
|
})
|
|
|
- await w.loadURL('about:blank')
|
|
|
|
|
|
- const promise = emittedOnce(app, 'remote-get-global')
|
|
|
- w.webContents.executeJavaScript(`require('electron').remote.getGlobal('test')`)
|
|
|
+ it('should emit remote-get-global event when remote.getGlobal() is invoked', async () => {
|
|
|
+ w = new BrowserWindow({
|
|
|
+ show: false,
|
|
|
+ webPreferences: {
|
|
|
+ nodeIntegration: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ await w.loadURL('about:blank')
|
|
|
|
|
|
- const [, webContents, globalName] = await promise
|
|
|
- expect(webContents).to.equal(w.webContents)
|
|
|
- expect(globalName).to.equal('test')
|
|
|
- })
|
|
|
+ const promise = emittedOnce(app, 'remote-get-global')
|
|
|
+ w.webContents.executeJavaScript(`require('electron').remote.getGlobal('test')`)
|
|
|
|
|
|
- it('should emit remote-get-builtin event when remote.getBuiltin() is invoked', async () => {
|
|
|
- w = new BrowserWindow({
|
|
|
- show: false,
|
|
|
- webPreferences: {
|
|
|
- nodeIntegration: true
|
|
|
- }
|
|
|
+ const [, webContents, globalName] = await promise
|
|
|
+ expect(webContents).to.equal(w.webContents)
|
|
|
+ expect(globalName).to.equal('test')
|
|
|
})
|
|
|
- await w.loadURL('about:blank')
|
|
|
|
|
|
- const promise = emittedOnce(app, 'remote-get-builtin')
|
|
|
- w.webContents.executeJavaScript(`require('electron').remote.app`)
|
|
|
+ it('should emit remote-get-builtin event when remote.getBuiltin() is invoked', async () => {
|
|
|
+ w = new BrowserWindow({
|
|
|
+ show: false,
|
|
|
+ webPreferences: {
|
|
|
+ nodeIntegration: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ await w.loadURL('about:blank')
|
|
|
|
|
|
- const [, webContents, moduleName] = await promise
|
|
|
- expect(webContents).to.equal(w.webContents)
|
|
|
- expect(moduleName).to.equal('app')
|
|
|
- })
|
|
|
+ const promise = emittedOnce(app, 'remote-get-builtin')
|
|
|
+ w.webContents.executeJavaScript(`require('electron').remote.app`)
|
|
|
|
|
|
- it('should emit remote-get-current-window event when remote.getCurrentWindow() is invoked', async () => {
|
|
|
- w = new BrowserWindow({
|
|
|
- show: false,
|
|
|
- webPreferences: {
|
|
|
- nodeIntegration: true
|
|
|
- }
|
|
|
+ const [, webContents, moduleName] = await promise
|
|
|
+ expect(webContents).to.equal(w.webContents)
|
|
|
+ expect(moduleName).to.equal('app')
|
|
|
})
|
|
|
- await w.loadURL('about:blank')
|
|
|
|
|
|
- const promise = emittedOnce(app, 'remote-get-current-window')
|
|
|
- w.webContents.executeJavaScript(`require('electron').remote.getCurrentWindow()`)
|
|
|
+ it('should emit remote-get-current-window event when remote.getCurrentWindow() is invoked', async () => {
|
|
|
+ w = new BrowserWindow({
|
|
|
+ show: false,
|
|
|
+ webPreferences: {
|
|
|
+ nodeIntegration: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ await w.loadURL('about:blank')
|
|
|
|
|
|
- const [, webContents] = await promise
|
|
|
- expect(webContents).to.equal(w.webContents)
|
|
|
- })
|
|
|
+ const promise = emittedOnce(app, 'remote-get-current-window')
|
|
|
+ w.webContents.executeJavaScript(`require('electron').remote.getCurrentWindow()`)
|
|
|
|
|
|
- it('should emit remote-get-current-web-contents event when remote.getCurrentWebContents() is invoked', async () => {
|
|
|
- w = new BrowserWindow({
|
|
|
- show: false,
|
|
|
- webPreferences: {
|
|
|
- nodeIntegration: true
|
|
|
- }
|
|
|
+ const [, webContents] = await promise
|
|
|
+ expect(webContents).to.equal(w.webContents)
|
|
|
})
|
|
|
- await w.loadURL('about:blank')
|
|
|
|
|
|
- const promise = emittedOnce(app, 'remote-get-current-web-contents')
|
|
|
- w.webContents.executeJavaScript(`require('electron').remote.getCurrentWebContents()`)
|
|
|
+ it('should emit remote-get-current-web-contents event when remote.getCurrentWebContents() is invoked', async () => {
|
|
|
+ w = new BrowserWindow({
|
|
|
+ show: false,
|
|
|
+ webPreferences: {
|
|
|
+ nodeIntegration: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ await w.loadURL('about:blank')
|
|
|
+
|
|
|
+ const promise = emittedOnce(app, 'remote-get-current-web-contents')
|
|
|
+ w.webContents.executeJavaScript(`require('electron').remote.getCurrentWebContents()`)
|
|
|
|
|
|
- const [, webContents] = await promise
|
|
|
- expect(webContents).to.equal(w.webContents)
|
|
|
+ const [, webContents] = await promise
|
|
|
+ expect(webContents).to.equal(w.webContents)
|
|
|
+ })
|
|
|
})
|
|
|
})
|
|
|
|