puppeteer-ruby 0.52.1 → 0.53.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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/docs/api_coverage.md +16 -15
  3. data/lib/puppeteer/accessibility.rb +300 -0
  4. data/lib/puppeteer/browser.rb +107 -8
  5. data/lib/puppeteer/browser_connector.rb +1 -0
  6. data/lib/puppeteer/browser_context.rb +0 -1
  7. data/lib/puppeteer/cdp_session.rb +29 -8
  8. data/lib/puppeteer/chrome_target_manager.rb +145 -34
  9. data/lib/puppeteer/connection.rb +19 -0
  10. data/lib/puppeteer/coverage.rb +5 -0
  11. data/lib/puppeteer/css_coverage.rb +4 -0
  12. data/lib/puppeteer/dialog.rb +5 -0
  13. data/lib/puppeteer/element_handle.rb +2 -3
  14. data/lib/puppeteer/emulation_manager.rb +70 -9
  15. data/lib/puppeteer/events.rb +2 -0
  16. data/lib/puppeteer/execution_context.rb +7 -0
  17. data/lib/puppeteer/extension.rb +20 -6
  18. data/lib/puppeteer/frame.rb +7 -3
  19. data/lib/puppeteer/frame_manager.rb +71 -26
  20. data/lib/puppeteer/http_response.rb +15 -1
  21. data/lib/puppeteer/isolated_world.rb +10 -4
  22. data/lib/puppeteer/js_coverage.rb +4 -0
  23. data/lib/puppeteer/keyboard.rb +6 -0
  24. data/lib/puppeteer/launcher/browser_options.rb +13 -1
  25. data/lib/puppeteer/launcher/chrome.rb +48 -4
  26. data/lib/puppeteer/lifecycle_watcher.rb +1 -6
  27. data/lib/puppeteer/locators.rb +54 -26
  28. data/lib/puppeteer/mouse.rb +12 -24
  29. data/lib/puppeteer/network_manager.rb +16 -4
  30. data/lib/puppeteer/page.rb +259 -33
  31. data/lib/puppeteer/puppeteer.rb +6 -5
  32. data/lib/puppeteer/screen_recorder.rb +269 -0
  33. data/lib/puppeteer/target.rb +7 -3
  34. data/lib/puppeteer/touch_screen.rb +6 -0
  35. data/lib/puppeteer/tracing.rb +4 -0
  36. data/lib/puppeteer/version.rb +2 -2
  37. data/lib/puppeteer/wait_task.rb +1 -2
  38. data/lib/puppeteer/web_mcp.rb +227 -0
  39. data/lib/puppeteer/web_worker.rb +135 -9
  40. data/lib/puppeteer.rb +11 -1
  41. data/puppeteer-ruby.gemspec +1 -0
  42. data/sig/_supplementary.rbs +33 -1
  43. data/sig/puppeteer/accessibility.rbs +73 -0
  44. data/sig/puppeteer/browser.rbs +27 -3
  45. data/sig/puppeteer/cdp_session.rbs +4 -0
  46. data/sig/puppeteer/dialog.rbs +3 -0
  47. data/sig/puppeteer/element_handle.rbs +1 -2
  48. data/sig/puppeteer/execution_context.rbs +5 -0
  49. data/sig/puppeteer/extension.rbs +4 -0
  50. data/sig/puppeteer/frame.rbs +4 -2
  51. data/sig/puppeteer/http_response.rbs +4 -0
  52. data/sig/puppeteer/keyboard.rbs +4 -0
  53. data/sig/puppeteer/locators.rbs +3 -4
  54. data/sig/puppeteer/mouse.rbs +5 -6
  55. data/sig/puppeteer/page.rbs +48 -4
  56. data/sig/puppeteer/puppeteer.rbs +4 -5
  57. data/sig/puppeteer/screen_recorder.rbs +48 -0
  58. data/sig/puppeteer/touch_screen.rbs +4 -0
  59. data/sig/puppeteer/web_mcp.rbs +112 -0
  60. data/sig/puppeteer/web_worker.rbs +39 -0
  61. metadata +22 -2
@@ -8,8 +8,12 @@ class Puppeteer::WorkerWorld
8
8
  def initialize(client)
9
9
  @client = client
10
10
  @context_promise = Async::Promise.new
11
+ @task_manager = Puppeteer::TaskManager.new
12
+ @disposed = false
11
13
  end
12
14
 
15
+ attr_reader :task_manager
16
+
13
17
  # @rbs context: Puppeteer::ExecutionContext -- Execution context to bind
14
18
  # @rbs return: void -- No return value
15
19
  def set_context(context)
@@ -18,6 +22,11 @@ class Puppeteer::WorkerWorld
18
22
 
19
23
  # @rbs return: Puppeteer::ExecutionContext -- Worker execution context
20
24
  def execution_context
25
+ if @disposed
26
+ raise Puppeteer::WaitTask::TerminatedError.new(
27
+ 'waitForFunction failed: worker got detached.',
28
+ )
29
+ end
21
30
  @context_promise.wait
22
31
  end
23
32
 
@@ -39,6 +48,30 @@ class Puppeteer::WorkerWorld
39
48
 
40
49
  define_async_method :async_evaluate_handle
41
50
 
51
+ # @rbs page_function: String -- Function or expression to evaluate
52
+ # @rbs args: Array[untyped] -- Arguments for evaluation
53
+ # @rbs polling: (Integer | String)? -- Polling interval or mode
54
+ # @rbs timeout: Integer? -- Maximum wait time in milliseconds
55
+ # @rbs return: Puppeteer::JSHandle -- Handle to the truthy evaluation result
56
+ def wait_for_function(page_function, args: [], polling: nil, timeout: nil)
57
+ runner = lambda do
58
+ wait_task = Puppeteer::WaitTask.new(
59
+ dom_world: self,
60
+ predicate_body: page_function,
61
+ title: 'function',
62
+ polling: polling || 100,
63
+ timeout: timeout.nil? ? 30_000 : timeout,
64
+ args: args,
65
+ )
66
+ wait_task.await_promise
67
+ end
68
+ return runner.call if Async::Task.current?
69
+
70
+ Sync { runner.call }
71
+ end
72
+
73
+ define_async_method :async_wait_for_function
74
+
42
75
  # @rbs return: nil -- Workers do not have frames
43
76
  def frame
44
77
  nil
@@ -46,7 +79,18 @@ class Puppeteer::WorkerWorld
46
79
 
47
80
  # @rbs return: void -- Dispose world resources
48
81
  def dispose
49
- @context_promise = Async::Promise.new
82
+ return if @disposed
83
+
84
+ @disposed = true
85
+ error = Puppeteer::WaitTask::TerminatedError.new(
86
+ 'waitForFunction failed: worker got detached.',
87
+ )
88
+ @context_promise.reject(error) unless @context_promise.resolved?
89
+ @task_manager.terminate_all(error)
90
+ end
91
+
92
+ def detached?
93
+ @disposed
50
94
  end
51
95
  end
52
96
 
@@ -96,6 +140,22 @@ class Puppeteer::WebWorker
96
140
 
97
141
  define_async_method :async_evaluate_handle
98
142
 
143
+ # @rbs page_function: String -- Function or expression to evaluate
144
+ # @rbs args: Array[untyped] -- Arguments for evaluation
145
+ # @rbs polling: (Integer | String)? -- Polling interval or mode
146
+ # @rbs timeout: Integer? -- Maximum wait time in milliseconds
147
+ # @rbs return: Puppeteer::JSHandle -- Handle to the truthy evaluation result
148
+ def wait_for_function(page_function, args: [], polling: nil, timeout: nil)
149
+ main_realm.wait_for_function(
150
+ page_function,
151
+ args: args,
152
+ polling: polling || 100,
153
+ timeout: timeout.nil? ? @timeout_settings.timeout : timeout,
154
+ )
155
+ end
156
+
157
+ define_async_method :async_wait_for_function
158
+
99
159
  # @rbs return: void -- Not supported
100
160
  def close
101
161
  raise Puppeteer::Error.new('WebWorker.close() is not supported')
@@ -118,14 +178,29 @@ class Puppeteer::CdpWebWorker < Puppeteer::WebWorker
118
178
  @target_id = target_id
119
179
  @target_type = target_type
120
180
  @world = Puppeteer::WorkerWorld.new(@client)
181
+ @worker_loaded_promise = Async::Promise.new
121
182
 
122
183
  @client.once('Runtime.executionContextCreated') do |event|
123
184
  @world.set_context(Puppeteer::ExecutionContext.new(@client, event['context'], @world))
124
185
  end
125
- if console_api_called
126
- @client.on_event('Runtime.consoleAPICalled') do |event|
127
- console_api_called.call(@world, event)
186
+ @client.once('Inspector.workerScriptLoaded') do
187
+ @worker_loaded_promise.resolve(nil) unless @worker_loaded_promise.resolved?
188
+ end
189
+ @client.on_event('Runtime.consoleAPICalled') do |event|
190
+ values = event['args'].map do |arg|
191
+ remote_object = Puppeteer::RemoteObject.new(arg)
192
+ Puppeteer::JSHandle.create(context: @world.execution_context, remote_object: remote_object)
128
193
  end
194
+ console_api_called&.call(@world, event)
195
+ emit_event(
196
+ 'console',
197
+ Puppeteer::ConsoleMessage.new(
198
+ event['type'],
199
+ values.map { |value| console_value_from_js_handle(value) }.join(' '),
200
+ values,
201
+ console_message_locations(event['stackTrace']),
202
+ ),
203
+ )
129
204
  end
130
205
  if exception_thrown
131
206
  @client.on_event('Runtime.exceptionThrown') do |event|
@@ -138,11 +213,9 @@ class Puppeteer::CdpWebWorker < Puppeteer::WebWorker
138
213
 
139
214
  if network_manager
140
215
  Async do
141
- begin
142
- network_manager.add_client(@client)
143
- rescue => err
144
- debug_puts(err)
145
- end
216
+ network_manager.add_client(@client)
217
+ rescue => err
218
+ debug_puts(err)
146
219
  end
147
220
  end
148
221
 
@@ -159,6 +232,59 @@ class Puppeteer::CdpWebWorker < Puppeteer::WebWorker
159
232
  @client
160
233
  end
161
234
 
235
+ # @rbs page_function: String -- Function or expression to evaluate
236
+ # @rbs args: Array[untyped] -- Arguments for evaluation
237
+ # @rbs return: untyped -- Evaluation result
238
+ def evaluate(page_function, *args)
239
+ @worker_loaded_promise.wait
240
+ super
241
+ end
242
+
243
+ # @rbs page_function: String -- Function or expression to evaluate
244
+ # @rbs args: Array[untyped] -- Arguments for evaluation
245
+ # @rbs return: Puppeteer::JSHandle -- Handle to evaluation result
246
+ def evaluate_handle(page_function, *args)
247
+ @worker_loaded_promise.wait
248
+ super
249
+ end
250
+
251
+ # @rbs page_function: String -- Function or expression to evaluate
252
+ # @rbs args: Array[untyped] -- Arguments for evaluation
253
+ # @rbs polling: (Integer | String)? -- Polling interval or mode
254
+ # @rbs timeout: Integer? -- Maximum wait time in milliseconds
255
+ # @rbs return: Puppeteer::JSHandle -- Handle to the truthy evaluation result
256
+ def wait_for_function(page_function, args: [], polling: nil, timeout: nil)
257
+ @worker_loaded_promise.wait
258
+ super
259
+ end
260
+
261
+ private def console_value_from_js_handle(handle)
262
+ remote_object = handle.remote_object
263
+ return remote_object.value unless remote_object.object_id?
264
+
265
+ description = remote_object.description.to_s
266
+ if remote_object.sub_type == 'error' && !description.empty?
267
+ newline_index = description.index("\n")
268
+ return newline_index ? description[0...newline_index] : description
269
+ end
270
+
271
+ type = remote_object.sub_type || remote_object.type
272
+ class_name = remote_object.class_name || remote_object.description || 'Object'
273
+ "[#{type} #{class_name}]"
274
+ end
275
+
276
+ private def console_message_locations(stack_trace)
277
+ return [] unless stack_trace && stack_trace['callFrames']
278
+
279
+ stack_trace['callFrames'].map do |call_frame|
280
+ Puppeteer::ConsoleMessage::Location.new(
281
+ url: call_frame['url'],
282
+ line_number: call_frame['lineNumber'],
283
+ column_number: call_frame['columnNumber'],
284
+ )
285
+ end
286
+ end
287
+
162
288
  # @rbs return: void -- Close the worker
163
289
  def close
164
290
  connection = @client.connection
data/lib/puppeteer.rb CHANGED
@@ -1,4 +1,11 @@
1
- require "async"
1
+ require 'async'
2
+ begin
3
+ require 'urlpattern'
4
+ rescue LoadError
5
+ # urlpattern 0.1.1's precompiled gems do not load their versioned extension
6
+ # through the public entrypoint. Source-built gems use the public entrypoint.
7
+ require "urlpattern/#{RUBY_VERSION[/\A\d+\.\d+/]}/urlpattern"
8
+ end
2
9
  require 'puppeteer/console_patch'
3
10
 
4
11
  # Check for Ruby versions affected by https://bugs.ruby-lang.org/issues/20907
@@ -36,6 +43,7 @@ require "puppeteer/reactor_runner"
36
43
 
37
44
  # Classes & values.
38
45
  require 'puppeteer/aria_query_handler'
46
+ require 'puppeteer/accessibility'
39
47
  require 'puppeteer/browser'
40
48
  require 'puppeteer/browser_context'
41
49
  require 'puppeteer/browser_runner'
@@ -76,6 +84,7 @@ require 'puppeteer/p_selector_parser'
76
84
  require 'puppeteer/p_query_handler'
77
85
  require 'puppeteer/query_handler_manager'
78
86
  require 'puppeteer/remote_object'
87
+ require 'puppeteer/screen_recorder'
79
88
  require 'puppeteer/target'
80
89
  require 'puppeteer/task_manager'
81
90
  require 'puppeteer/tracing'
@@ -85,6 +94,7 @@ require 'puppeteer/touch_handle'
85
94
  require 'puppeteer/touch_screen'
86
95
  require 'puppeteer/version'
87
96
  require 'puppeteer/wait_task'
97
+ require 'puppeteer/web_mcp'
88
98
  require 'puppeteer/web_worker'
89
99
  require 'puppeteer/web_socket_transport'
90
100
 
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "async-websocket", ">= 0.27", "< 1.0"
29
29
  spec.add_dependency 'base64'
30
30
  spec.add_dependency 'mime-types', '>= 3.0'
31
+ spec.add_dependency 'urlpattern', '~> 0.1.1'
31
32
  spec.add_development_dependency 'bundler'
32
33
  spec.add_development_dependency 'chunky_png'
33
34
  spec.add_development_dependency 'dry-inflector'
@@ -175,10 +175,14 @@ class Puppeteer::FrameManager
175
175
  def handle_execution_context_destroyed: (Integer execution_context_id, Puppeteer::CDPSession session) -> void
176
176
  def handle_execution_contexts_cleared: (Puppeteer::CDPSession session) -> void
177
177
  def execution_context_by_id: (Integer context_id, Puppeteer::CDPSession session) -> Puppeteer::ExecutionContext
178
+ def swap_frame_tree: (Puppeteer::CDPSession client) -> void
179
+ def register_speculative_session: (Puppeteer::CDPSession client) -> void
178
180
 
179
181
  private
180
182
 
181
183
  def setup_listeners: (Puppeteer::CDPSession client) -> void
184
+ def setup_client_disconnect_listener: (Puppeteer::CDPSession client) -> void
185
+ def handle_client_disconnect: (Puppeteer::CDPSession client) -> void
182
186
  def init: (String target_id, ?Puppeteer::CDPSession cdp_session) -> void
183
187
  def with_frame_tree_handled: () { () -> void } -> void
184
188
  def prepare_frame_tree_handling: () -> void
@@ -191,7 +195,6 @@ class Puppeteer::FrameManager
191
195
  def assert_no_legacy_navigation_options: (wait_until: (String | Array[String] | nil)) -> void
192
196
  def extension_origin?: (untyped origin) -> bool
193
197
  def extract_extension_id: (untyped origin) -> String?
194
- def maybe_setup_block_list: (Puppeteer::CDPSession client) -> void
195
198
  def blocked_url?: (String? url) -> bool
196
199
  end
197
200
 
@@ -219,6 +222,7 @@ class Puppeteer::Target
219
222
  def closed_callback: () -> void
220
223
  def ignore_initialize_callback_promise: () -> void
221
224
  def initialized?: () -> bool
225
+ def exposed?: () -> bool
222
226
  def session: () -> Puppeteer::CDPSession?
223
227
  def create_cdp_session: () -> Puppeteer::CDPSession
224
228
  def target_manager: () -> untyped
@@ -277,6 +281,10 @@ class Puppeteer::Connection
277
281
  include Puppeteer::DebugPrint
278
282
  include Puppeteer::EventCallbackable
279
283
 
284
+ class ProtocolError < Puppeteer::Error
285
+ def initialize: (method: String, error_message: String, ?error_data: untyped) -> void
286
+ end
287
+
280
288
  def initialize: (String url, Puppeteer::WebSocketTransport transport, ?Numeric delay, ?protocol_timeout: Numeric?) -> void
281
289
  def closed?: () -> bool
282
290
  def self.from_session: (Puppeteer::CDPSession session) -> Puppeteer::Connection?
@@ -291,6 +299,7 @@ class Puppeteer::Connection
291
299
  def dispose: () -> void
292
300
  def auto_attached?: (String target_id) -> bool
293
301
  def create_session: (untyped target_info, ?auto_attach_emulated: bool) -> Puppeteer::CDPSession
302
+ def ensure_command_allowed!: (String method) -> void
294
303
 
295
304
  private
296
305
 
@@ -305,6 +314,29 @@ class Puppeteer::Connection
305
314
  def handle_close: () -> void
306
315
  end
307
316
 
317
+ class Puppeteer::TargetCloseError < Puppeteer::Connection::ProtocolError
318
+ end
319
+
320
+ module Puppeteer::Launcher
321
+ def new: (project_root: untyped, preferred_revision: untyped, is_puppeteer_core: untyped, product: untyped) -> Puppeteer::Launcher::Chrome
322
+ def self.new: (project_root: untyped, preferred_revision: untyped, is_puppeteer_core: untyped, product: untyped) -> Puppeteer::Launcher::Chrome
323
+ end
324
+
325
+ class Puppeteer::Launcher::Chrome
326
+ def self.get_features: (String flag, ?Array[String] options) -> Array[String]
327
+ def self.remove_matching_flags: (Array[String] array, String flag) -> Array[String]
328
+ def initialize: (project_root: untyped, preferred_revision: untyped, is_puppeteer_core: untyped) -> void
329
+ def launch: (?Hash[Symbol, untyped] options) -> Puppeteer::Browser
330
+ def default_args: (?Hash[Symbol, untyped]? options) -> untyped
331
+ def executable_path: (?channel: (String | Symbol)?) -> String
332
+ def product: () -> String
333
+
334
+ private
335
+
336
+ def fallback_executable_path: () -> String
337
+ def executable_path_for_channel: (String channel) -> String
338
+ end
339
+
308
340
  class Puppeteer::BrowserRunner
309
341
  def initialize: (String executable_path, Array[String] process_arguments, String user_data_dir, bool using_temp_user_data_dir) -> void
310
342
  def start: (?executable_path: String?, ?ignore_default_args: Array[String]?, ?handle_SIGINT: bool?, ?handle_SIGTERM: bool?, ?handle_SIGHUP: bool?, ?timeout: Integer?, ?dumpio: bool?, ?env: Hash[String, String]?, ?pipe: bool?) -> void
@@ -0,0 +1,73 @@
1
+ # Generated from lib/puppeteer/accessibility.rb with RBS::Inline
2
+
3
+ class Puppeteer::Accessibility
4
+ class SerializedAXNode < Hash[String, untyped]
5
+ # @rbs values: Hash[String, untyped] -- Serialized node values
6
+ # @rbs element_handle_resolver: Proc -- Resolver for the backing element
7
+ def initialize: (Hash[String, untyped] values, Proc element_handle_resolver) -> untyped
8
+
9
+ # @rbs return: Puppeteer::ElementHandle? -- Backing element, if available
10
+ def element_handle: () -> Puppeteer::ElementHandle?
11
+ end
12
+
13
+ # @rbs frame: Puppeteer::Frame -- Frame whose accessibility tree is inspected
14
+ def initialize: (Puppeteer::Frame frame) -> untyped
15
+
16
+ # @rbs interesting_only: bool -- Prune uninteresting nodes
17
+ # @rbs include_iframes: bool -- Include descendant iframe trees
18
+ # @rbs root: Puppeteer::ElementHandle? -- Optional root node
19
+ # @rbs return: SerializedAXNode? -- Accessibility snapshot
20
+ def snapshot: (?interesting_only: bool, ?include_iframes: bool, ?root: Puppeteer::ElementHandle?) -> SerializedAXNode?
21
+
22
+ private def describe_backend_node: (untyped root) -> untyped
23
+
24
+ private def populate_iframes: (untyped root, interesting_only: untyped) -> untyped
25
+
26
+ private def serialize_tree: (untyped node, ?untyped interesting_nodes) -> untyped
27
+
28
+ private def collect_interesting_nodes: (untyped collection, untyped node, untyped inside_control) -> untyped
29
+
30
+ class AXNode
31
+ CONTROL_ROLES: untyped
32
+
33
+ LANDMARK_ROLES: untyped
34
+
35
+ LEAF_ROLES: untyped
36
+
37
+ TEXT_ROLES: untyped
38
+
39
+ # @rbs frame: Puppeteer::Frame -- Owning frame
40
+ # @rbs payload: Hash[String, untyped] -- CDP AX node payload
41
+ def initialize: (Puppeteer::Frame frame, Hash[String, untyped] payload) -> untyped
42
+
43
+ attr_reader payload: untyped
44
+
45
+ attr_reader children: untyped
46
+
47
+ attr_reader role: untyped
48
+
49
+ attr_accessor iframe_snapshot: untyped
50
+
51
+ def find: () ?{ (?) -> untyped } -> untyped
52
+
53
+ def leaf_node?: () -> untyped
54
+
55
+ def control?: () -> untyped
56
+
57
+ def landmark?: () -> untyped
58
+
59
+ def interesting?: (untyped inside_control) -> untyped
60
+
61
+ def serialize: () -> untyped
62
+
63
+ def self.create_tree: (untyped frame, untyped payloads) -> untyped
64
+
65
+ private def read_properties: () -> untyped
66
+
67
+ private def plain_text_field?: () -> untyped
68
+
69
+ private def has_focusable_child?: () -> untyped
70
+
71
+ private def element_handle: () -> untyped
72
+ end
73
+ end
@@ -15,12 +15,13 @@ class Puppeteer::Browser
15
15
  # @rbs network_enabled: bool -- Whether network events are enabled
16
16
  # @rbs issues_enabled: bool -- Whether issues events are enabled
17
17
  # @rbs block_list: Array[String]? -- URL block list patterns
18
+ # @rbs allow_list: Array[String]? -- URL allow list patterns
18
19
  # @rbs process: Puppeteer::BrowserRunner::BrowserProcess? -- Browser process handle
19
20
  # @rbs close_callback: Proc -- Close callback
20
21
  # @rbs target_filter_callback: Proc? -- Target filter callback
21
22
  # @rbs is_page_target_callback: Proc? -- Page target predicate
22
23
  # @rbs return: Puppeteer::Browser -- Browser instance
23
- def self.create: (product: String?, connection: Puppeteer::Connection, context_ids: Array[String], ignore_https_errors: bool, default_viewport: Puppeteer::Viewport?, process: Puppeteer::BrowserRunner::BrowserProcess?, close_callback: Proc, target_filter_callback: Proc?, is_page_target_callback: Proc?, ?network_enabled: bool, ?issues_enabled: bool, ?block_list: Array[String]?) -> Puppeteer::Browser
24
+ def self.create: (product: String?, connection: Puppeteer::Connection, context_ids: Array[String], ignore_https_errors: bool, default_viewport: Puppeteer::Viewport?, process: Puppeteer::BrowserRunner::BrowserProcess?, close_callback: Proc, target_filter_callback: Proc?, is_page_target_callback: Proc?, ?network_enabled: bool, ?issues_enabled: bool, ?block_list: Array[String]?, ?allow_list: Array[String]?) -> Puppeteer::Browser
24
25
 
25
26
  # @rbs product: String? -- Browser product (chrome only)
26
27
  # @rbs connection: Puppeteer::Connection -- CDP connection
@@ -30,15 +31,18 @@ class Puppeteer::Browser
30
31
  # @rbs network_enabled: bool -- Whether network events are enabled
31
32
  # @rbs issues_enabled: bool -- Whether issues events are enabled
32
33
  # @rbs block_list: Array[String]? -- URL block list patterns
34
+ # @rbs allow_list: Array[String]? -- URL allow list patterns
33
35
  # @rbs process: Puppeteer::BrowserRunner::BrowserProcess? -- Browser process handle
34
36
  # @rbs close_callback: Proc -- Close callback
35
37
  # @rbs target_filter_callback: Proc? -- Target filter callback
36
38
  # @rbs is_page_target_callback: Proc? -- Page target predicate
37
39
  # @rbs return: void -- No return value
38
- def initialize: (product: String?, connection: Puppeteer::Connection, context_ids: Array[String], ignore_https_errors: bool, default_viewport: Puppeteer::Viewport?, process: Puppeteer::BrowserRunner::BrowserProcess?, close_callback: Proc, target_filter_callback: Proc?, is_page_target_callback: Proc?, ?network_enabled: bool, ?issues_enabled: bool, ?block_list: Array[String]?) -> void
40
+ def initialize: (product: String?, connection: Puppeteer::Connection, context_ids: Array[String], ignore_https_errors: bool, default_viewport: Puppeteer::Viewport?, process: Puppeteer::BrowserRunner::BrowserProcess?, close_callback: Proc, target_filter_callback: Proc?, is_page_target_callback: Proc?, ?network_enabled: bool, ?issues_enabled: bool, ?block_list: Array[String]?, ?allow_list: Array[String]?) -> void
39
41
 
40
42
  private def default_target_filter_callback: (untyped target_info) -> untyped
41
43
 
44
+ private def validate_allow_list_version: () -> untyped
45
+
42
46
  private def default_is_page_target_callback: (untyped target_info) -> untyped
43
47
 
44
48
  attr_reader is_page_target_callback: untyped
@@ -120,6 +124,8 @@ class Puppeteer::Browser
120
124
  # @rbs return: Puppeteer::Page -- Created page
121
125
  def create_page_in_context: (String? context_id) -> Puppeteer::Page
122
126
 
127
+ private def wait_for_available_target: (untyped target_id) -> untyped
128
+
123
129
  # All active targets inside the Browser. In case of multiple browser contexts, returns
124
130
  # an array with all the targets in all browser contexts.
125
131
  # @rbs return: Array[Puppeteer::Target] -- Active targets
@@ -146,13 +152,24 @@ class Puppeteer::Browser
146
152
  # @rbs return: String -- Browser user agent string
147
153
  def user_agent: () -> String
148
154
 
155
+ private def version_info: () -> untyped
156
+
149
157
  # @rbs page_target_id: String -- Page target id
150
158
  # @rbs return: String? -- DevTools target id for page
151
159
  def _has_devtools_target: (String page_target_id) -> String?
152
160
 
161
+ # @rbs page_target_id: String -- Inspected page target id
162
+ # @rbs return: Puppeteer::Page -- DevTools page
163
+ def _create_devtools_page: (String page_target_id) -> Puppeteer::Page
164
+
165
+ # @rbs devtools_target_id: String -- DevTools target id
166
+ # @rbs return: Puppeteer::Page -- DevTools page
167
+ def _get_devtools_target_page: (String devtools_target_id) -> Puppeteer::Page
168
+
153
169
  # @rbs path: String -- Extension path
170
+ # @rbs enabled_in_incognito: bool -- Enable in Incognito and OTR profiles
154
171
  # @rbs return: String -- Installed extension id
155
- def install_extension: (String path) -> String
172
+ def install_extension: (String path, ?enabled_in_incognito: bool) -> String
156
173
 
157
174
  # @rbs extension_id: String -- Extension id
158
175
  # @rbs return: void -- No return value
@@ -167,6 +184,13 @@ class Puppeteer::Browser
167
184
  # @rbs return: Array[String]? -- URL block list patterns
168
185
  def block_list: () -> Array[String]?
169
186
 
187
+ # @rbs return: Array[String]? -- URL allow list patterns
188
+ def allow_list: () -> Array[String]?
189
+
190
+ # @rbs url: String -- URL to validate against network restriction rules
191
+ # @rbs return: bool -- Whether the URL is allowed
192
+ def url_allowed?: (String url) -> bool
193
+
170
194
  # @rbs return: void -- No return value
171
195
  def close: () -> void
172
196
 
@@ -40,6 +40,10 @@ class Puppeteer::CDPSession
40
40
  # @rbs return: Async::Promise[Hash[String, untyped]] -- Async CDP response
41
41
  def async_send_message: (String method, ?Hash[String, untyped] params) -> Async::Promise[Hash[String, untyped]]
42
42
 
43
+ # @rbs id: Integer -- CDP command id
44
+ # @rbs return: bool -- True when the session owns the callback
45
+ def callback?: (Integer id) -> bool
46
+
43
47
  # @rbs message: Hash[String, untyped] -- Raw CDP message
44
48
  # @rbs return: void -- No return value
45
49
  def handle_message: (Hash[String, untyped] message) -> void
@@ -13,6 +13,9 @@ class Puppeteer::Dialog
13
13
 
14
14
  attr_reader default_value: String
15
15
 
16
+ # @rbs return: bool -- Whether the dialog has already been handled
17
+ def handled?: () -> bool
18
+
16
19
  # @rbs prompt_text: String? -- Text entered into the prompt
17
20
  # @rbs return: void -- No return value
18
21
  def accept: (?String? prompt_text) -> void
@@ -166,11 +166,10 @@ class Puppeteer::ElementHandle < Puppeteer::JSHandle
166
166
 
167
167
  # @rbs delay: Numeric? -- Delay between down and up (ms)
168
168
  # @rbs button: String? -- Mouse button
169
- # @rbs click_count: Integer? -- Deprecated: use count (click_count only sets clickCount)
170
169
  # @rbs count: Integer? -- Number of clicks to perform
171
170
  # @rbs offset: Puppeteer::ElementHandle::Offset | Hash[Symbol, Numeric] | nil -- Click offset
172
171
  # @rbs return: void -- No return value
173
- def click: (?delay: Numeric?, ?button: String?, ?click_count: Integer?, ?count: Integer?, ?offset: Puppeteer::ElementHandle::Offset | Hash[Symbol, Numeric] | nil) -> void
172
+ def click: (?delay: Numeric?, ?button: String?, ?count: Integer?, ?offset: Puppeteer::ElementHandle::Offset | Hash[Symbol, Numeric] | nil) -> void
174
173
 
175
174
  # @rbs return: Puppeteer::TouchHandle -- Touch handle
176
175
  def touch_start: () -> Puppeteer::TouchHandle
@@ -3,6 +3,8 @@
3
3
  class Puppeteer::ExecutionContext
4
4
  include Puppeteer::IfPresent
5
5
 
6
+ include Puppeteer::EventCallbackable
7
+
6
8
  EVALUATION_SCRIPT_URL: ::String
7
9
 
8
10
  SOURCE_URL_REGEX: ::Regexp
@@ -16,6 +18,9 @@ class Puppeteer::ExecutionContext
16
18
 
17
19
  attr_reader world: untyped
18
20
 
21
+ # @rbs return: void -- Notify consumers that this context was destroyed
22
+ def dispose: () -> void
23
+
19
24
  # only used in IsolaatedWorld
20
25
  private def _context_id: () -> untyped
21
26
 
@@ -31,6 +31,10 @@ class Puppeteer::Extension
31
31
  # @rbs return: Array[Puppeteer::Page] -- Extension pages
32
32
  def pages: () -> Array[Puppeteer::Page]
33
33
 
34
+ # @rbs error: StandardError -- Error raised while resolving an extension target
35
+ # @rbs return: bool -- Whether the target resolution error can be ignored
36
+ private def can_ignore_error?: (StandardError error) -> bool
37
+
34
38
  # @rbs page: Puppeteer::Page -- Target page
35
39
  # @rbs return: void -- No return value
36
40
  def trigger_action: (Puppeteer::Page page) -> void
@@ -19,6 +19,9 @@ class Puppeteer::Frame
19
19
  # @rbs return: Puppeteer::Page -- Owning page
20
20
  def page: () -> Puppeteer::Page
21
21
 
22
+ # @rbs return: Puppeteer::Accessibility -- Accessibility tree for this frame
23
+ def accessibility: () -> Puppeteer::Accessibility
24
+
22
25
  # @rbs return: Numeric -- Default timeout in milliseconds
23
26
  def default_timeout: () -> Numeric
24
27
 
@@ -158,10 +161,9 @@ class Puppeteer::Frame
158
161
  # @rbs selector: String -- CSS selector
159
162
  # @rbs delay: Numeric? -- Delay between down and up (ms)
160
163
  # @rbs button: String? -- Mouse button
161
- # @rbs click_count: Integer? -- Deprecated: use count (click_count only sets clickCount)
162
164
  # @rbs count: Integer? -- Number of clicks to perform
163
165
  # @rbs return: void -- No return value
164
- def click: (String selector, ?delay: Numeric?, ?button: String?, ?click_count: Integer?, ?count: Integer?) -> void
166
+ def click: (String selector, ?delay: Numeric?, ?button: String?, ?count: Integer?) -> void
165
167
 
166
168
  # @rbs selector: String -- CSS selector
167
169
  # @rbs return: void -- No return value
@@ -46,6 +46,10 @@ class Puppeteer::HTTPResponse
46
46
 
47
47
  attr_reader timing: untyped
48
48
 
49
+ # Multiline values represent duplicate fields in CDP. RFC 9110 allows
50
+ # comma-combining fields except Set-Cookie, whose lines must stay separate.
51
+ private def normalize_header_value: (untyped name, untyped value) -> untyped
52
+
49
53
  def inspect: () -> untyped
50
54
 
51
55
  private def parse_status_text_from_extra_info: (untyped extra_info) -> untyped
@@ -7,6 +7,10 @@ class Puppeteer::Keyboard
7
7
 
8
8
  attr_reader modifiers: untyped
9
9
 
10
+ # @rbs client: Puppeteer::CDPSession -- Replacement CDP session
11
+ # @rbs return: void -- No return value
12
+ def update_client: (Puppeteer::CDPSession client) -> void
13
+
10
14
  # @rbs key: String -- Key name
11
15
  # @rbs text: String? -- Text to input
12
16
  # @rbs commands: Array[String]? -- Editing commands
@@ -87,16 +87,15 @@ class Puppeteer::Locator
87
87
 
88
88
  # @rbs delay: Numeric? -- Delay between down and up (ms)
89
89
  # @rbs button: String? -- Mouse button
90
- # @rbs click_count: Integer? -- Deprecated click count
91
90
  # @rbs count: Integer? -- Number of clicks
92
91
  # @rbs offset: Hash[Symbol, Numeric]? -- Click offset
93
92
  # @rbs return: void -- No return value
94
- def click: (?delay: Numeric?, ?button: String?, ?click_count: Integer?, ?count: Integer?, ?offset: Hash[Symbol, Numeric]?) -> void
93
+ def click: (?delay: Numeric?, ?button: String?, ?count: Integer?, ?offset: Hash[Symbol, Numeric]?) -> void
95
94
 
96
- # @rbs value: String -- Value to fill
95
+ # @rbs value: String | bool -- Value to fill
97
96
  # @rbs typing_threshold: Integer -- Minimum length to switch to direct assignment
98
97
  # @rbs return: void -- No return value
99
- def fill: (String value, ?typing_threshold: Integer) -> void
98
+ def fill: (String | bool value, ?typing_threshold: Integer) -> void
100
99
 
101
100
  # @rbs return: void -- No return value
102
101
  def hover: () -> void
@@ -34,6 +34,10 @@ class Puppeteer::Mouse
34
34
  # @rbs return: void -- No return value
35
35
  def initialize: (Puppeteer::CDPSession client, Puppeteer::Keyboard keyboard) -> void
36
36
 
37
+ # @rbs client: Puppeteer::CDPSession -- Replacement CDP session
38
+ # @rbs return: void -- No return value
39
+ def update_client: (Puppeteer::CDPSession client) -> void
40
+
37
41
  # @rbs return: void -- No return value
38
42
  def reset: () -> void
39
43
 
@@ -47,14 +51,9 @@ class Puppeteer::Mouse
47
51
  # @rbs y: Numeric -- Y coordinate
48
52
  # @rbs delay: Numeric? -- Delay between down and up (ms)
49
53
  # @rbs button: String? -- Mouse button
50
- # @rbs click_count: Integer? -- Deprecated: use count (click_count only sets clickCount)
51
54
  # @rbs count: Integer? -- Number of click repetitions
52
55
  # @rbs return: void -- No return value
53
- def click: (Numeric x, Numeric y, ?delay: Numeric?, ?button: String?, ?click_count: Integer?, ?count: Integer?) -> void
54
-
55
- private def warn_deprecated_click_count: () -> untyped
56
-
57
- attr_accessor deprecated_click_count_warned: untyped
56
+ def click: (Numeric x, Numeric y, ?delay: Numeric?, ?button: String?, ?count: Integer?) -> void
58
57
 
59
58
  # @rbs button: String? -- Mouse button
60
59
  # @rbs click_count: Integer? -- Click count to report