@@ -20,7 +20,7 @@ describe('getCurrentFuseWire()', () => {
2020 } ) ;
2121
2222 it ( 'should return the expected defaults for Electron v20.0.0' , async ( ) => {
23- const electronPath = await getElectronLocally ( '20.0.0' , 'darwin' , 'x64' ) ;
23+ const electronPath = await getElectronLocally ( '20.0.0' , process . platform , process . arch ) ;
2424 expect ( readableFuseWire ( await getCurrentFuseWire ( electronPath ) ) ) . toMatchInlineSnapshot ( `
2525 {
2626 "EnableCookieEncryption": "DISABLE",
@@ -35,16 +35,18 @@ describe('getCurrentFuseWire()', () => {
3535 } ) ;
3636
3737 for ( const [ platform , arch ] of supportedPlatforms ) {
38- it ( `should work on ${ platform } /${ arch } ` , async ( ) => {
39- const electronPath = await getElectronLocally ( '20.0.0' , platform , arch ) ;
40- await expect ( getCurrentFuseWire ( electronPath ) ) . resolves . toBeTruthy ( ) ;
41- } ) ;
38+ if ( process . platform === platform ) {
39+ it ( `should work on ${ platform } /${ arch } ` , async ( ) => {
40+ const electronPath = await getElectronLocally ( '20.0.0' , platform , arch ) ;
41+ await expect ( getCurrentFuseWire ( electronPath ) ) . resolves . toBeTruthy ( ) ;
42+ } ) ;
43+ }
4244 }
4345} ) ;
4446
4547describe ( 'flipFuses()' , ( ) => {
4648 it ( 'should allow toggling a single fuse' , async ( ) => {
47- const electronPath = await getElectronLocally ( '20.0.0' , 'darwin' , 'x64' ) ;
49+ const electronPath = await getElectronLocally ( '20.0.0' , process . platform , process . arch ) ;
4850 expect ( ( await getCurrentFuseWire ( electronPath ) ) [ FuseV1Options . EnableCookieEncryption ] ) . toEqual (
4951 FuseState . DISABLE ,
5052 ) ;
@@ -59,7 +61,7 @@ describe('flipFuses()', () => {
5961 } ) ;
6062
6163 it ( 'should allow toggling multiple fuses' , async ( ) => {
62- const electronPath = await getElectronLocally ( '20.0.0' , 'darwin' , 'x64' ) ;
64+ const electronPath = await getElectronLocally ( '20.0.0' , process . platform , process . arch ) ;
6365 expect ( ( await getCurrentFuseWire ( electronPath ) ) [ FuseV1Options . EnableCookieEncryption ] ) . toEqual (
6466 FuseState . DISABLE ,
6567 ) ;
@@ -79,6 +81,37 @@ describe('flipFuses()', () => {
7981 ) . toEqual ( FuseState . ENABLE ) ;
8082 } ) ;
8183
84+ it ( 'should throw exception by default if unsupported fuse is specified' , async ( ) => {
85+ const electronPath = await getElectronLocally ( '20.0.0' , process . platform , process . arch ) ;
86+ const fuseConfig = await getCurrentFuseWire ( electronPath ) ;
87+ expect ( FuseV1Options . LoadBrowserProcessSpecificV8Snapshot in fuseConfig ) . toBeFalsy ( ) ;
88+
89+ await expect (
90+ flipFuses ( electronPath , {
91+ version : FuseVersion . V1 ,
92+ [ FuseV1Options . LoadBrowserProcessSpecificV8Snapshot ] : true ,
93+ } ) ,
94+ ) . rejects . toThrow ( 'LoadBrowserProcessSpecificV8Snapshot' ) ;
95+ } ) ;
96+
97+ it ( 'should toggle only supported fuses if ignoreNotSupportedFuses is true' , async ( ) => {
98+ const electronPath = await getElectronLocally ( '20.0.0' , process . platform , process . arch ) ;
99+ const fuseConfig = await getCurrentFuseWire ( electronPath ) ;
100+ expect ( FuseV1Options . LoadBrowserProcessSpecificV8Snapshot in fuseConfig ) . toBeFalsy ( ) ;
101+ expect ( fuseConfig [ FuseV1Options . EnableCookieEncryption ] ) . toEqual ( FuseState . DISABLE ) ;
102+
103+ await flipFuses ( electronPath , {
104+ version : FuseVersion . V1 ,
105+ ignoreNotSupportedFuses : true ,
106+ [ FuseV1Options . EnableCookieEncryption ] : true ,
107+ [ FuseV1Options . LoadBrowserProcessSpecificV8Snapshot ] : true ,
108+ } ) ;
109+
110+ const newFuseConfig = await getCurrentFuseWire ( electronPath ) ;
111+ expect ( FuseV1Options . LoadBrowserProcessSpecificV8Snapshot in newFuseConfig ) . toBeFalsy ( ) ;
112+ expect ( newFuseConfig [ FuseV1Options . EnableCookieEncryption ] ) . toEqual ( FuseState . ENABLE ) ;
113+ } ) ;
114+
82115 if ( process . platform === 'darwin' ) {
83116 it ( 'should work on universal macOS applications' , async ( ) => {
84117 const electronPathX64 = await getElectronLocally ( '20.0.0' , 'darwin' , 'x64' ) ;
0 commit comments