@@ -3,7 +3,13 @@ import { generateSPKIFingerprint } from 'mockttp';
33
44import { HtkConfig } from '../config' ;
55
6- import { getAvailableBrowsers , launchBrowser , BrowserInstance , Browser } from '../browsers' ;
6+ import {
7+ getAvailableBrowsers ,
8+ launchBrowser ,
9+ BrowserInstance ,
10+ Browser ,
11+ LaunchOptions
12+ } from '../browsers' ;
713import { delay , readFile , deleteFolder , listRunningProcesses } from '../util' ;
814import { HideWarningServer } from '../hide-warning-server' ;
915import { Interceptor } from '.' ;
@@ -21,7 +27,7 @@ const getChromiumLaunchOptions = async (
2127 config : HtkConfig ,
2228 proxyPort : number ,
2329 hideWarningServer : HideWarningServer
24- ) => {
30+ ) : Promise < LaunchOptions & { options : Required < LaunchOptions > [ 'options' ] } > => {
2531 const certificatePem = await readFile ( config . https . certPath , 'utf8' ) ;
2632 const spkiFingerprint = generateSPKIFingerprint ( certificatePem ) ;
2733
@@ -234,13 +240,21 @@ abstract class ExistingChromiumBasedInterceptor implements Interceptor {
234240 hideWarningServer
235241 ) ;
236242
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' ) ;
241254
242255 const browser = await launchBrowser ( hideWarningServer . hideWarningUrl , {
243256 ...launchOptions ,
257+ skipDefaults : true ,
244258 profile : null // Enforce that we use the default profile
245259 } , this . config . configPath ) ;
246260
0 commit comments