Skip to content

fix(firefox): disable safe mode keyboard shortcut in environment (#43089) - #43178

Open
Alok Pandey (alok-108) wants to merge 1 commit into
microsoft:mainfrom
alok-108:fix-firefox-safe-mode-key
Open

Alok Pandey (alok-108) wants to merge 1 commit into
microsoft:mainfrom
alok-108:fix-firefox-safe-mode-key

Conversation

@alok-108

Copy link
Copy Markdown
Contributor

Summary

Fixes #43089 where launching Firefox (especially in headless mode) hangs if the Shift key is pressed or held on Windows (or Option key on macOS), causing Firefox to trigger its modal Troubleshoot / Safe Mode prompt dialog (chrome://browser/content/safeMode.xhtml). In headless mode or automated launches, this modal prompt is invisible and cannot be dismissed, causing launch and launchPersistentContext to hang until timeout.

What changed

packages/playwright-core/src/server/firefox/firefox.ts & bidiFirefox.ts

  • Added 'MOZ_DISABLE_SAFE_MODE_KEY': '1' to amendEnvironment in both standard Firefox and BiDi Firefox launchers.
  • This is Mozilla's documented environment flag used across automated test runners (such as Marionette, geckodriver, and Firefox CI) to suppress keyboard modifier detection that triggers the Safe Mode dialog on startup.
  • Sets 'MOZ_DISABLE_SAFE_MODE_KEY': '1' before expanding ...env, preserving user-configured environment overrides if explicitly provided.

Test changes

tests/library/firefox/launcher.spec.ts

  • Added unit test 'should disable safe mode key in firefox environment' verifying that:
    • MOZ_DISABLE_SAFE_MODE_KEY is set to '1' by default in amendEnvironment for both Firefox and BiDi Firefox.
    • User-specified values in env override the default.

Verification

  • npm run build completed successfully.
  • npx playwright test tests/library/firefox/launcher.spec.ts -g "should disable safe mode key in firefox environment" passed.
  • npm run tsc passed with 0 errors.
  • npm run eslint passed with 0 errors.

Closes #43089

This branch has not been deployed

No deployments
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.

[Bug]: Headless Firefox persistent launch hangs on Windows if Shift is held when the browser starts (safe mode)

1 participant