puppeteer-ruby 0.50.0.alpha8 → 0.50.0.alpha9
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 +4 -4
- data/docs/api_coverage.md +1 -1
- data/lib/puppeteer/frame_manager.rb +43 -1
- data/lib/puppeteer/version.rb +1 -1
- data/sig/_supplementary.rbs +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 904e4fe437eb2088c1c1f6650e840818b9d8b0be5d420cdf4aa33142dd7468a4
|
|
4
|
+
data.tar.gz: 27ca94c22baf6edcf0ebf6173df06142a071803995a3c29462ccd00286adf723
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a874a9d182af6525021f91a2cf3eeaeffe6fd5380eef345b8fd9e6bb896b3468543d67900af2b827a263a6c2adc0a8a85f06bf6d05241e4477033863dd6a4601
|
|
7
|
+
data.tar.gz: 3d99750cef4daa4438786a581f8246d1f03c2920c0ff6bc3ebc7f2fbe5f97cbb47ea577faae87f45bf37933adfa7a40d3df6b3ae1347a2c37eeb3488e1142029
|
data/docs/api_coverage.md
CHANGED
|
@@ -34,6 +34,8 @@ class Puppeteer::FrameManager
|
|
|
34
34
|
|
|
35
35
|
# Keeps track of frames that are in the process of being attached in #onFrameAttached.
|
|
36
36
|
@frames_pending_attachment = {}
|
|
37
|
+
@frame_tree_handled_promise = nil
|
|
38
|
+
@queued_lifecycle_events = []
|
|
37
39
|
|
|
38
40
|
setup_listeners(@client)
|
|
39
41
|
end
|
|
@@ -78,6 +80,7 @@ class Puppeteer::FrameManager
|
|
|
78
80
|
@frames_pending_target_init[target_id] ||= Async::Promise.new
|
|
79
81
|
client = cdp_session || @client
|
|
80
82
|
|
|
83
|
+
prepare_frame_tree_handling
|
|
81
84
|
promises = [
|
|
82
85
|
client.async_send_message('Page.enable'),
|
|
83
86
|
client.async_send_message('Page.getFrameTree'),
|
|
@@ -85,6 +88,7 @@ class Puppeteer::FrameManager
|
|
|
85
88
|
results = Puppeteer::AsyncUtils.await_promise_all(*promises)
|
|
86
89
|
frame_tree = results[1]['frameTree']
|
|
87
90
|
handle_frame_tree(client, frame_tree)
|
|
91
|
+
finish_frame_tree_handling
|
|
88
92
|
Puppeteer::AsyncUtils.await_promise_all(
|
|
89
93
|
client.async_send_message('Page.setLifecycleEventsEnabled', enabled: true),
|
|
90
94
|
client.async_send_message('Runtime.enable'),
|
|
@@ -93,10 +97,16 @@ class Puppeteer::FrameManager
|
|
|
93
97
|
@network_manager.init unless cdp_session
|
|
94
98
|
rescue => err
|
|
95
99
|
# The target might have been closed before the initialization finished.
|
|
96
|
-
|
|
100
|
+
if err.message.include?('Target closed') || err.message.include?('Session closed')
|
|
101
|
+
finish_frame_tree_handling(process_queue: false)
|
|
102
|
+
return
|
|
103
|
+
end
|
|
97
104
|
|
|
98
105
|
raise
|
|
99
106
|
ensure
|
|
107
|
+
if @frame_tree_handled_promise && !@frame_tree_handled_promise.resolved?
|
|
108
|
+
finish_frame_tree_handling(process_queue: false)
|
|
109
|
+
end
|
|
100
110
|
@frames_pending_target_init.delete(target_id)&.resolve(nil)
|
|
101
111
|
end
|
|
102
112
|
|
|
@@ -214,6 +224,15 @@ class Puppeteer::FrameManager
|
|
|
214
224
|
|
|
215
225
|
# @param event [Hash]
|
|
216
226
|
def handle_lifecycle_event(event)
|
|
227
|
+
if @frame_tree_handled_promise && !@frame_tree_handled_promise.resolved?
|
|
228
|
+
@queued_lifecycle_events << event
|
|
229
|
+
return
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
handle_lifecycle_event_impl(event)
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
private def handle_lifecycle_event_impl(event)
|
|
217
236
|
frame = @frames[event['frameId']]
|
|
218
237
|
return if !frame
|
|
219
238
|
frame.handle_lifecycle_event(event['loaderId'], event['name'])
|
|
@@ -251,6 +270,29 @@ class Puppeteer::FrameManager
|
|
|
251
270
|
end
|
|
252
271
|
end
|
|
253
272
|
|
|
273
|
+
private def prepare_frame_tree_handling
|
|
274
|
+
if @frame_tree_handled_promise && !@frame_tree_handled_promise.resolved?
|
|
275
|
+
@frame_tree_handled_promise.resolve(nil)
|
|
276
|
+
end
|
|
277
|
+
@frame_tree_handled_promise = Async::Promise.new
|
|
278
|
+
@queued_lifecycle_events = []
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
private def finish_frame_tree_handling(process_queue: true)
|
|
282
|
+
return unless @frame_tree_handled_promise
|
|
283
|
+
|
|
284
|
+
@frame_tree_handled_promise.resolve(nil) unless @frame_tree_handled_promise.resolved?
|
|
285
|
+
flush_queued_lifecycle_events if process_queue
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
private def flush_queued_lifecycle_events
|
|
289
|
+
return if @queued_lifecycle_events.empty?
|
|
290
|
+
|
|
291
|
+
queued = @queued_lifecycle_events
|
|
292
|
+
@queued_lifecycle_events = []
|
|
293
|
+
queued.each { |event| handle_lifecycle_event_impl(event) }
|
|
294
|
+
end
|
|
295
|
+
|
|
254
296
|
# @return {!Puppeteer.Page}
|
|
255
297
|
def page
|
|
256
298
|
@page
|
data/lib/puppeteer/version.rb
CHANGED
data/sig/_supplementary.rbs
CHANGED
|
@@ -178,6 +178,10 @@ class Puppeteer::FrameManager
|
|
|
178
178
|
|
|
179
179
|
def setup_listeners: (Puppeteer::CDPSession client) -> void
|
|
180
180
|
def init: (String target_id, ?Puppeteer::CDPSession cdp_session) -> void
|
|
181
|
+
def handle_lifecycle_event_impl: (Hash[String, untyped] event) -> void
|
|
182
|
+
def prepare_frame_tree_handling: () -> void
|
|
183
|
+
def finish_frame_tree_handling: (?process_queue: bool) -> void
|
|
184
|
+
def flush_queued_lifecycle_events: () -> void
|
|
181
185
|
def attach_child_frame: (Puppeteer::Frame parent_frame, String parent_frame_id, String frame_id, Puppeteer::CDPSession? session) -> void
|
|
182
186
|
def reattach_frame: (Puppeteer::Frame frame, String frame_id, bool is_main_frame, Hash[String, untyped] frame_payload) -> void
|
|
183
187
|
def ensure_isolated_world: (Puppeteer::CDPSession session, String name) -> void
|