@@ -3,7 +3,13 @@ import { generateSPKIFingerprint } from 'mockttp';
3
3
4
4
import { HtkConfig } from '../config' ;
5
5
6
- import { getAvailableBrowsers , launchBrowser , BrowserInstance , Browser } from '../browsers' ;
6
+ import {
7
+ getAvailableBrowsers ,
8
+ launchBrowser ,
9
+ BrowserInstance ,
10
+ Browser ,
11
+ LaunchOptions
12
+ } from '../browsers' ;
7
13
import { delay , readFile , deleteFolder , listRunningProcesses } from '../util' ;
8
14
import { HideWarningServer } from '../hide-warning-server' ;
9
15
import { Interceptor } from '.' ;
@@ -21,7 +27,7 @@ const getChromiumLaunchOptions = async (
21
27
config : HtkConfig ,
22
28
proxyPort : number ,
23
29
hideWarningServer : HideWarningServer
24
- ) => {
30
+ ) : Promise < LaunchOptions & { options : Required < LaunchOptions > [ 'options' ] } > => {
25
31
const certificatePem = await readFile ( config . https . certPath , 'utf8' ) ;
26
32
const spkiFingerprint = generateSPKIFingerprint ( certificatePem ) ;
27
33
@@ -234,13 +240,21 @@ abstract class ExistingChromiumBasedInterceptor implements Interceptor {
234
240
hideWarningServer
235
241
) ;
236
242
237
- if ( existingPid ) {
238
- // If we killed something, use --restore-last-session to ensure it comes back:
239
- launchOptions . options . push ( '--restore-last-session' ) ;
240
- }
243
+ // Remove almost all default arguments. Each of these changes behaviour in maybe unexpected
244
+ // ways, notably including --disable-restore which actively causes problems.
245
+ launchOptions . skipDefaults = true ;
246
+ launchOptions . options . push (
247
+ '--no-default-browser-check' ,
248
+ '--no-first-run' ,
249
+ '--disable-popup-blocking' // Required for hide-warning -> amiusing hop
250
+ ) ;
251
+
252
+ // If we killed something, use --restore-last-session to ensure it comes back:
253
+ if ( existingPid ) launchOptions . options . push ( '--restore-last-session' ) ;
241
254
242
255
const browser = await launchBrowser ( hideWarningServer . hideWarningUrl , {
243
256
...launchOptions ,
257
+ skipDefaults : true ,
244
258
profile : null // Enforce that we use the default profile
245
259
} , this . config . configPath ) ;
246
260
0 commit comments