Skip to content

test(contexts): check in Chrome that no browser_ui target stays attached - #697

Closed
thomasklemm wants to merge 1 commit into
rubycdp:mainfrom
thomasklemm:fix-contexts-spec-chrome-157
Closed

thomasklemm wants to merge 1 commit into
rubycdp:mainfrom
thomasklemm:fix-contexts-spec-chrome-157

Conversation

@thomasklemm

Copy link
Copy Markdown
Contributor

spec/contexts_spec.rb ("detaches from attached targets of a type it doesn't track") fails on every CI job since chrome-version: stable resolves to Chrome for Testing 157.0.8103.38, for example in #696. The last green main run used 156.0.8078.80.

Ferrum itself still works. Probing both versions locally:

  • Chrome 156 opens two browser_ui targets per new browser context: chrome://omnibox-popup.top-chrome/ and chrome://omnibox-popup.top-chrome/omnibox_popup_aim.html.
  • Chrome 157 opens only the first.
  • In both, Contexts#detach_untracked resumes and detaches them, and Target.getTargets reports them with attached: false afterwards.

The spec waited for at least two untracked attach events, so it failed on 157. Instead of lowering the count, it now asks Chrome directly: it polls Target.getTargets for the new context's browser_ui targets until there is at least one and none is attached, the same way context_spec.rb checks service workers. That holds for any number of targets and also catches a target that stays attached before its attach event has been handled, which the event-based version could miss.

Test

  • Green 10/10 with Chrome 156.0.8078.47 and 10/10 with 157.0.8103.38 (spec/contexts_spec.rb).
  • With detach_untracked stubbed to do nothing it fails on both versions (expected [true] …, expected [true, true] …).
  • With only the first untracked target detached it fails on 156 (expected [true, false] to all equal false).
  • RuboCop is clean.

Spec-only, so no CHANGELOG entry.

The spec waited for at least two untracked targets, but Chrome 157 opens
one `chrome://omnibox-popup.top-chrome/` target per browser context
instead of two, so it failed although Ferrum still detaches from it.
Ask Chrome for the context's `browser_ui` targets instead, which holds
for any count and also catches one that stays attached before its
attach event has been handled.
@thomasklemm

Copy link
Copy Markdown
Contributor Author

Closing, since 532aec9 fixed this on main.

@thomasklemm thomasklemm closed this Nov 5, 2026
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