Skip to content

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

Merged
Pavel Feldman (pavelfeldman) merged 2 commits into
microsoft:mainfrom
alok-108:fix-firefox-safe-mode-key
Oct 8, 2026
Merged

Pavel Feldman (pavelfeldman) merged 2 commits 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

@pavelfeldman

Copy link
Copy Markdown
Member

Thanks for the fix. Since we don't test the actual hang, let's remove the test.

@alok-108

Copy link
Copy Markdown
Contributor Author

Removed the test as requested. Thanks Pavel Feldman (@pavelfeldman)!

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

9 flaky ⚠️ [installation tests] › screencast.spec.ts:18 › screencast works `@package-installations-ubuntu-latest`
⚠️ [chromium-page] › page/workers.spec.ts:191 › should attribute network activity for worker inside iframe to the iframe `@frozen-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:725 › screencast › should capture full viewport on hidpi `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:762 › screencast › should work with video+trace `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:762 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/popup.spec.ts:260 › should not throw when click closes popup `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/video.spec.ts:356 › screencast › should work for popups `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`

52979 passed, 1270 skipped


Merge workflow run.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Test results for "MCP"

2 failed
❌ [firefox] › mcp/sse.spec.ts:196 › sse transport browser lifecycle (persistent) @mcp-ubuntu-latest-firefox
❌ [firefox] › mcp/cli-core.spec.ts:57 › click link @mcp-windows-latest-firefox

9046 passed, 1495 skipped


Merge workflow run.

@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit 1139417 into microsoft:main Oct 8, 2026
43 of 46 checks passed
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)

2 participants