Class: Puppeteer::Launcher::Chrome::DefaultArgs

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/puppeteer/launcher/chrome.rb

Instance Method Summary collapse

Constructor Details

#initialize(chrome_arg_options) ⇒ DefaultArgs

Returns a new instance of DefaultArgs.

Parameters:



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/puppeteer/launcher/chrome.rb', line 83

def initialize(chrome_arg_options)
  chrome_arguments = [
    '--disable-background-networking',
    '--enable-features=NetworkService,NetworkServiceInProcess',
    '--disable-background-timer-throttling',
    '--disable-backgrounding-occluded-windows',
    '--disable-breakpad',
    '--disable-client-side-phishing-detection',
    '--disable-component-extensions-with-background-pages',
    '--disable-default-apps',
    '--disable-dev-shm-usage',
    '--disable-extensions',
    '--disable-features=Translate',
    '--disable-hang-monitor',
    '--disable-ipc-flooding-protection',
    '--disable-popup-blocking',
    '--disable-prompt-on-repost',
    '--disable-renderer-backgrounding',
    '--disable-sync',
    '--force-color-profile=srgb',
    '--metrics-recording-only',
    '--no-first-run',
    '--enable-automation',
    '--password-store=basic',
    '--use-mock-keychain',
    # TODO(sadym): remove '--enable-blink-features=IdleDetection'
    # once IdleDetection is turned on by default.
    '--enable-blink-features=IdleDetection',
  ]

  if chrome_arg_options.user_data_dir
    chrome_arguments << "--user-data-dir=#{chrome_arg_options.user_data_dir}"
  end

  if chrome_arg_options.devtools?
    chrome_arguments << '--auto-open-devtools-for-tabs'
  end

  if chrome_arg_options.headless?
    chrome_arguments.concat([
      '--headless',
      '--hide-scrollbars',
      '--mute-audio',
    ])
  end

  if chrome_arg_options.args.all? { |arg| arg.start_with?('-') }
    chrome_arguments << 'about:blank'
  end

  chrome_arguments.concat(chrome_arg_options.args)

  @chrome_arguments = chrome_arguments
end

Instance Method Details

#each(&block) ⇒ Object



138
139
140
141
142
# File 'lib/puppeteer/launcher/chrome.rb', line 138

def each(&block)
  @chrome_arguments.each do |opt|
    block.call(opt)
  end
end