Path: blob/main/plugins/default-browser-emulator/lib/helpers/configureBrowserLaunchArgs.ts
1030 views
import * as Path from 'path';1import * as os from 'os';2import BrowserEngine from '@secret-agent/plugin-utils/lib/BrowserEngine';3import { defaultScreen } from '../Viewports';45let sessionDirCounter = 0;67export function configureBrowserLaunchArgs(8engine: BrowserEngine,9options: {10showBrowser?: boolean;11disableGpu?: boolean;12disableDevtools?: boolean;13},14): void {15engine.launchArguments.push(16'--disable-background-networking', // Disable various background network services, including extension updating,safe browsing service, upgrade detector, translate, UMA17'--enable-features=NetworkService,NetworkServiceInProcess',18'--disable-background-timer-throttling', // Disable timers being throttled in background pages/tabs19'--disable-backgrounding-occluded-windows',20'--disable-breakpad', // Disable crashdump collection (reporting is already disabled in Chromium)21'--disable-client-side-phishing-detection', // Disables client-side phishing detection.22'--disable-domain-reliability', // Disables Domain Reliability Monitoring, which tracks whether the browser has difficulty contacting Google-owned sites and uploads reports to Google.23'--disable-default-apps', // Disable installation of default apps on first run24'--disable-dev-shm-usage', // https://github.com/GoogleChrome/puppeteer/issues/183425'--disable-extensions', // Disable all chrome extensions.26'--disable-features=PaintHolding,TranslateUI,site-per-process,OutOfBlinkCors,DestroyProfileOnBrowserClose', // site-per-process = Disables OOPIF, OutOfBlinkCors = Disables feature in chrome80/81 for out of process cors27'--disable-blink-features=AutomationControlled',28'--disable-hang-monitor',29'--disable-ipc-flooding-protection', // Some javascript functions can be used to flood the browser process with IPC. By default, protection is on to limit the number of IPC sent to 10 per second per frame.30'--disable-prompt-on-repost', // Reloading a page that came from a POST normally prompts the user.31'--disable-renderer-backgrounding', // This disables non-foreground tabs from getting a lower process priority This doesn't (on its own) affect timers or painting behavior. karma-chrome-launcher#12332'--disable-sync', // Disable syncing to a Google account3334'--force-color-profile=srgb', // Force all monitors to be treated as though they have the specified color profile.35'--use-gl=any', // Select which implementation of GL the GPU process should use. Options are: desktop: whatever desktop OpenGL the user has installed (Linux and Mac default). egl: whatever EGL / GLES2 the user has installed (Windows default - actually ANGLE). swiftshader: The SwiftShader software renderer.36'--disable-partial-raster', // https://crbug.com/91995537'--disable-skia-runtime-opts', // Do not use runtime-detected high-end CPU optimizations in Skia.3839'--incognito',4041'--use-fake-device-for-media-stream',4243'--no-default-browser-check', // Disable the default browser check, do not prompt to set it as such44'--metrics-recording-only', // Disable reporting to UMA, but allows for collection45'--no-first-run', // Skip first run wizards4647// '--enable-automation', BAB - disable because adds infobar, stops auto-reload on network errors (using other flags)48'--enable-auto-reload', // Enable auto-reload of error pages.4950'--password-store=basic', // Avoid potential instability of using Gnome Keyring or KDE wallet.51'--use-mock-keychain', // Use mock keychain on Mac to prevent blocking permissions dialogs52'--allow-running-insecure-content',5354`--window-size=${defaultScreen.width},${defaultScreen.height}`,5556// don't leak private ip57'--force-webrtc-ip-handling-policy=default_public_interface_only',58'--no-startup-window',59);6061if (options.showBrowser) {62const dataDir = Path.join(63os.tmpdir(),64engine.fullVersion.replace('.', '-'),65`${String(Date.now()).substr(0, 10)}-${(sessionDirCounter += 1)}`,66);67engine.launchArguments.push(`--user-data-dir=${dataDir}`); // required to allow multiple browsers to be headed68engine.userDataDir = dataDir;6970if (!options.disableDevtools) engine.launchArguments.push('--auto-open-devtools-for-tabs');71} else {72engine.launchArguments.push(73'--hide-scrollbars',74'--mute-audio',75'--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4', // adds cursor to headless linux76);77}7879if (options.disableGpu === true) {80engine.launchArguments.push('--disable-gpu', '--disable-software-rasterizer');81const idx = engine.launchArguments.indexOf('--use-gl=any');82if (idx >= 0) engine.launchArguments.splice(idx, 1);83}84}858687