Chrome Flags for Tooling: A Comprehensive Guide
Chrome flags are powerful command-line switches that can modify the browser's behavior for testing, automation, and development purposes. This article provides an in-depth overview of Chrome flags relevant to tooling, automation, and benchmarking. We'll explore how these flags can be used to control various aspects of the browser, from disabling unwanted features to optimizing performance and suppressing interactivity.
Understanding Chrome Flags
Chrome flags allow you to fine-tune the browser environment to suit your specific needs. They offer a way to disable default behaviors, enable experimental features, and customize rendering and networking settings.
Disabling Unwanted Browser Features
Many flags are useful for suppressing features that can interfere with automated testing or benchmarking:
--disable-client-side-phishing-detection
: Turns off phishing detection.--disable-component-extensions-with-background-pages
: Prevents certain built-in extensions from running.--disable-default-apps
: Stops the installation of default apps.--disable-extensions
: Disables all extensions.--disable-features=InterestFeedContentSuggestions
: Hides the Discover feed.--disable-features=Translate
: Disables translation prompts and functionality.--hide-scrollbars
: Removes scrollbars from screenshots.--mute-audio
: Mutes audio output.--no-default-browser-check
: Skips the default browser check.--no-first-run
: Skips the first-run wizard.--ash-no-nudges
: Disables user education nudges.--disable-search-engine-choice-screen
: Disables the search engine choice screen.--propagate-iph-for-testing
: Specifies which in-product help (IPH) features are allowed.
Controlling Task Throttling
These flags manage how Chrome handles background processes and tasks:
--disable-background-timer-throttling
: Prevents timers from being throttled in background tabs.--disable-backgrounding-occluded-windows
: Stops Chrome from treating foreground tabs as backgrounded when visually covered.--disable-features=CalculateNativeWinOcclusion
: Disables window occlusion calculations on Windows.--disable-hang-monitor
: Suppresses hang monitor dialogs.--disable-ipc-flooding-protection
: Disables protection against IPC flooding.--disable-renderer-backgrounding
: Prevents non-foreground tabs from getting lower process priority.
Customizing Web Platform Behavior
These flags influence how Chrome interacts with web content:
--aggressive-cache-discard
--allow-running-insecure-content
--disable-back-forward-cache
: Disables the BackForwardCache feature.--disable-features=AcceptCHFrame
: Disable accepting h2/h3 ACCEPT_CH Client Hints frames.--disable-features=AutoExpandDetailsElement
--disable-features=AvoidUnnecessaryBeforeUnloadCheckSync
: Prevents the browser from checkingbeforeunload
handlers unnecessarily, which can speed up navigation.--disable-features=BackForwardCache
: Disable the bfcache.--disable-features=HeavyAdPrivacyMitigations
: Disables the privacy mitigations for heavy ads.--disable-features=IsolateOrigins
--disable-features=LazyFrameLoading
--disable-features=ScriptStreaming
: Disables V8 script streaming.--no-process-per-site
: Disables renderer process reuse across tabs of the same site.--enable-precise-memory-info
: Provides more granular memory information.--js-flags=--random-seed=1157259157
: Used to initialize V8's RNG with a fixed seed.--use-fake-device-for-media-stream
: Use fake device for Media Stream to replace camera and microphone--use-fake-ui-for-media-stream
: Bypass the media stream infobar by selecting the default device for media streams (e.g. WebRTC).--use-file-for-fake-video-capture=
: Use file for fake video capture (.y4m or .mjpeg).
Suppressing Interactivity
These flags help control user prompts and interactive elements:
--autoplay-policy=...
: Controls autoplay behavior (e.g.,--autoplay-policy=user-gesture-required
to prevent autoplay).--deny-permission-prompts
: Automatically denies all permission prompts.--disable-external-intent-requests
: Disallows opening links in external applications.--disable-features=GlobalMediaControls
: Hides the global media controls button.--disable-features=ImprovedCookieControls
: Disables an improved UI for third-party cookie blocking in incognito mode.--disable-features=PrivacySandboxSettings4
: Disables "Enhanced ad privacy in Chrome" dialog (if it wasn't disabled through other means).--disable-notifications
: Disables web notifications and the Push API.--disable-popup-blocking
: Disables popup blocking.--disable-prompt-on-repost
: Suppresses prompts when reloading a page that came from a POST request.--noerrdialogs
: Suppresses all error dialogs.
Automation-Focused Flags
These flags are specifically designed to optimize Chrome for automated environments:
--enable-automation
: Disables features that are inappropriate for automation, such as infobar animations and password saving prompts. It also setsnavigator.webdriver
totrue
.--test-type
: Similar to--enable-automation
, but with additional effects like avoiding application stub creation on macOS and providing more accurate exit codes.--remote-debugging-pipe
: Enables remote debugging over a pipe (more secure than a websocket).--remote-debugging-port=...
: Specifies the port for remote debugging. Setting the value to 0 will cause Chrome to automatically select a port and setnavigator.webdriver
totrue
.--silent-debugger-extension-api
: Suppresses infobars when extensions attach using thechrome.debugger
API, crucial for working with extension background pages.
General Utility Flags
--enable-logging=stderr
: Sends logging output to stderr, which is more suitable for server-type processes.--log-level=0
: Sets the logging level (0 = INFO and higher, 2 = most verbose). Use--enable-logging=stderr --v=2
for verbose logging and potential troubleshooting.--user-data-dir=...
: Specifies the directory for storing the user profile.
Addressing Chromium Annoyances
--disable-features=MediaRouter
: Avoid the startup dialog for Do you want the application "Chromium.app" to accept incoming network connections?.--password-store=basic
: Avoids potential instability with Gnome Keyring or KDE wallet on Linux.--use-mock-keychain
: Uses a mock keychain on macOS to prevent permission dialogs.
Controlling Background Networking
--disable-background-networking
: Disables various background network services, like extension updating and safe browsing.--disable-breakpad
: Disables crashdump collection.--disable-component-update
: Prevents updates to browser components.--disable-domain-reliability
: Disables Domain Reliability Monitoring.--disable-features=AutofillServerCommunication
: Disables autofill server communication.--disable-features=CertificateTransparencyComponentUpdater
--disable-sync
: Disables syncing to a Google account.--enable-crash-reporter-for-testing
: Enables crash reporting in debug environments.--metrics-recording-only
: Disables reporting to UMA, but allows for collection.--disable-features=OptimizationHints
: Disable the Chrome Optimization Guide and networking with its service API--disable-features=DialMediaRouteProvider
: Disables theMediaRouter
feature.--no-pings
: Prevents sending hyperlink auditing pings.
Rendering and GPU Configuration
--allow-pre-commit-input
: Allows input processing before a frame is committed (used by headless Chrome).--deterministic-mode
: Enables settings to ensure deterministic rendering.--disable-features=PaintHolding
: Don't defer paint commits (normally used to avoid flash of unstyled content)--disable-partial-raster
--disable-skia-runtime-opts
: Disables runtime CPU optimizations in Skia.--in-process-gpu
: Moves the GPU process into a browser process thread to save memory.--use-gl="swiftshader"
: Selects the GL implementation for the GPU process (options includedesktop
,egl
, andswiftshader
).
Conclusion
Chrome flags offer an extensive toolkit for customizing and controlling browser behavior. By understanding and utilizing these flags, developers and testers can create more reliable, efficient, and tailored environments for their specific needs. Experiment with these flags and consult the Chromium documentation for the most up-to-date information.