puppeteer-ruby 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d18f0aae5e331fee42f66c8140bdc3cced9c0514a03ab65460c4036a94bc6eb2
4
- data.tar.gz: babeb261ac3661a6738eb3d02dddeef22685590791fbd579483edd2da7800606
3
+ metadata.gz: e09022ffac5da45a7c40bca6b612c8a67afece662142675625794b15b89a044b
4
+ data.tar.gz: 9af45888cfcfaff3bc368facbd1b5fb28572924ccf0c8d33b05ba310894638bb
5
5
  SHA512:
6
- metadata.gz: 0d70da4b6dc257f39d020286672180d93a4fe2aa321828035eeba80aeff92e7b1f28ff07acd15396d03aad33ab84b4f3474f1c75b587cb833d90f17dde4b024f
7
- data.tar.gz: ccb8a58f1ffff28d1498c560c8f17671064ca00ce4b98af9dbc5e844ab1c77d9c28fc503c021ae019d9e799a287976fe01a88bbce3f87979d163f7d384336c0e
6
+ metadata.gz: 580410458c1e0f2ac6dd8fb678fce42ed5f12ee6a1ff70b90600b6601b945af4342db53f6b98fe73ba249a9d85e3e8d64efb664534f7b1231265dbfbeb2f8e09
7
+ data.tar.gz: adecd0293ec7b7ade882d9c331b794b4a14e2e52999c164880e7f4b0fa3d723e7bc6b44a238a5ad04c50ad0bfc9c3d5d33e60b50ea40904dc49af1506ce3e72e
data/.rubocop.yml CHANGED
@@ -149,6 +149,8 @@ Style/MethodCallWithArgsParentheses:
149
149
  # utils
150
150
  - debug_print
151
151
  - debug_puts
152
+ - exit
153
+ - puts
152
154
 
153
155
  Style/MethodCallWithoutArgsParentheses:
154
156
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
- ### main [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.38.0...main)]
1
+ ### main [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.39.0...main)]
2
2
 
3
3
  - xxx
4
4
 
5
+ ### 0.39.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.38.0...0.39.0)]
6
+
7
+ New features:
8
+
9
+ - Puppeteer 12.0 functionalities
10
+
5
11
  ### 0.38.0 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.37.4...0.38.0)]
6
12
 
7
13
  New features:
data/docs/api_coverage.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # API coverages
2
2
  - Puppeteer version: v12.0.0
3
- - puppeteer-ruby version: 0.38.0
3
+ - puppeteer-ruby version: 0.39.0
4
4
 
5
5
  ## Puppeteer
6
6
 
@@ -7,10 +7,10 @@ class Puppeteer::AriaQueryHandler
7
7
  private def parse_aria_selector(selector)
8
8
  known_attributes = %w(name role)
9
9
  query_options = {}
10
- attribute_regexp = /\[\s*(?<attribute>\w+)\s*=\s*"(?<value>\\.|[^"\\]*)"\s*\]/
10
+ attribute_regexp = /\[\s*(?<attribute>\w+)\s*=\s*(?<quote>"|')(?<value>\\.|.*?(?=\k<quote>))\k<quote>\s*\]/
11
11
  default_name = selector.gsub(attribute_regexp) do
12
12
  attribute = $1.strip
13
- value = $2
13
+ value = $3
14
14
  unless known_attributes.include?(attribute)
15
15
  raise ArgumentError.new("Unkown aria attribute \"#{attribute}\" in selector")
16
16
  end
@@ -39,7 +39,7 @@ class Puppeteer::AriaQueryHandler
39
39
  def wait_for(dom_world, selector, visible: nil, hidden: nil, timeout: nil)
40
40
  binding_function = Puppeteer::DOMWorld::BindingFunction.new(
41
41
  name: 'ariaQuerySelector',
42
- proc: -> (selector) { query_one(dom_world.send(:document), selector) },
42
+ proc: -> (sel) { query_one(dom_world.send(:document), sel) },
43
43
  )
44
44
  dom_world.send(:wait_for_selector_in_page,
45
45
  '(_, selector) => globalThis.ariaQuerySelector(selector)',
@@ -4,13 +4,17 @@ require 'timeout'
4
4
 
5
5
  # https://github.com/puppeteer/puppeteer/blob/master/lib/Launcher.js
6
6
  class Puppeteer::BrowserRunner
7
+ include Puppeteer::DebugPrint
8
+
7
9
  # @param {string} executablePath
8
10
  # @param {!Array<string>} processArguments
9
11
  # @param {string=} tempDirectory
10
- def initialize(executable_path, process_arguments, temp_directory)
12
+ def initialize(for_firefox, executable_path, process_arguments, user_data_dir, using_temp_user_data_dir)
13
+ @for_firefox = for_firefox
11
14
  @executable_path = executable_path
12
15
  @process_arguments = process_arguments
13
- @temp_directory = temp_directory
16
+ @user_data_dir = user_data_dir
17
+ @using_temp_user_data_dir = using_temp_user_data_dir
14
18
  @proc = nil
15
19
  @connection = nil
16
20
  @closed = true
@@ -90,8 +94,8 @@ class Puppeteer::BrowserRunner
90
94
  @process_closing = -> {
91
95
  @proc.dispose
92
96
  @closed = true
93
- if @temp_directory
94
- FileUtils.rm_rf(@temp_directory)
97
+ if @using_temp_user_data_dir
98
+ FileUtils.rm_rf(@user_data_dir)
95
99
  end
96
100
  }
97
101
  at_exit do
@@ -122,7 +126,7 @@ class Puppeteer::BrowserRunner
122
126
  def close
123
127
  return if @closed
124
128
 
125
- if @temp_directory
129
+ if @using_temp_user_data_dir && !@for_firefox
126
130
  kill
127
131
  elsif @connection
128
132
  begin
@@ -137,11 +141,18 @@ class Puppeteer::BrowserRunner
137
141
 
138
142
  # @return {Promise}
139
143
  def kill
140
- if @temp_directory
141
- FileUtils.rm_rf(@temp_directory)
142
- end
143
- unless @closed
144
- @proc.kill
144
+ # If the process failed to launch (for example if the browser executable path
145
+ # is invalid), then the process does not get a pid assigned. A call to
146
+ # `proc.kill` would error, as the `pid` to-be-killed can not be found.
147
+ @proc&.kill
148
+
149
+ # Attempt to remove temporary profile directory to avoid littering.
150
+ begin
151
+ if @using_temp_user_data_dir
152
+ FileUtils.rm_rf(@temp_directory)
153
+ end
154
+ rescue => err
155
+ debug_puts(err)
145
156
  end
146
157
  end
147
158
 
@@ -382,7 +382,7 @@ class Puppeteer::FrameManager
382
382
  @isolated_worlds << context_payload['name']
383
383
  end
384
384
 
385
- context = Puppeteer::ExecutionContext.new(frame._client || @client, context_payload, world)
385
+ context = Puppeteer::ExecutionContext.new(frame&._client || @client, context_payload, world)
386
386
  if world
387
387
  world.context = context
388
388
  end
@@ -27,9 +27,6 @@ module Puppeteer::Launcher
27
27
  @chrome_arg_options.args.dup
28
28
  end
29
29
 
30
- #
31
- # let temporaryUserDataDir = null;
32
-
33
30
  if chrome_arguments.none? { |arg| arg.start_with?('--remote-debugging-') }
34
31
  if @launch_options.pipe?
35
32
  chrome_arguments << '--remote-debugging-pipe'
@@ -38,10 +35,17 @@ module Puppeteer::Launcher
38
35
  end
39
36
  end
40
37
 
41
- temporary_user_data_dir = nil
42
- if chrome_arguments.none? { |arg| arg.start_with?('--user-data-dir') }
43
- temporary_user_data_dir = Dir.mktmpdir('puppeteer_dev_chrome_profile-', ENV['PUPPETEER_TMP_DIR'])
44
- chrome_arguments << "--user-data-dir=#{temporary_user_data_dir}"
38
+ user_data_dir = chrome_arguments.find { |arg| arg.start_with?('--user-data-dir') }
39
+ if user_data_dir
40
+ user_data_dir = user_data_dir.split('=').last
41
+ unless File.exist?(user_data_dir)
42
+ raise ArgumentError.new("Chrome user data dir not found at '#{user_data_dir}'")
43
+ end
44
+ using_temp_user_data_dir = false
45
+ else
46
+ user_data_dir = Dir.mktmpdir('puppeteer_dev_chrome_profile-', ENV['PUPPETEER_TMP_DIR'])
47
+ chrome_arguments << "--user-data-dir=#{user_data_dir}"
48
+ using_temp_user_data_dir = true
45
49
  end
46
50
 
47
51
  chrome_executable =
@@ -51,7 +55,13 @@ module Puppeteer::Launcher
51
55
  @launch_options.executable_path || fallback_executable_path
52
56
  end
53
57
  use_pipe = chrome_arguments.include?('--remote-debugging-pipe')
54
- runner = Puppeteer::BrowserRunner.new(chrome_executable, chrome_arguments, temporary_user_data_dir)
58
+ runner = Puppeteer::BrowserRunner.new(
59
+ false,
60
+ chrome_executable,
61
+ chrome_arguments,
62
+ user_data_dir,
63
+ using_temp_user_data_dir,
64
+ )
55
65
  runner.start(
56
66
  handle_SIGHUP: @launch_options.handle_SIGHUP?,
57
67
  handle_SIGTERM: @launch_options.handle_SIGTERM?,
@@ -61,33 +71,39 @@ module Puppeteer::Launcher
61
71
  pipe: use_pipe,
62
72
  )
63
73
 
64
- begin
65
- connection = runner.setup_connection(
66
- use_pipe: use_pipe,
67
- timeout: @launch_options.timeout,
68
- slow_mo: @browser_options.slow_mo,
69
- preferred_revision: @preferred_revision,
70
- )
71
-
72
- browser = Puppeteer::Browser.create(
73
- connection: connection,
74
- context_ids: [],
75
- ignore_https_errors: @browser_options.ignore_https_errors?,
76
- default_viewport: @browser_options.default_viewport,
77
- process: runner.proc,
78
- close_callback: -> { runner.close },
79
- )
74
+ browser =
75
+ begin
76
+ connection = runner.setup_connection(
77
+ use_pipe: use_pipe,
78
+ timeout: @launch_options.timeout,
79
+ slow_mo: @browser_options.slow_mo,
80
+ preferred_revision: @preferred_revision,
81
+ )
82
+
83
+ Puppeteer::Browser.create(
84
+ connection: connection,
85
+ context_ids: [],
86
+ ignore_https_errors: @browser_options.ignore_https_errors?,
87
+ default_viewport: @browser_options.default_viewport,
88
+ process: runner.proc,
89
+ close_callback: -> { runner.close },
90
+ )
91
+ rescue
92
+ runner.kill
93
+ raise
94
+ end
80
95
 
96
+ begin
81
97
  browser.wait_for_target(
82
98
  predicate: ->(target) { target.type == 'page' },
83
99
  timeout: @launch_options.timeout,
84
100
  )
85
-
86
- browser
87
101
  rescue
88
- runner.kill
102
+ browser.close
89
103
  raise
90
104
  end
105
+
106
+ browser
91
107
  end
92
108
 
93
109
  class DefaultArgs
@@ -31,11 +31,20 @@ module Puppeteer::Launcher
31
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 =
@@ -44,7 +53,13 @@ module Puppeteer::Launcher
44
53
  else
45
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,33 +69,39 @@ module Puppeteer::Launcher
54
69
  pipe: @launch_options.pipe?,
55
70
  )
56
71
 
57
- begin
58
- connection = runner.setup_connection(
59
- use_pipe: @launch_options.pipe?,
60
- timeout: @launch_options.timeout,
61
- slow_mo: @browser_options.slow_mo,
62
- preferred_revision: @preferred_revision,
63
- )
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
- )
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
73
93
 
94
+ begin
74
95
  browser.wait_for_target(
75
96
  predicate: ->(target) { target.type == 'page' },
76
97
  timeout: @launch_options.timeout,
77
98
  )
78
-
79
- browser
80
99
  rescue
81
- runner.kill
100
+ browser.close
82
101
  raise
83
102
  end
103
+
104
+ browser
84
105
  end
85
106
 
86
107
  # @return [Puppeteer::Browser]
@@ -190,11 +211,13 @@ module Puppeteer::Launcher
190
211
 
191
212
  # @param options [Launcher::ChromeArgOptions]
192
213
  def initialize(chrome_arg_options)
193
- firefox_arguments = ['--no-remote', '--foreground']
214
+ firefox_arguments = ['--no-remote']
194
215
 
195
- # if (os.platform().startsWith('win')) {
196
- # firefoxArguments.push('--wait-for-browser');
197
- # }
216
+ if Puppeteer.env.darwin?
217
+ firefox_arguments << '--foreground'
218
+ elsif Puppeteer.env.windows?
219
+ firefox_arguments << '--wait-for-browser'
220
+ end
198
221
 
199
222
  if chrome_arg_options.user_data_dir
200
223
  firefox_arguments << "--profile"
@@ -230,209 +253,216 @@ module Puppeteer::Launcher
230
253
  DefaultArgs.new(ChromeArgOptions.new(options || {}))
231
254
  end
232
255
 
233
- private def create_profile(extra_prefs = {})
234
- Dir.mktmpdir('puppeteer_dev_firefox_profile-', ENV['PUPPETEER_TMP_DIR']).tap do |profile_path|
235
- server = 'dummy.test'
236
- default_preferences = {
237
- # Make sure Shield doesn't hit the network.
238
- 'app.normandy.api_url': '',
239
- # Disable Firefox old build background check
240
- 'app.update.checkInstallTime': false,
241
- # Disable automatically upgrading Firefox
242
- 'app.update.disabledForTesting': true,
243
-
244
- # Increase the APZ content response timeout to 1 minute
245
- 'apz.content_response_timeout': 60000,
246
-
247
- # Prevent various error message on the console
248
- # jest-puppeteer asserts that no error message is emitted by the console
249
- 'browser.contentblocking.features.standard': '-tp,tpPrivate,cookieBehavior0,-cm,-fp',
250
-
251
- # Enable the dump function: which sends messages to the system
252
- # console
253
- # https://bugzilla.mozilla.org/show_bug.cgi?id=1543115
254
- 'browser.dom.window.dump.enabled': true,
255
- # Disable topstories
256
- 'browser.newtabpage.activity-stream.feeds.system.topstories': false,
257
- # Always display a blank page
258
- 'browser.newtabpage.enabled': false,
259
- # Background thumbnails in particular cause grief: and disabling
260
- # thumbnails in general cannot hurt
261
- 'browser.pagethumbnails.capturing_disabled': true,
262
-
263
- # Disable safebrowsing components.
264
- 'browser.safebrowsing.blockedURIs.enabled': false,
265
- 'browser.safebrowsing.downloads.enabled': false,
266
- 'browser.safebrowsing.malware.enabled': false,
267
- 'browser.safebrowsing.passwords.enabled': false,
268
- 'browser.safebrowsing.phishing.enabled': false,
269
-
270
- # Disable updates to search engines.
271
- 'browser.search.update': false,
272
- # Do not restore the last open set of tabs if the browser has crashed
273
- 'browser.sessionstore.resume_from_crash': false,
274
- # Skip check for default browser on startup
275
- 'browser.shell.checkDefaultBrowser': false,
276
-
277
- # Disable newtabpage
278
- 'browser.startup.homepage': 'about:blank',
279
- # Do not redirect user when a milstone upgrade of Firefox is detected
280
- 'browser.startup.homepage_override.mstone': 'ignore',
281
- # Start with a blank page about:blank
282
- 'browser.startup.page': 0,
283
-
284
- # Do not allow background tabs to be zombified on Android: otherwise for
285
- # tests that open additional tabs: the test harness tab itself might get
286
- # unloaded
287
- 'browser.tabs.disableBackgroundZombification': false,
288
- # Do not warn when closing all other open tabs
289
- 'browser.tabs.warnOnCloseOtherTabs': false,
290
- # Do not warn when multiple tabs will be opened
291
- 'browser.tabs.warnOnOpen': false,
292
-
293
- # Disable the UI tour.
294
- 'browser.uitour.enabled': false,
295
- # Turn off search suggestions in the location bar so as not to trigger
296
- # network connections.
297
- 'browser.urlbar.suggest.searches': false,
298
- # Disable first run splash page on Windows 10
299
- 'browser.usedOnWindows10.introURL': '',
300
- # Do not warn on quitting Firefox
301
- 'browser.warnOnQuit': false,
302
-
303
- # Defensively disable data reporting systems
304
- 'datareporting.healthreport.documentServerURI': "http://#{server}/dummy/healthreport/",
305
- 'datareporting.healthreport.logging.consoleEnabled': false,
306
- 'datareporting.healthreport.service.enabled': false,
307
- 'datareporting.healthreport.service.firstRun': false,
308
- 'datareporting.healthreport.uploadEnabled': false,
309
-
310
- # Do not show datareporting policy notifications which can interfere with tests
311
- 'datareporting.policy.dataSubmissionEnabled': false,
312
- 'datareporting.policy.dataSubmissionPolicyBypassNotification': true,
313
-
314
- # DevTools JSONViewer sometimes fails to load dependencies with its require.js.
315
- # This doesn't affect Puppeteer but spams console (Bug 1424372)
316
- 'devtools.jsonview.enabled': false,
317
-
318
- # Disable popup-blocker
319
- 'dom.disable_open_during_load': false,
320
-
321
- # Enable the support for File object creation in the content process
322
- # Required for |Page.setFileInputFiles| protocol method.
323
- 'dom.file.createInChild': true,
324
-
325
- # Disable the ProcessHangMonitor
326
- 'dom.ipc.reportProcessHangs': false,
327
-
328
- # Disable slow script dialogues
329
- 'dom.max_chrome_script_run_time': 0,
330
- 'dom.max_script_run_time': 0,
331
-
332
- # Only load extensions from the application and user profile
333
- # AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
334
- 'extensions.autoDisableScopes': 0,
335
- 'extensions.enabledScopes': 5,
336
-
337
- # Disable metadata caching for installed add-ons by default
338
- 'extensions.getAddons.cache.enabled': false,
339
-
340
- # Disable installing any distribution extensions or add-ons.
341
- 'extensions.installDistroAddons': false,
342
-
343
- # Disabled screenshots extension
344
- 'extensions.screenshots.disabled': true,
345
-
346
- # Turn off extension updates so they do not bother tests
347
- 'extensions.update.enabled': false,
348
-
349
- # Turn off extension updates so they do not bother tests
350
- 'extensions.update.notifyUser': false,
351
-
352
- # Make sure opening about:addons will not hit the network
353
- 'extensions.webservice.discoverURL': "http://#{server}/dummy/discoveryURL",
354
-
355
- # Allow the application to have focus even it runs in the background
356
- 'focusmanager.testmode': true,
357
- # Disable useragent updates
358
- 'general.useragent.updates.enabled': false,
359
- # Always use network provider for geolocation tests so we bypass the
360
- # macOS dialog raised by the corelocation provider
361
- 'geo.provider.testing': true,
362
- # Do not scan Wifi
363
- 'geo.wifi.scan': false,
364
- # No hang monitor
365
- 'hangmonitor.timeout': 0,
366
- # Show chrome errors and warnings in the error console
367
- 'javascript.options.showInConsole': true,
368
-
369
- # Disable download and usage of OpenH264: and Widevine plugins
370
- 'media.gmp-manager.updateEnabled': false,
371
- # Prevent various error message on the console
372
- # jest-puppeteer asserts that no error message is emitted by the console
373
- 'network.cookie.cookieBehavior': 0,
374
-
375
- # Do not prompt for temporary redirects
376
- 'network.http.prompt-temp-redirect': false,
377
-
378
- # Disable speculative connections so they are not reported as leaking
379
- # when they are hanging around
380
- 'network.http.speculative-parallel-limit': 0,
381
-
382
- # Do not automatically switch between offline and online
383
- 'network.manage-offline-status': false,
384
-
385
- # Make sure SNTP requests do not hit the network
386
- 'network.sntp.pools': server,
387
-
388
- # Disable Flash.
389
- 'plugin.state.flash': 0,
390
-
391
- 'privacy.trackingprotection.enabled': false,
392
-
393
- # Enable Remote Agent
394
- # https://bugzilla.mozilla.org/show_bug.cgi?id=1544393
395
- 'remote.enabled': true,
396
-
397
- # Don't do network connections for mitm priming
398
- 'security.certerrors.mitm.priming.enabled': false,
399
- # Local documents have access to all other local documents,
400
- # including directory listings
401
- 'security.fileuri.strict_origin_policy': false,
402
- # Do not wait for the notification button security delay
403
- 'security.notification_enable_delay': 0,
404
-
405
- # Ensure blocklist updates do not hit the network
406
- '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,
436
+
437
+ # Disable first-run welcome page
438
+ 'startup.homepage_welcome_url': 'about:blank',
407
439
 
408
- # Do not automatically fill sign-in forms with known usernames and
409
- # passwords
410
- 'signon.autofillForms': false,
411
- # Disable password capture, so that tests that include forms are not
412
- # influenced by the presence of the persistent doorhanger notification
413
- 'signon.rememberSignons': false,
414
-
415
- # Disable first-run welcome page
416
- 'startup.homepage_welcome_url': 'about:blank',
440
+ # Disable first-run welcome page
441
+ 'startup.homepage_welcome_url.additional': '',
417
442
 
418
- # Disable first-run welcome page
419
- 'startup.homepage_welcome_url.additional': '',
443
+ # Disable browser animations (tabs, fullscreen, sliding alerts)
444
+ 'toolkit.cosmeticAnimations.enabled': false,
420
445
 
421
- # Disable browser animations (tabs, fullscreen, sliding alerts)
422
- 'toolkit.cosmeticAnimations.enabled': false,
446
+ # Prevent starting into safe mode after application crashes
447
+ 'toolkit.startup.max_resumed_crashes': -1,
448
+ }
423
449
 
424
- # Prevent starting into safe mode after application crashes
425
- 'toolkit.startup.max_resumed_crashes': -1,
426
- }
450
+ default_preferences.merge(extra_prefs)
451
+ end
427
452
 
428
- preferences = default_preferences.merge(extra_prefs)
429
-
430
- File.open(File.join(profile_path, 'user.js'), 'w') do |f|
431
- preferences.each do |key, value|
432
- f.write("user_pref(#{JSON.generate(key)}, #{JSON.generate(value)});\n")
433
- end
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")
434
457
  end
435
- 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)
436
466
  end
437
467
  end
438
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
@@ -1,3 +1,3 @@
1
1
  module Puppeteer
2
- VERSION = '0.38.0'
2
+ VERSION = '0.39.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppeteer-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.0
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-06 00:00:00.000000000 Z
11
+ date: 2021-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby