Skip to content

Device pixel ratio for tests #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gsnedders opened this issue Mar 18, 2025 · 0 comments
Open

Device pixel ratio for tests #220

gsnedders opened this issue Mar 18, 2025 · 0 comments

Comments

@gsnedders
Copy link
Member

gsnedders commented Mar 18, 2025

https://web-platform-tests.org/writing-tests/assumptions.html doesn't document anything about what the device pixel ratio of the viewport is (for HiDPI/Hi-DPI/retina/etc. displays).

RFC #41: Print Testing says for print that we rasterise it at 96 dpi, but doesn't say what device pixel ratio we render at:

The WebDriver-based implementation first renders the document to a PDF, and then computes the reftest result by rasterising the test and ref PDFs at 96 dpi.

There is prior discussion in web-platform-tests/wpt#7140, web-platform-tests/wpt#20284, and web-platform-tests/wpt#31457.

As far as I can tell, for Gecko it is set to 1.0 in:

https://github.com/mozilla/gecko-dev/blob/fd2b3e70974daa97cd27b24fd3484abb662c671f/testing/profiles/web-platform/user.js#L48-L49

And:

https://github.com/web-platform-tests/wpt/blob/85b598e6524f25d7821a824d6c5e9a3f848740b8/tools/wptrunner/wptrunner/browsers/firefox_android.py#L181-L182

WebKit, for WKTR, sets it in:

https://github.com/WebKit/WebKit/blob/312e1f95f86f42d48b464e54109375a036572cde/Tools/WebKitTestRunner/TestOptions.cpp#L222

This is, however, ignored on iOS. (For DRT, it's set in many places, per-platform, and I'm not gonna link to all of them here!)

Chromium I think does this in many places, depending on how it is being run, but I'm not totally sure. That said, some of the failures on wpt.fyi seem like they might be caused by running at a device pixel ratio which is not 1.0, though we don't have screenshots to see what's going on there.

Currently, on wpt.fyi, Edge and Safari are both run on HiDPI screens, I believe; see web-platform-tests/wpt#5498 and web-platform-tests/wpt#20058.

WebDriver doesn't expose any way to change the device pixel ratio, w3c/webdriver#1547, though WebDriver BiDi does, thus currently our only way to do this is via settings.

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

No branches or pull requests

1 participant