puppeteer-ruby 0.37.2 → 0.39.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,23 +28,38 @@ module Puppeteer::Launcher
28
28
  end
29
29
 
30
30
  if firefox_arguments.none? { |arg| arg.start_with?('--remote-debugging-') }
31
- firefox_arguments << '--remote-debugging-port=0'
31
+ firefox_arguments << "--remote-debugging-port=#{@chrome_arg_options.debugging_port}"
32
32
  end
33
33
 
34
- temporary_user_data_dir = nil
35
- if firefox_arguments.none? { |arg| arg.start_with?('--profile') || arg.start_with?('-profile') }
36
- temporary_user_data_dir = create_profile
34
+ profile_arg_index = firefox_arguments.index { |arg| arg.start_with?('--profile') || arg.start_with?('-profile') }
35
+ if profile_arg_index
36
+ using_temp_user_data_dir = false
37
+ user_data_dir = firefox_arguments[profile_arg_index + 1]
38
+ unless File.exist?(user_data_dir)
39
+ raise ArgumentError.new("Firefox profile not found at '#{user_data_dir}'")
40
+ end
41
+ prefs = default_preferences(@launch_options.extra_prefs_firefox)
42
+ write_preferences(prefs, user_data_dir)
43
+ else
44
+ using_temp_user_data_dir = true
45
+ user_data_dir = create_profile(@launch_options.extra_prefs_firefox)
37
46
  firefox_arguments << "--profile"
38
- firefox_arguments << temporary_user_data_dir
47
+ firefox_arguments << user_data_dir
39
48
  end
40
49
 
41
50
  firefox_executable =
42
51
  if @launch_options.channel
43
52
  executable_path_for_channel(@launch_options.channel.to_s)
44
53
  else
45
- @launch_options.executable_path || executable_path_for_channel('nightly')
54
+ @launch_options.executable_path || fallback_executable_path
46
55
  end
47
- runner = Puppeteer::BrowserRunner.new(firefox_executable, firefox_arguments, temporary_user_data_dir)
56
+ runner = Puppeteer::BrowserRunner.new(
57
+ true,
58
+ firefox_executable,
59
+ firefox_arguments,
60
+ user_data_dir,
61
+ using_temp_user_data_dir,
62
+ )
48
63
  runner.start(
49
64
  handle_SIGHUP: @launch_options.handle_SIGHUP?,
50
65
  handle_SIGTERM: @launch_options.handle_SIGTERM?,
@@ -54,30 +69,39 @@ module Puppeteer::Launcher
54
69
  pipe: @launch_options.pipe?,
55
70
  )
56
71
 
72
+ browser =
73
+ begin
74
+ connection = runner.setup_connection(
75
+ use_pipe: @launch_options.pipe?,
76
+ timeout: @launch_options.timeout,
77
+ slow_mo: @browser_options.slow_mo,
78
+ preferred_revision: @preferred_revision,
79
+ )
80
+
81
+ Puppeteer::Browser.create(
82
+ connection: connection,
83
+ context_ids: [],
84
+ ignore_https_errors: @browser_options.ignore_https_errors?,
85
+ default_viewport: @browser_options.default_viewport,
86
+ process: runner.proc,
87
+ close_callback: -> { runner.close },
88
+ )
89
+ rescue
90
+ runner.kill
91
+ raise
92
+ end
93
+
57
94
  begin
58
- connection = runner.setup_connection(
59
- use_pipe: @launch_options.pipe?,
95
+ browser.wait_for_target(
96
+ predicate: ->(target) { target.type == 'page' },
60
97
  timeout: @launch_options.timeout,
61
- slow_mo: @browser_options.slow_mo,
62
- preferred_revision: @preferred_revision,
63
98
  )
64
-
65
- browser = Puppeteer::Browser.create(
66
- connection: connection,
67
- context_ids: [],
68
- ignore_https_errors: @browser_options.ignore_https_errors?,
69
- default_viewport: @browser_options.default_viewport,
70
- process: runner.proc,
71
- close_callback: -> { runner.close },
72
- )
73
-
74
- browser.wait_for_target(predicate: ->(target) { target.type == 'page' })
75
-
76
- browser
77
99
  rescue
78
- runner.kill
100
+ browser.close
79
101
  raise
80
102
  end
103
+
104
+ browser
81
105
  end
82
106
 
83
107
  # @return [Puppeteer::Browser]
@@ -138,14 +162,18 @@ module Puppeteer::Launcher
138
162
  if channel
139
163
  executable_path_for_channel(channel.to_s)
140
164
  else
141
- executable_path_for_channel('firefox')
165
+ fallback_executable_path
142
166
  end
143
167
  end
144
168
 
169
+ private def fallback_executable_path
170
+ executable_path_for_channel('firefox')
171
+ end
172
+
145
173
  FIREFOX_EXECUTABLE_PATHS = {
146
174
  windows: "#{ENV['PROGRAMFILES']}\\Firefox Nightly\\firefox.exe",
147
175
  darwin: '/Applications/Firefox Nightly.app/Contents/MacOS/firefox',
148
- linux: '/usr/bin/firefox',
176
+ linux: -> { Puppeteer::ExecutablePathFinder.new('firefox').find_first },
149
177
  }.freeze
150
178
 
151
179
  # @param channel [String]
@@ -163,6 +191,9 @@ module Puppeteer::Launcher
163
191
  else
164
192
  FIREFOX_EXECUTABLE_PATHS[:linux]
165
193
  end
194
+ if firefox_path.is_a?(Proc)
195
+ firefox_path = firefox_path.call
196
+ end
166
197
 
167
198
  unless File.exist?(firefox_path)
168
199
  raise "Nightly version of Firefox is not installed on this system.\nExpected path: #{firefox_path}"
@@ -180,11 +211,13 @@ module Puppeteer::Launcher
180
211
 
181
212
  # @param options [Launcher::ChromeArgOptions]
182
213
  def initialize(chrome_arg_options)
183
- firefox_arguments = ['--no-remote', '--foreground']
214
+ firefox_arguments = ['--no-remote']
184
215
 
185
- # if (os.platform().startsWith('win')) {
186
- # firefoxArguments.push('--wait-for-browser');
187
- # }
216
+ if Puppeteer.env.darwin?
217
+ firefox_arguments << '--foreground'
218
+ elsif Puppeteer.env.windows?
219
+ firefox_arguments << '--wait-for-browser'
220
+ end
188
221
 
189
222
  if chrome_arg_options.user_data_dir
190
223
  firefox_arguments << "--profile"
@@ -220,209 +253,216 @@ module Puppeteer::Launcher
220
253
  DefaultArgs.new(ChromeArgOptions.new(options || {}))
221
254
  end
222
255
 
223
- private def create_profile(extra_prefs = {})
224
- Dir.mktmpdir('puppeteer_dev_firefox_profile-').tap do |profile_path|
225
- server = 'dummy.test'
226
- default_preferences = {
227
- # Make sure Shield doesn't hit the network.
228
- 'app.normandy.api_url': '',
229
- # Disable Firefox old build background check
230
- 'app.update.checkInstallTime': false,
231
- # Disable automatically upgrading Firefox
232
- 'app.update.disabledForTesting': true,
233
-
234
- # Increase the APZ content response timeout to 1 minute
235
- 'apz.content_response_timeout': 60000,
236
-
237
- # Prevent various error message on the console
238
- # jest-puppeteer asserts that no error message is emitted by the console
239
- 'browser.contentblocking.features.standard': '-tp,tpPrivate,cookieBehavior0,-cm,-fp',
240
-
241
- # Enable the dump function: which sends messages to the system
242
- # console
243
- # https://bugzilla.mozilla.org/show_bug.cgi?id=1543115
244
- 'browser.dom.window.dump.enabled': true,
245
- # Disable topstories
246
- 'browser.newtabpage.activity-stream.feeds.system.topstories': false,
247
- # Always display a blank page
248
- 'browser.newtabpage.enabled': false,
249
- # Background thumbnails in particular cause grief: and disabling
250
- # thumbnails in general cannot hurt
251
- 'browser.pagethumbnails.capturing_disabled': true,
252
-
253
- # Disable safebrowsing components.
254
- 'browser.safebrowsing.blockedURIs.enabled': false,
255
- 'browser.safebrowsing.downloads.enabled': false,
256
- 'browser.safebrowsing.malware.enabled': false,
257
- 'browser.safebrowsing.passwords.enabled': false,
258
- 'browser.safebrowsing.phishing.enabled': false,
259
-
260
- # Disable updates to search engines.
261
- 'browser.search.update': false,
262
- # Do not restore the last open set of tabs if the browser has crashed
263
- 'browser.sessionstore.resume_from_crash': false,
264
- # Skip check for default browser on startup
265
- 'browser.shell.checkDefaultBrowser': false,
266
-
267
- # Disable newtabpage
268
- 'browser.startup.homepage': 'about:blank',
269
- # Do not redirect user when a milstone upgrade of Firefox is detected
270
- 'browser.startup.homepage_override.mstone': 'ignore',
271
- # Start with a blank page about:blank
272
- 'browser.startup.page': 0,
273
-
274
- # Do not allow background tabs to be zombified on Android: otherwise for
275
- # tests that open additional tabs: the test harness tab itself might get
276
- # unloaded
277
- 'browser.tabs.disableBackgroundZombification': false,
278
- # Do not warn when closing all other open tabs
279
- 'browser.tabs.warnOnCloseOtherTabs': false,
280
- # Do not warn when multiple tabs will be opened
281
- 'browser.tabs.warnOnOpen': false,
282
-
283
- # Disable the UI tour.
284
- 'browser.uitour.enabled': false,
285
- # Turn off search suggestions in the location bar so as not to trigger
286
- # network connections.
287
- 'browser.urlbar.suggest.searches': false,
288
- # Disable first run splash page on Windows 10
289
- 'browser.usedOnWindows10.introURL': '',
290
- # Do not warn on quitting Firefox
291
- 'browser.warnOnQuit': false,
292
-
293
- # Defensively disable data reporting systems
294
- 'datareporting.healthreport.documentServerURI': "http://#{server}/dummy/healthreport/",
295
- 'datareporting.healthreport.logging.consoleEnabled': false,
296
- 'datareporting.healthreport.service.enabled': false,
297
- 'datareporting.healthreport.service.firstRun': false,
298
- 'datareporting.healthreport.uploadEnabled': false,
299
-
300
- # Do not show datareporting policy notifications which can interfere with tests
301
- 'datareporting.policy.dataSubmissionEnabled': false,
302
- 'datareporting.policy.dataSubmissionPolicyBypassNotification': true,
303
-
304
- # DevTools JSONViewer sometimes fails to load dependencies with its require.js.
305
- # This doesn't affect Puppeteer but spams console (Bug 1424372)
306
- 'devtools.jsonview.enabled': false,
307
-
308
- # Disable popup-blocker
309
- 'dom.disable_open_during_load': false,
310
-
311
- # Enable the support for File object creation in the content process
312
- # Required for |Page.setFileInputFiles| protocol method.
313
- 'dom.file.createInChild': true,
314
-
315
- # Disable the ProcessHangMonitor
316
- 'dom.ipc.reportProcessHangs': false,
317
-
318
- # Disable slow script dialogues
319
- 'dom.max_chrome_script_run_time': 0,
320
- 'dom.max_script_run_time': 0,
321
-
322
- # Only load extensions from the application and user profile
323
- # AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
324
- 'extensions.autoDisableScopes': 0,
325
- 'extensions.enabledScopes': 5,
326
-
327
- # Disable metadata caching for installed add-ons by default
328
- 'extensions.getAddons.cache.enabled': false,
329
-
330
- # Disable installing any distribution extensions or add-ons.
331
- 'extensions.installDistroAddons': false,
332
-
333
- # Disabled screenshots extension
334
- 'extensions.screenshots.disabled': true,
335
-
336
- # Turn off extension updates so they do not bother tests
337
- 'extensions.update.enabled': false,
338
-
339
- # Turn off extension updates so they do not bother tests
340
- 'extensions.update.notifyUser': false,
341
-
342
- # Make sure opening about:addons will not hit the network
343
- 'extensions.webservice.discoverURL': "http://#{server}/dummy/discoveryURL",
344
-
345
- # Allow the application to have focus even it runs in the background
346
- 'focusmanager.testmode': true,
347
- # Disable useragent updates
348
- 'general.useragent.updates.enabled': false,
349
- # Always use network provider for geolocation tests so we bypass the
350
- # macOS dialog raised by the corelocation provider
351
- 'geo.provider.testing': true,
352
- # Do not scan Wifi
353
- 'geo.wifi.scan': false,
354
- # No hang monitor
355
- 'hangmonitor.timeout': 0,
356
- # Show chrome errors and warnings in the error console
357
- 'javascript.options.showInConsole': true,
358
-
359
- # Disable download and usage of OpenH264: and Widevine plugins
360
- 'media.gmp-manager.updateEnabled': false,
361
- # Prevent various error message on the console
362
- # jest-puppeteer asserts that no error message is emitted by the console
363
- 'network.cookie.cookieBehavior': 0,
364
-
365
- # Do not prompt for temporary redirects
366
- 'network.http.prompt-temp-redirect': false,
367
-
368
- # Disable speculative connections so they are not reported as leaking
369
- # when they are hanging around
370
- 'network.http.speculative-parallel-limit': 0,
371
-
372
- # Do not automatically switch between offline and online
373
- 'network.manage-offline-status': false,
374
-
375
- # Make sure SNTP requests do not hit the network
376
- 'network.sntp.pools': server,
377
-
378
- # Disable Flash.
379
- 'plugin.state.flash': 0,
380
-
381
- 'privacy.trackingprotection.enabled': false,
382
-
383
- # Enable Remote Agent
384
- # https://bugzilla.mozilla.org/show_bug.cgi?id=1544393
385
- 'remote.enabled': true,
386
-
387
- # Don't do network connections for mitm priming
388
- 'security.certerrors.mitm.priming.enabled': false,
389
- # Local documents have access to all other local documents,
390
- # including directory listings
391
- 'security.fileuri.strict_origin_policy': false,
392
- # Do not wait for the notification button security delay
393
- 'security.notification_enable_delay': 0,
394
-
395
- # Ensure blocklist updates do not hit the network
396
- 'services.settings.server': "http://#{server}/dummy/blocklist/",
256
+ private def default_preferences(extra_prefs)
257
+ server = 'dummy.test'
258
+ default_preferences = {
259
+ # Make sure Shield doesn't hit the network.
260
+ 'app.normandy.api_url': '',
261
+ # Disable Firefox old build background check
262
+ 'app.update.checkInstallTime': false,
263
+ # Disable automatically upgrading Firefox
264
+ 'app.update.disabledForTesting': true,
265
+
266
+ # Increase the APZ content response timeout to 1 minute
267
+ 'apz.content_response_timeout': 60000,
268
+
269
+ # Prevent various error message on the console
270
+ # jest-puppeteer asserts that no error message is emitted by the console
271
+ 'browser.contentblocking.features.standard': '-tp,tpPrivate,cookieBehavior0,-cm,-fp',
272
+
273
+ # Enable the dump function: which sends messages to the system
274
+ # console
275
+ # https://bugzilla.mozilla.org/show_bug.cgi?id=1543115
276
+ 'browser.dom.window.dump.enabled': true,
277
+ # Disable topstories
278
+ 'browser.newtabpage.activity-stream.feeds.system.topstories': false,
279
+ # Always display a blank page
280
+ 'browser.newtabpage.enabled': false,
281
+ # Background thumbnails in particular cause grief: and disabling
282
+ # thumbnails in general cannot hurt
283
+ 'browser.pagethumbnails.capturing_disabled': true,
284
+
285
+ # Disable safebrowsing components.
286
+ 'browser.safebrowsing.blockedURIs.enabled': false,
287
+ 'browser.safebrowsing.downloads.enabled': false,
288
+ 'browser.safebrowsing.malware.enabled': false,
289
+ 'browser.safebrowsing.passwords.enabled': false,
290
+ 'browser.safebrowsing.phishing.enabled': false,
291
+
292
+ # Disable updates to search engines.
293
+ 'browser.search.update': false,
294
+ # Do not restore the last open set of tabs if the browser has crashed
295
+ 'browser.sessionstore.resume_from_crash': false,
296
+ # Skip check for default browser on startup
297
+ 'browser.shell.checkDefaultBrowser': false,
298
+
299
+ # Disable newtabpage
300
+ 'browser.startup.homepage': 'about:blank',
301
+ # Do not redirect user when a milstone upgrade of Firefox is detected
302
+ 'browser.startup.homepage_override.mstone': 'ignore',
303
+ # Start with a blank page about:blank
304
+ 'browser.startup.page': 0,
305
+
306
+ # Do not allow background tabs to be zombified on Android: otherwise for
307
+ # tests that open additional tabs: the test harness tab itself might get
308
+ # unloaded
309
+ 'browser.tabs.disableBackgroundZombification': false,
310
+ # Do not warn when closing all other open tabs
311
+ 'browser.tabs.warnOnCloseOtherTabs': false,
312
+ # Do not warn when multiple tabs will be opened
313
+ 'browser.tabs.warnOnOpen': false,
314
+
315
+ # Disable the UI tour.
316
+ 'browser.uitour.enabled': false,
317
+ # Turn off search suggestions in the location bar so as not to trigger
318
+ # network connections.
319
+ 'browser.urlbar.suggest.searches': false,
320
+ # Disable first run splash page on Windows 10
321
+ 'browser.usedOnWindows10.introURL': '',
322
+ # Do not warn on quitting Firefox
323
+ 'browser.warnOnQuit': false,
324
+
325
+ # Defensively disable data reporting systems
326
+ 'datareporting.healthreport.documentServerURI': "http://#{server}/dummy/healthreport/",
327
+ 'datareporting.healthreport.logging.consoleEnabled': false,
328
+ 'datareporting.healthreport.service.enabled': false,
329
+ 'datareporting.healthreport.service.firstRun': false,
330
+ 'datareporting.healthreport.uploadEnabled': false,
331
+
332
+ # Do not show datareporting policy notifications which can interfere with tests
333
+ 'datareporting.policy.dataSubmissionEnabled': false,
334
+ 'datareporting.policy.dataSubmissionPolicyBypassNotification': true,
335
+
336
+ # DevTools JSONViewer sometimes fails to load dependencies with its require.js.
337
+ # This doesn't affect Puppeteer but spams console (Bug 1424372)
338
+ 'devtools.jsonview.enabled': false,
339
+
340
+ # Disable popup-blocker
341
+ 'dom.disable_open_during_load': false,
342
+
343
+ # Enable the support for File object creation in the content process
344
+ # Required for |Page.setFileInputFiles| protocol method.
345
+ 'dom.file.createInChild': true,
346
+
347
+ # Disable the ProcessHangMonitor
348
+ 'dom.ipc.reportProcessHangs': false,
349
+
350
+ # Disable slow script dialogues
351
+ 'dom.max_chrome_script_run_time': 0,
352
+ 'dom.max_script_run_time': 0,
353
+
354
+ # Only load extensions from the application and user profile
355
+ # AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
356
+ 'extensions.autoDisableScopes': 0,
357
+ 'extensions.enabledScopes': 5,
358
+
359
+ # Disable metadata caching for installed add-ons by default
360
+ 'extensions.getAddons.cache.enabled': false,
361
+
362
+ # Disable installing any distribution extensions or add-ons.
363
+ 'extensions.installDistroAddons': false,
364
+
365
+ # Disabled screenshots extension
366
+ 'extensions.screenshots.disabled': true,
367
+
368
+ # Turn off extension updates so they do not bother tests
369
+ 'extensions.update.enabled': false,
370
+
371
+ # Turn off extension updates so they do not bother tests
372
+ 'extensions.update.notifyUser': false,
373
+
374
+ # Make sure opening about:addons will not hit the network
375
+ 'extensions.webservice.discoverURL': "http://#{server}/dummy/discoveryURL",
376
+
377
+ # Allow the application to have focus even it runs in the background
378
+ 'focusmanager.testmode': true,
379
+ # Disable useragent updates
380
+ 'general.useragent.updates.enabled': false,
381
+ # Always use network provider for geolocation tests so we bypass the
382
+ # macOS dialog raised by the corelocation provider
383
+ 'geo.provider.testing': true,
384
+ # Do not scan Wifi
385
+ 'geo.wifi.scan': false,
386
+ # No hang monitor
387
+ 'hangmonitor.timeout': 0,
388
+ # Show chrome errors and warnings in the error console
389
+ 'javascript.options.showInConsole': true,
390
+
391
+ # Disable download and usage of OpenH264: and Widevine plugins
392
+ 'media.gmp-manager.updateEnabled': false,
393
+ # Prevent various error message on the console
394
+ # jest-puppeteer asserts that no error message is emitted by the console
395
+ 'network.cookie.cookieBehavior': 0,
396
+
397
+ # Do not prompt for temporary redirects
398
+ 'network.http.prompt-temp-redirect': false,
399
+
400
+ # Disable speculative connections so they are not reported as leaking
401
+ # when they are hanging around
402
+ 'network.http.speculative-parallel-limit': 0,
403
+
404
+ # Do not automatically switch between offline and online
405
+ 'network.manage-offline-status': false,
406
+
407
+ # Make sure SNTP requests do not hit the network
408
+ 'network.sntp.pools': server,
409
+
410
+ # Disable Flash.
411
+ 'plugin.state.flash': 0,
412
+
413
+ 'privacy.trackingprotection.enabled': false,
414
+
415
+ # Enable Remote Agent
416
+ # https://bugzilla.mozilla.org/show_bug.cgi?id=1544393
417
+ 'remote.enabled': true,
418
+
419
+ # Don't do network connections for mitm priming
420
+ 'security.certerrors.mitm.priming.enabled': false,
421
+ # Local documents have access to all other local documents,
422
+ # including directory listings
423
+ 'security.fileuri.strict_origin_policy': false,
424
+ # Do not wait for the notification button security delay
425
+ 'security.notification_enable_delay': 0,
426
+
427
+ # Ensure blocklist updates do not hit the network
428
+ 'services.settings.server': "http://#{server}/dummy/blocklist/",
429
+
430
+ # Do not automatically fill sign-in forms with known usernames and
431
+ # passwords
432
+ 'signon.autofillForms': false,
433
+ # Disable password capture, so that tests that include forms are not
434
+ # influenced by the presence of the persistent doorhanger notification
435
+ 'signon.rememberSignons': false,
397
436
 
398
- # Do not automatically fill sign-in forms with known usernames and
399
- # passwords
400
- 'signon.autofillForms': false,
401
- # Disable password capture, so that tests that include forms are not
402
- # influenced by the presence of the persistent doorhanger notification
403
- 'signon.rememberSignons': false,
404
-
405
- # Disable first-run welcome page
406
- 'startup.homepage_welcome_url': 'about:blank',
437
+ # Disable first-run welcome page
438
+ 'startup.homepage_welcome_url': 'about:blank',
407
439
 
408
- # Disable first-run welcome page
409
- 'startup.homepage_welcome_url.additional': '',
440
+ # Disable first-run welcome page
441
+ 'startup.homepage_welcome_url.additional': '',
410
442
 
411
- # Disable browser animations (tabs, fullscreen, sliding alerts)
412
- 'toolkit.cosmeticAnimations.enabled': false,
443
+ # Disable browser animations (tabs, fullscreen, sliding alerts)
444
+ 'toolkit.cosmeticAnimations.enabled': false,
413
445
 
414
- # Prevent starting into safe mode after application crashes
415
- 'toolkit.startup.max_resumed_crashes': -1,
416
- }
446
+ # Prevent starting into safe mode after application crashes
447
+ 'toolkit.startup.max_resumed_crashes': -1,
448
+ }
417
449
 
418
- preferences = default_preferences.merge(extra_prefs)
419
-
420
- File.open(File.join(profile_path, 'user.js'), 'w') do |f|
421
- preferences.each do |key, value|
422
- f.write("user_pref(#{JSON.generate(key)}, #{JSON.generate(value)});\n")
423
- end
450
+ default_preferences.merge(extra_prefs)
451
+ end
452
+
453
+ private def write_preferences(prefs, profile_path)
454
+ File.open(File.join(profile_path, 'user.js'), 'w') do |f|
455
+ prefs.each do |key, value|
456
+ f.write("user_pref(#{JSON.generate(key)}, #{JSON.generate(value)});\n")
424
457
  end
425
- IO.write(File.join(profile_path, 'prefs.js'), "")
458
+ end
459
+ IO.write(File.join(profile_path, 'prefs.js'), "")
460
+ end
461
+
462
+ private def create_profile(extra_prefs)
463
+ Dir.mktmpdir('puppeteer_dev_firefox_profile-', ENV['PUPPETEER_TMP_DIR']).tap do |profile_path|
464
+ prefs = default_preferences(extra_prefs)
465
+ write_preferences(prefs, profile_path)
426
466
  end
427
467
  end
428
468
  end
@@ -42,9 +42,10 @@ module Puppeteer::Launcher
42
42
  @dumpio = options[:dumpio] || false
43
43
  @env = options[:env] || ENV
44
44
  @pipe = options[:pipe] || false
45
+ @extra_prefs_firefox = options[:extra_prefs_firefox] || {}
45
46
  end
46
47
 
47
- attr_reader :channel, :executable_path, :ignore_default_args, :timeout, :env
48
+ attr_reader :channel, :executable_path, :ignore_default_args, :timeout, :env, :extra_prefs_firefox
48
49
 
49
50
  def handle_SIGINT?
50
51
  @handle_SIGINT
@@ -34,7 +34,7 @@ class Puppeteer::Page
34
34
  @type ||= 'png'
35
35
 
36
36
  if options[:quality]
37
- unless @type == 'jpeg'
37
+ if @type != 'jpeg' && @type != 'webp'
38
38
  raise ArgumentError.new("options.quality is unsupported for the #{@type} screenshots")
39
39
  end
40
40
  unless options[:quality].is_a?(Numeric)