Skip to content

fix: use WebDriver new_window instead of JS window.open in tab_restart_browser#1146

Merged
vringar merged 5 commits intomasterfrom
fix/tab-restart-popup-blocking
Mar 1, 2026
Merged

fix: use WebDriver new_window instead of JS window.open in tab_restart_browser#1146
vringar merged 5 commits intomasterfrom
fix/tab-restart-popup-blocking

Conversation

@vringar
Copy link
Contributor

@vringar vringar commented Feb 26, 2026

Summary

  • Replace JS window.open('') with Selenium 4's webdriver.switch_to.new_window("tab") in tab_restart_browser()
  • The old approach used a Selenium 3 workaround that breaks when popup-blocking prefs are active (e.g. dom.disable_open_during_load=True)
  • Add regression test that enables popup blocking and runs two visits
  • Document the previously-undocumented prefs field on BrowserParams

Closes #741
Closes #784

Test plan

  • New test_get_with_popup_blocking passes locally
  • Existing test_get_site_visits_table_valid still passes (both headless and xvfb)
  • black, isort, mypy all clean
  • CI passes

Copilot AI review requested due to automatic review settings February 26, 2026 23:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a browser restart issue where popup-blocking preferences break tab restarting. The fix replaces a legacy Selenium 3 workaround with Selenium 4's native new_window() method, which bypasses content-level popup blocking.

Changes:

  • Replace JavaScript window.open('') with WebDriver's switch_to.new_window("window") in tab_restart_browser()
  • Add regression test that enables popup blocking and verifies two visits complete successfully
  • Document the previously-undocumented prefs field in BrowserParams configuration

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
openwpm/commands/browser_commands.py Replaces JS-based window creation with WebDriver protocol to avoid popup blocking issues
test/test_simple_commands.py Adds regression test verifying visits work with popup blocking enabled
docs/Configuration.md Documents the prefs field for setting custom Firefox preferences

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…t_browser

Replace the Selenium 3 workaround (JS window.open) with Selenium 4
switch_to.new_window(), which uses the WebDriver protocol and is not
blocked by popup-blocking preferences like dom.disable_open_during_load.

Closes #741, closes #784
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.75%. Comparing base (40e044f) to head (e1cbbfb).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1146      +/-   ##
==========================================
+ Coverage   56.62%   56.75%   +0.13%     
==========================================
  Files          40       40              
  Lines        3910     3908       -2     
==========================================
+ Hits         2214     2218       +4     
+ Misses       1696     1690       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Using "window" instead of "tab" created an isolated cache context,
causing test_cache_hits_recorded to fail with extra uncached requests.
@vringar vringar force-pushed the fix/tab-restart-popup-blocking branch from b390ab7 to 0f03c2f Compare February 27, 2026 16:45
Fix black formatting, mypy errors (duplicate sleep arg, missing return type).
@vringar vringar force-pushed the fix/tab-restart-popup-blocking branch 4 times, most recently from 2f4a230 to a5fa580 Compare February 28, 2026 22:53
@vringar vringar enabled auto-merge February 28, 2026 22:53
@vringar vringar requested a review from Copilot February 28, 2026 22:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vringar vringar added this pull request to the merge queue Feb 28, 2026
@vringar vringar removed this pull request from the merge queue due to a manual request Feb 28, 2026
@vringar vringar force-pushed the fix/tab-restart-popup-blocking branch 2 times, most recently from bcd9fcc to 790e94c Compare February 28, 2026 23:16
@vringar vringar enabled auto-merge February 28, 2026 23:16
Use new_window("tab") for tab_restart_browser — not subject to popup
blocking. Update HTTP_CACHED_REQUESTS to include resources re-fetched
due to the new tab having an isolated cache context.

Remove stealth extension files accidentally included in this branch.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"image",
),
# Resources re-requested when the tab restart opens a new tab; served from
# the shared HTTP cache (is_cached=1 in HTTP_CACHED_RESPONSES).
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

The new expectations add cached image/css entries for the second visit, but test_cache_hits_recorded’s docstring later in this file still states that cached images do not trigger the relevant instrumentation events. To avoid confusion for future maintenance, please update/clarify that docstring (or the inline comment here) to match the new observed behavior (i.e., which cached resource types are expected to appear in http_requests/http_responses).

Suggested change
# the shared HTTP cache (is_cached=1 in HTTP_CACHED_RESPONSES).
# the shared HTTP cache (is_cached=1 in HTTP_CACHED_RESPONSES), but still
# expected to generate entries in http_requests/http_responses (for both
# the cached stylesheet and cached images).

Copilot uses AI. Check for mistakes.
@vringar vringar added this pull request to the merge queue Feb 28, 2026
@vringar vringar removed this pull request from the merge queue due to a manual request Mar 1, 2026
@vringar vringar enabled auto-merge March 1, 2026 00:00
@vringar vringar added this pull request to the merge queue Mar 1, 2026
Merged via the queue into master with commit b529b2f Mar 1, 2026
14 checks passed
@vringar vringar deleted the fix/tab-restart-popup-blocking branch March 1, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disabling pop-ups lead to crash in FinalizeCommand

2 participants