-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Version
1.57.0
Steps to reproduce
Repository: https://github.com/rChaoz/bug-repro-playwright-firefox-media-queries
This only reproduces on Linux (e.g. WSL). Run npm i and playwright test.
Expected behavior
All browsers, on all operating systems, headless or not, should report the same media capabilities (except if there are differences in the browser engine/implementations). For example, all "Desktop" setups (devices["Desktop ..."]) should act as if a mouse is present, since page.mouse.move() etc. is available.
For almost most platforms/browsers this works, but headless Firefox on Linux reports wrong media queries.
Actual behavior
Only on Firefox running on Linux in headless mode, there are different media query results. For example, testing for (hover: hover) and (pointer: fine):
- chromium headless Hover: true , pointer fine: true
- chromium non-headless Hover: true , pointer fine: true
- firefox non-headless Hover: true , pointer fine: true
- firefox headless Hover: false , pointer fine: false
- webkit non-headless Hover: true , pointer fine: true
- webkit headless Hover: true , pointer fine: true
On Windows, all 6 tests correctly return true. Note that I was not able to test on Mac. Also, I have only tested 2 queries here, but there may be more.
Workaround
The pointer-related media queries can be fixed using a Firefox config option:
const launchOptions: LaunchOptions | undefined =
process.platform === "linux" ? { firefoxUserPrefs: { "ui.primaryPointerCapabilities": 0x06 } } : undefined
export default defineConfig({
// ...
use: {
//...
launchOptions,
},
})Environment
System:
OS: Windows 11 10.0.26100
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700KF
Memory: 9.42 GB / 31.86 GB
Binaries:
Node: 24.4.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
npm: 11.4.2 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.15.4 - C:\Program Files\nodejs\pnpm.CMD
Languages:
Bash: 5.1.16 - C:\Windows\System32\bash.EXE
npmPackages:
@playwright/test: ^1.57.0 => 1.57.0
playwright: ^1.57.0 => 1.57.0