Skip to content

Support Ferrum 0.21: dialog chain and closed windows - #366

Merged
route merged 3 commits into
mainfrom
ferrum-0.21
Nov 19, 2026
Merged

route merged 3 commits into
mainfrom
ferrum-0.21

Conversation

@route

@route route commented Nov 19, 2026

Copy link
Copy Markdown
Member

Prepares Cuprite for Ferrum 0.21. The Gemfile pins Ferrum main until the release, and two Ferrum changes need adjustments in Cuprite.

Dialogs (rubycdp/ferrum#703)

Ferrum now handles Page.javascriptDialogOpening itself through an on(:dialog) chain, and its default handler accepts any dialog nobody handled. Cuprite listened to the raw CDP event, so Ferrum's default answered first: dismissals and prompt responses were lost, and every dialog printed Ferrum's warning.

Cuprite now registers its handler with on(:dialog) and answers through dialog.accept/dialog.dismiss, so the chain sees it as handled. The answer is sent on the dispatcher thread without raising a pending UnhandledModalError there. With raise_on_unhandled_modal, the error is stashed before the dialog is answered, so the command waiting on the dialog raises it instead of returning first.

Closed windows (rubycdp/ferrum#707)

Context#targets now returns a copy, so close_window deleted the target from that copy and the closed window stayed listed until Chrome reported it destroyed. switch_to_window, within_window and Window#exists?/#closed? then saw it as open, and switching to it raised Ferrum::BrowserError: Session with given id not found instead of NoSuchPageError. Cuprite now removes it with default_context.delete_target.

Testing

Run against Ferrum main (99b6c17):

  • bundle exec rspec spec/browser/extensions_spec.rb: 12 examples, 0 failures (3 runs)
  • bundle exec rspec spec/capybara_spec.rb -e modal -e alert -e confirm -e prompt -e window: 95 examples, 0 failures, 2 pending
  • bundle exec rubocop: no offenses

Replaces #364 and #365. On their own, each one hung or failed on CI because it lacked the other fix.

…r stays out

Ferrum 0.21 runs on(:dialog) callbacks as a chain and accepts a dialog nobody handled with a warning. Cuprite listened to the raw Page.javascriptDialogOpening event, so Ferrum accepted every dialog first, dismissals and prompt responses were lost, and a test stubbing warn killed the dispatcher thread.
… of a copy of its targets

Ferrum 0.21 returns a copy from Context#targets, so deleting from it kept a closed window listed until Chrome reported it destroyed: exists? stayed true and switching to it raised BrowserError instead of NoSuchPageError.
@route
route merged commit f82dd2a into main Nov 19, 2026
6 checks passed
@route
route deleted the ferrum-0.21 branch November 19, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant