Skip to content

Search engine dropdown shadow DOM#1152

Merged
ben-c-at-moz merged 2 commits intomainfrom
ben/search-eng-dropdown
Mar 11, 2026
Merged

Search engine dropdown shadow DOM#1152
ben-c-at-moz merged 2 commits intomainfrom
ben/search-eng-dropdown

Conversation

@ben-c-at-moz
Copy link
Collaborator

Relevant Links

Bugzilla: Link

Description of Code / Doc Changes

  • Update all of these tests to use a keyboard method to select default search eng
  • Fix search results in new tab test
  • Mark key

Process Changes Required

Mark the relevant boxes, delete irrelevant lines.

  • Changes or creates a BOM/POM (name the object model): AboutPrefs

Screenshots or Explanations

The shadow DOM in the new search engine dropdown is more difficult to work with than the previous, so using the keyboard is preferred

Comments or Future Work

  • We should look at where Dropdown objects are being used in the repo and probably just factor that out.
  • We also see some weird stuff happening with the run_commit_tests script, it's erroring some tests on importing the TabBar, but that's not a problem when running pytest from command line.

Workflow Checklist

  • Reviewers have been requested.
  • Code has been linted and formatted.
  • If this is an unblocker, a message has been posted to #dte-automation in Slack.

Thank you!

@github-actions
Copy link

Review Notes

Overall the approach is sound — using keyboard navigation to work around shadow DOM complexity is a reasonable workaround. A couple of things to address:

Unused import: After removing search_engine_dropdown(), the Dropdown import on line 16 of page_object_prefs.py is now dead code. Ruff will flag this.

Linting not done: The PR checklist notes linting/formatting is unchecked — per project conventions this must pass before merging. Running 'ruff check .' will catch the unused import above.

Algorithm assumption: select_default_search_engine_by_key assumes the dropdown always starts focused at the topmost option when opened. If Firefox focuses the currently selected item instead, pressing DOWN i times won't consistently land on the expected index — the loop might exit early on the wrong iteration or miss the target. Worth verifying this assumption holds for all dropdown states (e.g. when DuckDuckGo is already selected before the method runs).

@github-actions
Copy link

Good cleanup overall -- replacing the shadow DOM Dropdown interaction with keyboard navigation is a solid approach, and the test stabilizations look reasonable. One bug flagged inline; two minor nits: (1) missing return type annotation on legacy_search_engine_matches, (2) linting is unchecked in the PR checklist -- the docstring rewraps look fine but worth verifying with ruff format before merge.

Copy link
Collaborator

@Tracy-Walker Tracy-Walker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! aproved

@ben-c-at-moz ben-c-at-moz merged commit 3a5af9a into main Mar 11, 2026
26 checks passed
@ben-c-at-moz ben-c-at-moz deleted the ben/search-eng-dropdown branch March 11, 2026 21:27
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.

2 participants