Skip to content

Commit

Permalink
Merge pull request #580 from HTTPArchive/flags
Browse files Browse the repository at this point in the history
Cleaned up Chrome command-line flags
  • Loading branch information
tkadlec authored Nov 29, 2022
2 parents 9436f6b + 5119281 commit 178ab72
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 58 deletions.
62 changes: 33 additions & 29 deletions internal/chrome_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,60 @@
from .android_browser import AndroidBrowser

CHROME_COMMAND_LINE_OPTIONS = [
'--disable-fre',
'--metrics-recording-only',
'--disable-background-networking',
'--disable-component-update',
'--no-default-browser-check',
'--no-first-run',
'--allow-running-insecure-content',
'--disable-background-networking',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-breakpad',
'--disable-client-side-phishing-detection',
'--disable-device-discovery-notifications',
'--disable-component-update',
'--disable-default-apps',
'--disable-domain-reliability',
'--disable-background-timer-throttling',
'--disable-external-intent-requests',
'--disable-fetching-hints-at-navigation-start',
'--disable-fre',
'--disable-hang-monitor',
'--disable-ipc-flooding-protection',
'--disable-prompt-on-repost',
'--disable-renderer-backgrounding',
'--disable-site-isolation-trials',
'--disable-sync',
'--enable-remote-debugging',
'--net-log-capture-mode=IncludeSensitive',
'--load-media-router-component-extension=0',
'--metrics-recording-only',
'--metrics-recording-only',
'--mute-audio',
'--disable-hang-monitor',
'--net-log-capture-mode=IncludeSensitive',
'--no-default-browser-check',
'--no-first-run',
'--password-store=basic',
'--disable-breakpad',
'--dont-require-litepage-redirect-infobar',
'--override-https-image-compression-infobar',
'--disable-fetching-hints-at-navigation-start'
'--use-mock-keychain',
]

HOST_RULES = [
'"MAP cache.pack.google.com 127.0.0.1"',
'"MAP clients1.google.com 127.0.0.1"',
'"MAP update.googleapis.com 127.0.0.1"',
'"MAP redirector.gvt1.com 127.0.0.1"',
'"MAP offlinepages-pa.googleapis.com 127.0.0.1"',
'"MAP optimizationguide-pa.googleapis.com 127.0.0.1"'
'"MAP optimizationguide-pa.googleapis.com 127.0.0.1"',
'"MAP redirector.gvt1.com 127.0.0.1"',
'"MAP update.googleapis.com 127.0.0.1"',
]

DISABLE_CHROME_FEATURES = [
'InterestFeedContentSuggestions',
'AutofillServerCommunication',
'BackForwardCache',
'CalculateNativeWinOcclusion',
'TranslateUI',
'Translate',
'HeavyAdPrivacyMitigations',
'InterestFeedContentSuggestions',
'MediaRouter',
'OfflinePagesPrefetching',
'AutofillServerCommunication'
'OptimizationHints',
'Translate',
]

ENABLE_CHROME_FEATURES = [
'SecMetadata'
]

ENABLE_BLINK_FEATURES = [
'LayoutInstabilityAPI'
]

""" Orange page
Expand Down Expand Up @@ -151,11 +156,10 @@ def launch(self, job, task):
if 'netlog' in job and job['netlog']:
self.adb.shell(['rm', '/data/local/tmp/netlog.txt'])
args.append('--log-net-log=/data/local/tmp/netlog.txt')
if 'overrideHosts' in task and task['overrideHosts']:
features.append('NetworkService')
features.append('NetworkServiceInProcess')
args.append('--enable-features=' + ','.join(features))
args.append('--enable-blink-features=' + ','.join(ENABLE_BLINK_FEATURES))
if len(features):
args.append('--enable-features=' + ','.join(features))
if len(ENABLE_BLINK_FEATURES):
args.append('--enable-blink-features=' + ','.join(ENABLE_BLINK_FEATURES))
args.append('--disable-features=' + ','.join(disable_features))
self.sanitize_shell_args(args)
command_line = 'chrome ' + ' '.join(args)
Expand Down
60 changes: 31 additions & 29 deletions internal/chrome_desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,58 +21,58 @@
import json

CHROME_COMMAND_LINE_OPTIONS = [
'--disable-background-networking',
'--no-default-browser-check',
'--no-first-run',
'--new-window',
'--allow-running-insecure-content',
'--disable-background-networking',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-breakpad',
'--disable-client-side-phishing-detection',
'--disable-component-update',
'--disable-default-apps',
'--disable-device-discovery-notifications',
'--disable-domain-reliability',
'--disable-background-timer-throttling',
'--load-media-router-component-extension=0',
'--mute-audio',
'--disable-fetching-hints-at-navigation-start',
'--disable-hang-monitor',
'--disable-ipc-flooding-protection',
'--disable-prompt-on-repost',
'--disable-renderer-backgrounding',
'--disable-site-isolation-trials',
'--disable-sync',
'--metrics-recording-only',
'--mute-audio',
'--new-window',
'--no-default-browser-check',
'--no-first-run',
'--password-store=basic',
'--disable-breakpad',
'--dont-require-litepage-redirect-infobar',
'--override-https-image-compression-infobar',
'--disable-fetching-hints-at-navigation-start',
'--disable-back-forward-cache',
'--disable-site-isolation-trials'
'--use-mock-keychain',
]

HOST_RULES = [
'"MAP cache.pack.google.com 127.0.0.1"',
'"MAP clients1.google.com 127.0.0.1"',
'"MAP update.googleapis.com 127.0.0.1"',
'"MAP redirector.gvt1.com 127.0.0.1"',
'"MAP edge.microsoft.com 127.0.0.1"',
'"MAP laptop-updates.brave.com 127.0.0.1"',
'"MAP offlinepages-pa.googleapis.com 127.0.0.1"',
'"MAP edge.microsoft.com 127.0.0.1"',
'"MAP optimizationguide-pa.googleapis.com 127.0.0.1"'
'"MAP optimizationguide-pa.googleapis.com 127.0.0.1"',
'"MAP redirector.gvt1.com 127.0.0.1"',
'"MAP update.googleapis.com 127.0.0.1"',
]

ENABLE_CHROME_FEATURES = [
'NetworkService',
'NetworkServiceInProcess',
'SecMetadata'
]

DISABLE_CHROME_FEATURES = [
'InterestFeedContentSuggestions',
'AutofillServerCommunication',
'BackForwardCache',
'CalculateNativeWinOcclusion',
'TranslateUI',
'Translate',
'OfflinePagesPrefetching',
'HeavyAdPrivacyMitigations',
'AutofillServerCommunication'
'InterestFeedContentSuggestions',
'MediaRouter',
'OfflinePagesPrefetching',
'OptimizationHints',
'Translate',
]

ENABLE_BLINK_FEATURES = [
'LayoutInstabilityAPI'
]

class ChromeDesktop(DesktopBrowser, DevtoolsBrowser):
Expand Down Expand Up @@ -144,8 +144,10 @@ def launch(self, job, task):
if platform.system() == "Linux":
args.append('--disable-setuid-sandbox')
args.append('--disable-dev-shm-usage')
args.append('--enable-features=' + ','.join(features))
args.append('--enable-blink-features=' + ','.join(ENABLE_BLINK_FEATURES))
if len(features):
args.append('--enable-features=' + ','.join(features))
if len(ENABLE_BLINK_FEATURES):
args.append('--enable-blink-features=' + ','.join(ENABLE_BLINK_FEATURES))
if task['running_lighthouse']:
args.append('--headless')

Expand Down

0 comments on commit 178ab72

Please sign in to comment.