Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
the browser; a failed `IO.close` is raised to the caller.

### Fixed
- An out-of-process iframe, e.g. Chrome's PDF viewer for an embedded PDF, appearing while a web worker was connected
raised `'Page.enable' wasn't found` in the event thread. Only pages and iframes are now searched for its parent [#640]
- A browser context whose `Target.disposeBrowserContext` timed out stayed registered, so every later `#reset` asked
again and raised `Disposal of browser context ... is already pending` for the rest of the process. It's now
forgotten either way, and `#reset` disposes the remaining contexts before raising the first error [#641]
Expand Down
9 changes: 7 additions & 2 deletions lib/ferrum/contexts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ def subscribe_target_created
context_id = info["browserContextId"]
add_context(context_id)

if info["type"] == "iframe" &&
(target = @contexts[context_id]&.find_target { |t| t.connected? && t.page.frame_by(id: info["targetId"]) })
if info["type"] == "iframe" && (target = find_frame_owner(context_id, info["targetId"]))
@contexts[context_id]&.add_target(session_id: target.session_id, params: info)
else
@contexts[context_id]&.add_target(params: info)
Expand All @@ -205,6 +204,12 @@ def subscribe_target_created
end
end

def find_frame_owner(context_id, frame_id)
@contexts[context_id]&.find_target do |target|
(target.page? || target.iframe?) && target.connected? && target.page.frame_by(id: frame_id)
end
end

def rearm_auto_attach(session_id, type)
return unless RECURSIVE_AUTO_ATTACH_TYPES.include?(type)

Expand Down
2 changes: 2 additions & 0 deletions sig/ferrum/contexts.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ module Ferrum

def subscribe_target_created: () -> void

def find_frame_owner: (String? context_id, String frame_id) -> Target?

def rearm_auto_attach: (String session_id, String type) -> void

def handle_attach: (Target? target, String session_id, Hash[String, untyped] params) -> void
Expand Down
Loading