Skip to content

fix(page): handle dialogs with on(:dialog) so Ferrum's default handler stays out - #364

Closed
route wants to merge 2 commits into
mainfrom
fix-dialog-chain
Closed

route wants to merge 2 commits into
mainfrom
fix-dialog-chain

Conversation

@route

@route route commented Nov 19, 2026

Copy link
Copy Markdown
Member

Ferrum runs on(:dialog) callbacks as a chain since rubycdp/ferrum#703. A dialog no callback handles is accepted with a warning. Cuprite listened to the raw Page.javascriptDialogOpening event, so Ferrum's default didn't see it:

  • Ferrum accepted every dialog first, and Cuprite's own Page.handleJavaScriptDialog then failed. dismiss_confirm, dismiss_prompt and accept_prompt with a response all ended up as a plain accept.
  • Specs that stub warn to expect Cuprite's unhandled modal message got Ferrum's instead. The RSpec mock error isn't a StandardError, so it killed Ferrum's event thread. No target events arrived after that, and every later spec failed with Ferrum::NoSuchTargetError: 1749 of 1813 examples against Ferrum main.

Cuprite now registers on(:dialog) and answers with dialog.accept(response) or dialog.dismiss, which marks the dialog handled, so Ferrum's default stays out. Dialog#accept goes through page.command, Cuprite's override that raises a stashed UnhandledModalError. That runs on Ferrum's event thread, so the override skips the check while Cuprite answers a dialog. Otherwise an error stashed by an earlier dialog would be raised there and leave this one unanswered.

Against Ferrum main (99b6c17):

  • bundle exec rspec spec/browser/extensions_spec.rb spec/driver_spec.rb -e raise_on_unhandled_modal -e accept_modal: 6 examples, 0 failures
  • bundle exec rspec spec/capybara_spec.rb -e accept_alert -e accept_confirm -e accept_prompt -e dismiss_confirm -e dismiss_prompt: 29 examples, 0 failures

…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.
@route

route commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

Superseded by #366.

@route route closed this Nov 19, 2026
@route
route deleted the fix-dialog-chain branch November 19, 2026 15:48
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