Skip to content

Device pixel ratio for tests #220

Open
@gsnedders

Description

@gsnedders

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions