Repository navigation
Support Ferrum 0.21: dialog chain and closed windows - #366
Merged
Merged
Conversation
…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.
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prepares Cuprite for Ferrum 0.21. The Gemfile pins Ferrum
mainuntil the release, and two Ferrum changes need adjustments in Cuprite.Dialogs (rubycdp/ferrum#703)
Ferrum now handles
Page.javascriptDialogOpeningitself through anon(: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 throughdialog.accept/dialog.dismiss, so the chain sees it as handled. The answer is sent on the dispatcher thread without raising a pendingUnhandledModalErrorthere. Withraise_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#targetsnow returns a copy, soclose_windowdeleted the target from that copy and the closed window stayed listed until Chrome reported it destroyed.switch_to_window,within_windowandWindow#exists?/#closed?then saw it as open, and switching to it raisedFerrum::BrowserError: Session with given id not foundinstead ofNoSuchPageError. Cuprite now removes it withdefault_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 pendingbundle exec rubocop: no offensesReplaces #364 and #365. On their own, each one hung or failed on CI because it lacked the other fix.