@@ -32,16 +32,48 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
3232 // extension in an in-memory session results in it being installed in the
3333 // default session.
3434 const customSession = session . fromPartition ( `persist:${ require ( 'uuid' ) . v4 ( ) } ` ) ;
35- ( customSession as any ) . loadChromeExtension ( path . join ( fixtures , 'extensions' , 'red-bg' ) )
35+ ( customSession as any ) . loadExtension ( path . join ( fixtures , 'extensions' , 'red-bg' ) )
3636 const w = new BrowserWindow ( { show : false , webPreferences : { session : customSession } } )
3737 await w . loadURL ( url )
3838 const bg = await w . webContents . executeJavaScript ( 'document.documentElement.style.backgroundColor' )
3939 expect ( bg ) . to . equal ( 'red' )
4040 } )
4141
42+ it ( 'removes an extension' , async ( ) => {
43+ const customSession = session . fromPartition ( `persist:${ require ( 'uuid' ) . v4 ( ) } ` )
44+ const { id } = await ( customSession as any ) . loadExtension ( path . join ( fixtures , 'extensions' , 'red-bg' ) )
45+ {
46+ const w = new BrowserWindow ( { show : false , webPreferences : { session : customSession } } )
47+ await w . loadURL ( url )
48+ const bg = await w . webContents . executeJavaScript ( 'document.documentElement.style.backgroundColor' )
49+ expect ( bg ) . to . equal ( 'red' )
50+ }
51+ ( customSession as any ) . removeExtension ( id )
52+ {
53+ const w = new BrowserWindow ( { show : false , webPreferences : { session : customSession } } )
54+ await w . loadURL ( url )
55+ const bg = await w . webContents . executeJavaScript ( 'document.documentElement.style.backgroundColor' )
56+ expect ( bg ) . to . equal ( '' )
57+ }
58+ } )
59+
60+ it ( 'lists loaded extensions in getAllExtensions' , async ( ) => {
61+ const customSession = session . fromPartition ( `persist:${ require ( 'uuid' ) . v4 ( ) } ` )
62+ const e = await ( customSession as any ) . loadExtension ( path . join ( fixtures , 'extensions' , 'red-bg' ) )
63+ expect ( ( customSession as any ) . getAllExtensions ( ) ) . to . deep . equal ( [ e ] ) ;
64+ ( customSession as any ) . removeExtension ( e . id )
65+ expect ( ( customSession as any ) . getAllExtensions ( ) ) . to . deep . equal ( [ ] )
66+ } )
67+
68+ it ( 'gets an extension by id' , async ( ) => {
69+ const customSession = session . fromPartition ( `persist:${ require ( 'uuid' ) . v4 ( ) } ` )
70+ const e = await ( customSession as any ) . loadExtension ( path . join ( fixtures , 'extensions' , 'red-bg' ) )
71+ expect ( ( customSession as any ) . getExtension ( e . id ) ) . to . deep . equal ( e )
72+ } )
73+
4274 it ( 'confines an extension to the session it was loaded in' , async ( ) => {
4375 const customSession = session . fromPartition ( `persist:${ require ( 'uuid' ) . v4 ( ) } ` ) ;
44- ( customSession as any ) . loadChromeExtension ( path . join ( fixtures , 'extensions' , 'red-bg' ) )
76+ ( customSession as any ) . loadExtension ( path . join ( fixtures , 'extensions' , 'red-bg' ) )
4577 const w = new BrowserWindow ( { show : false } ) // not in the session
4678 await w . loadURL ( url )
4779 const bg = await w . webContents . executeJavaScript ( 'document.documentElement.style.backgroundColor' )
@@ -52,7 +84,7 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
5284 let content : any
5385 before ( async ( ) => {
5486 const customSession = session . fromPartition ( `persist:${ require ( 'uuid' ) . v4 ( ) } ` ) ;
55- ( customSession as any ) . loadChromeExtension ( path . join ( fixtures , 'extensions' , 'chrome-runtime' ) )
87+ ( customSession as any ) . loadExtension ( path . join ( fixtures , 'extensions' , 'chrome-runtime' ) )
5688 const w = new BrowserWindow ( { show : false , webPreferences : { session : customSession } } )
5789 try {
5890 await w . loadURL ( url )
@@ -76,7 +108,7 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
76108 describe ( 'chrome.storage' , ( ) => {
77109 it ( 'stores and retrieves a key' , async ( ) => {
78110 const customSession = session . fromPartition ( `persist:${ require ( 'uuid' ) . v4 ( ) } ` ) ;
79- ( customSession as any ) . loadChromeExtension ( path . join ( fixtures , 'extensions' , 'chrome-storage' ) )
111+ ( customSession as any ) . loadExtension ( path . join ( fixtures , 'extensions' , 'chrome-storage' ) )
80112 const w = new BrowserWindow ( { show : false , webPreferences : { session : customSession , nodeIntegration : true } } )
81113 try {
82114 const p = emittedOnce ( ipcMain , 'storage-success' )
0 commit comments