@@ -9,6 +9,9 @@ import split = require('split')
9
9
import { app , BrowserWindow , Menu } from 'electron'
10
10
import { emittedOnce } from './events-helpers' ;
11
11
import { closeWindow } from './window-helpers' ;
12
+ import { ifdescribe } from './spec-helpers' ;
13
+
14
+ const features = process . electronBinding ( 'features' )
12
15
13
16
const { expect } = chai
14
17
@@ -405,103 +408,107 @@ describe('app module', () => {
405
408
expect ( webContents ) . to . equal ( w . webContents )
406
409
} )
407
410
408
- it ( 'should emit desktop-capturer-get-sources event when desktopCapturer.getSources() is invoked' , async ( ) => {
409
- w = new BrowserWindow ( {
410
- show : false ,
411
- webPreferences : {
412
- nodeIntegration : true
413
- }
414
- } )
415
- await w . loadURL ( 'about:blank' )
416
-
417
- const promise = emittedOnce ( app , 'desktop-capturer-get-sources' )
418
- w . webContents . executeJavaScript ( `require('electron').desktopCapturer.getSources({ types: ['screen'] }, () => {})` )
411
+ ifdescribe ( features . isDesktopCapturerEnabled ( ) ) ( 'desktopCapturer module filtering' , ( ) => {
412
+ it ( 'should emit desktop-capturer-get-sources event when desktopCapturer.getSources() is invoked' , async ( ) => {
413
+ w = new BrowserWindow ( {
414
+ show : false ,
415
+ webPreferences : {
416
+ nodeIntegration : true
417
+ }
418
+ } )
419
+ await w . loadURL ( 'about:blank' )
419
420
420
- const [ , webContents ] = await promise
421
- expect ( webContents ) . to . equal ( w . webContents )
422
- } )
421
+ const promise = emittedOnce ( app , 'desktop-capturer-get-sources' )
422
+ w . webContents . executeJavaScript ( `require('electron').desktopCapturer.getSources({ types: ['screen'] }, () => {})` )
423
423
424
- it ( 'should emit remote-require event when remote.require() is invoked' , async ( ) => {
425
- w = new BrowserWindow ( {
426
- show : false ,
427
- webPreferences : {
428
- nodeIntegration : true
429
- }
424
+ const [ , webContents ] = await promise
425
+ expect ( webContents ) . to . equal ( w . webContents )
430
426
} )
431
- await w . loadURL ( 'about:blank' )
427
+ } )
432
428
433
- const promise = emittedOnce ( app , 'remote-require' )
434
- w . webContents . executeJavaScript ( `require('electron').remote.require('test')` )
429
+ describe ( 'remote module filtering' , ( ) => {
430
+ it ( 'should emit remote-require event when remote.require() is invoked' , async ( ) => {
431
+ w = new BrowserWindow ( {
432
+ show : false ,
433
+ webPreferences : {
434
+ nodeIntegration : true
435
+ }
436
+ } )
437
+ await w . loadURL ( 'about:blank' )
435
438
436
- const [ , webContents , moduleName ] = await promise
437
- expect ( webContents ) . to . equal ( w . webContents )
438
- expect ( moduleName ) . to . equal ( 'test' )
439
- } )
439
+ const promise = emittedOnce ( app , 'remote-require' )
440
+ w . webContents . executeJavaScript ( `require('electron').remote.require('test')` )
440
441
441
- it ( 'should emit remote-get-global event when remote.getGlobal() is invoked' , async ( ) => {
442
- w = new BrowserWindow ( {
443
- show : false ,
444
- webPreferences : {
445
- nodeIntegration : true
446
- }
442
+ const [ , webContents , moduleName ] = await promise
443
+ expect ( webContents ) . to . equal ( w . webContents )
444
+ expect ( moduleName ) . to . equal ( 'test' )
447
445
} )
448
- await w . loadURL ( 'about:blank' )
449
446
450
- const promise = emittedOnce ( app , 'remote-get-global' )
451
- w . webContents . executeJavaScript ( `require('electron').remote.getGlobal('test')` )
447
+ it ( 'should emit remote-get-global event when remote.getGlobal() is invoked' , async ( ) => {
448
+ w = new BrowserWindow ( {
449
+ show : false ,
450
+ webPreferences : {
451
+ nodeIntegration : true
452
+ }
453
+ } )
454
+ await w . loadURL ( 'about:blank' )
452
455
453
- const [ , webContents , globalName ] = await promise
454
- expect ( webContents ) . to . equal ( w . webContents )
455
- expect ( globalName ) . to . equal ( 'test' )
456
- } )
456
+ const promise = emittedOnce ( app , 'remote-get-global' )
457
+ w . webContents . executeJavaScript ( `require('electron').remote.getGlobal('test')` )
457
458
458
- it ( 'should emit remote-get-builtin event when remote.getBuiltin() is invoked' , async ( ) => {
459
- w = new BrowserWindow ( {
460
- show : false ,
461
- webPreferences : {
462
- nodeIntegration : true
463
- }
459
+ const [ , webContents , globalName ] = await promise
460
+ expect ( webContents ) . to . equal ( w . webContents )
461
+ expect ( globalName ) . to . equal ( 'test' )
464
462
} )
465
- await w . loadURL ( 'about:blank' )
466
463
467
- const promise = emittedOnce ( app , 'remote-get-builtin' )
468
- w . webContents . executeJavaScript ( `require('electron').remote.app` )
464
+ it ( 'should emit remote-get-builtin event when remote.getBuiltin() is invoked' , async ( ) => {
465
+ w = new BrowserWindow ( {
466
+ show : false ,
467
+ webPreferences : {
468
+ nodeIntegration : true
469
+ }
470
+ } )
471
+ await w . loadURL ( 'about:blank' )
469
472
470
- const [ , webContents , moduleName ] = await promise
471
- expect ( webContents ) . to . equal ( w . webContents )
472
- expect ( moduleName ) . to . equal ( 'app' )
473
- } )
473
+ const promise = emittedOnce ( app , 'remote-get-builtin' )
474
+ w . webContents . executeJavaScript ( `require('electron').remote.app` )
474
475
475
- it ( 'should emit remote-get-current-window event when remote.getCurrentWindow() is invoked' , async ( ) => {
476
- w = new BrowserWindow ( {
477
- show : false ,
478
- webPreferences : {
479
- nodeIntegration : true
480
- }
476
+ const [ , webContents , moduleName ] = await promise
477
+ expect ( webContents ) . to . equal ( w . webContents )
478
+ expect ( moduleName ) . to . equal ( 'app' )
481
479
} )
482
- await w . loadURL ( 'about:blank' )
483
480
484
- const promise = emittedOnce ( app , 'remote-get-current-window' )
485
- w . webContents . executeJavaScript ( `require('electron').remote.getCurrentWindow()` )
481
+ it ( 'should emit remote-get-current-window event when remote.getCurrentWindow() is invoked' , async ( ) => {
482
+ w = new BrowserWindow ( {
483
+ show : false ,
484
+ webPreferences : {
485
+ nodeIntegration : true
486
+ }
487
+ } )
488
+ await w . loadURL ( 'about:blank' )
486
489
487
- const [ , webContents ] = await promise
488
- expect ( webContents ) . to . equal ( w . webContents )
489
- } )
490
+ const promise = emittedOnce ( app , 'remote-get-current-window' )
491
+ w . webContents . executeJavaScript ( `require('electron').remote.getCurrentWindow()` )
490
492
491
- it ( 'should emit remote-get-current-web-contents event when remote.getCurrentWebContents() is invoked' , async ( ) => {
492
- w = new BrowserWindow ( {
493
- show : false ,
494
- webPreferences : {
495
- nodeIntegration : true
496
- }
493
+ const [ , webContents ] = await promise
494
+ expect ( webContents ) . to . equal ( w . webContents )
497
495
} )
498
- await w . loadURL ( 'about:blank' )
499
496
500
- const promise = emittedOnce ( app , 'remote-get-current-web-contents' )
501
- w . webContents . executeJavaScript ( `require('electron').remote.getCurrentWebContents()` )
497
+ it ( 'should emit remote-get-current-web-contents event when remote.getCurrentWebContents() is invoked' , async ( ) => {
498
+ w = new BrowserWindow ( {
499
+ show : false ,
500
+ webPreferences : {
501
+ nodeIntegration : true
502
+ }
503
+ } )
504
+ await w . loadURL ( 'about:blank' )
505
+
506
+ const promise = emittedOnce ( app , 'remote-get-current-web-contents' )
507
+ w . webContents . executeJavaScript ( `require('electron').remote.getCurrentWebContents()` )
502
508
503
- const [ , webContents ] = await promise
504
- expect ( webContents ) . to . equal ( w . webContents )
509
+ const [ , webContents ] = await promise
510
+ expect ( webContents ) . to . equal ( w . webContents )
511
+ } )
505
512
} )
506
513
} )
507
514
0 commit comments