@@ -20,7 +20,7 @@ describe('getCurrentFuseWire()', () => {
20
20
} ) ;
21
21
22
22
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 ) ;
24
24
expect ( readableFuseWire ( await getCurrentFuseWire ( electronPath ) ) ) . toMatchInlineSnapshot ( `
25
25
{
26
26
"EnableCookieEncryption": "DISABLE",
@@ -35,16 +35,18 @@ describe('getCurrentFuseWire()', () => {
35
35
} ) ;
36
36
37
37
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
+ }
42
44
}
43
45
} ) ;
44
46
45
47
describe ( 'flipFuses()' , ( ) => {
46
48
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 ) ;
48
50
expect ( ( await getCurrentFuseWire ( electronPath ) ) [ FuseV1Options . EnableCookieEncryption ] ) . toEqual (
49
51
FuseState . DISABLE ,
50
52
) ;
@@ -59,7 +61,7 @@ describe('flipFuses()', () => {
59
61
} ) ;
60
62
61
63
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 ) ;
63
65
expect ( ( await getCurrentFuseWire ( electronPath ) ) [ FuseV1Options . EnableCookieEncryption ] ) . toEqual (
64
66
FuseState . DISABLE ,
65
67
) ;
@@ -79,6 +81,37 @@ describe('flipFuses()', () => {
79
81
) . toEqual ( FuseState . ENABLE ) ;
80
82
} ) ;
81
83
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
+
82
115
if ( process . platform === 'darwin' ) {
83
116
it ( 'should work on universal macOS applications' , async ( ) => {
84
117
const electronPathX64 = await getElectronLocally ( '20.0.0' , 'darwin' , 'x64' ) ;
0 commit comments