Skip to main content

Chrome flags

· 6 min read
Alan

Chrome 工具 flags 列表, 摘自 Chrome Flags for Tooling:

常用

  • --proxy-server=http://192.168.1.199:3210 设置HTTP代理
  • --proxy-bypass-list 忽略的 server host

SSL 证书

解决 Chrome设置使用代理,代理工具证书未被信任导致的签名问题。

  • 如果你的代理工具是本地运行,可以在Chrome启动时增加 --allow-insecure-localhost flag。
  • 或者忽略所有证书错误 --ignore-certificate-errors

本文尝试记录和自动化工具以及基准测试相关的Chrome flags列表.

没有相同的场景, 所以你需要选择最适合自己的flag.

通常无用的浏览器特性

  • --disable-client-side-phishing-detection: 禁用客户端钓鱼检测
  • --disable-component-extensions-with-background-pages: 禁用一些 --disable-extensions 无法禁用的内置扩展
  • --disable-default-apps: 禁止安装默认App
  • --disable-extensions: 禁用所有Chrome扩展
  • --mute-audio: 静音
  • --no-default-browser-check: 禁用默认浏览器检测
  • --no-first-run: 跳过首次运行向导
  • --use-fake-device-for-media-stream: Use fake device for Media Stream to replace camera and microphone
  • --use-file-for-fake-video-capture=<path-to-file>: Use file for fake video capture (.y4m or .mjpeg) Needs --use-fake-device-for-media-stream

性能和Web平台行为

  • --allow-running-insecure-content 允许运行不安全的内容
  • --autoplay-policy=user-gesture-required: 不要渲染视频
  • --disable-background-timer-throttling: 禁用后台页面或tab抖动计时器
  • --disable-backgrounding-occluded-windows
  • --disable-features=ScriptStreaming: V8 script streaming
  • --disable-hang-monitor
  • --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. This flag disables it. https://crrev.com/604305
  • --disable-notifications: Disables the Web Notification and the Push APIs.
  • --disable-popup-blocking: Disable popup blocking. --block-new-web-contents is the strict version of this.
  • --disable-prompt-on-repost: Reloading a page that came from a POST normally prompts the user.
  • --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#123
  • --js-flags=--random-seed=1157259157: Initialize V8's RNG with a fixed seed.

Test & debugging flags

  • --disable-device-discovery-notifications: Avoid messages like "New printer on your network"
  • --enable-automation: Disable a few things considered not appropriate for automation. (Original design doc, though renamed here) codesearch. Note that some projects have chosen to avoid using this flag: web-platform-tests/wpt/#6348
    • disables bubble notification about running development/unpacked extensions
    • disables the password saving UI (which covers the usecase of the removed --disable-save-password-bubble flag)
    • disables infobar animations
    • disables auto-reloading on network errors (source)
    • means the default browser check prompt isn't shown
    • avoids showing these 3 infobars: ShowBadFlagsPrompt, GoogleApiKeysInfoBarDelegate, ObsoleteSystemInfoBarDelegate
    • adds this infobar: image
  • --enable-logging=stderr: Logging behavior slightly more appropriate for a server-type process.
  • --log-level=0: 0 means INFO and higher.
  • --password-store=basic: Avoid potential instability of using Gnome Keyring or KDE wallet. chromium/linux/password_storage.md https://crbug.com/571003
  • --remote-debugging-pipe: more secure than using protocol over a websocket
  • --silent-debugger-extension-api: Does not show an infobar when a Chrome extension attaches to a page using chrome.debugger page. Required to attach to extension background pages.
  • --test-type: Basically the 2014 version of --enable-automation. codesearch
    • It avoids creating application stubs in ~/Applications on mac.
    • It makes exit codes slightly more correct
    • windows navigation jumplists arent updated https://crbug.com/389375
    • doesn't start some chrome StartPageService
    • disables initializing chromecast service
    • "Component extensions with background pages are not enabled during tests because they generate a lot of background behavior that can interfere."
    • when quitting the browser, it disables additional checks that may stop that quitting process. (like unsaved form modifications or unhandled profile notifications..)
  • --use-mock-keychain: Use mock keychain on Mac to prevent blocking permissions dialogs. https://crbug.com/865247

Background updates, networking, reporting

  • --disable-background-networking: Disable various background network services, including extension updating,safe browsing service, upgrade detector, translate, UMA
  • --disable-breakpad: Disable crashdump collection (reporting is already disabled in Chromium)
  • --disable-component-update: Don't update the browser 'components' listed at chrome://components/
  • --disable-domain-reliability: Disables Domain Reliability Monitoring, which tracks whether the browser has difficulty contacting Google-owned sites and uploads reports to Google.
  • --disable-sync: Disable syncing to a Google account
  • --enable-crash-reporter-for-testing: Used for turning on Breakpad crash reporting in a debug environment where crash reporting is typically compiled but disabled.
  • --metrics-recording-only: Disable reporting to UMA, but allows for collection

Rendering & GPU

  • --deterministic-mode: An experimental meta flag. This sets the below indented flags which put the browser into a mode where rendering (border radius, etc) is deterministic and begin frames should be issued over DevTools Protocol. codesearch
    • --run-all-compositor-stages-before-draw
    • --disable-new-content-rendering-timeout
    • --enable-begin-frame-control
    • --disable-threaded-animation
    • --disable-threaded-scrolling
    • --disable-checker-imaging
    • --disable-image-animation-resync
  • --disable-features=PaintHolding: Don't defer paint commits (normally used to avoid flash of unstyled content)
  • --disable-partial-raster: https://crbug.com/919955
  • --disable-skia-runtime-opts: Do not use runtime-detected high-end CPU optimizations in Skia.
  • --in-process-gpu: Saves some memory by moving GPU process into a browser process thread
  • --use-gl="swiftshader": 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.

Window & screen management

  • --block-new-web-contents: All pop-ups and calls to window.open will fail.
  • --force-color-profile=srgb: Force all monitors to be treated as though they have the specified color profile.
  • --force-device-scale-factor=1
  • --new-window: Launches URL in new browser window.
  • --window-position=0,0
  • --window-size=1600,1024

Process management

Headless

  • --disable-dev-shm-usage: Often used in Lambda, Cloud Functions scenarios. (pptr issue, crbug)
  • --no-sandbox: Sometimes used with headless, though not recommended.
  • --disable-gpu: Sometimes used with headless.

~Removed~ flags

Sources

浏览器所有 flags

FYI: (Probably) all flags are defined in files matching the pattern of *_switches.cc.

Feature Flags FYI

Chromium and Blink use feature flags to disable/enable many features at runtime. Chromium has ~400 features that can be toggled with --enable-features / --disable-features. Indepdently, Blink has many features that can be toggled with commandline switches: --enable-blink-features / --disable-blink-features.