Skip to content

Consider changing initial viewport to visual viewport for element screenshots #1947

@Sameem-baba

Description

@Sameem-baba

While working on a Firefox patch to clip oversized elements during screenshots (to prevent massive canvas allocation failures), we noticed a potential quirk in the classic WebDriver spec.

Right now, the algorithm to draw a bounding box from the framebuffer uses the initial viewport as its reference.

The issue with using initial viewport is that if the browser window gets resized after the page first renders, using those initial dimensions to calculate intersections or bounds can lead to incorrectly clipped screenshots.

It feels like the spec should be updated to use the viewport (or visual viewport) instead. This would actually bring Classic into parity with WebDriver BiDi, which already does the right thing by using the current viewport when getting the origin rectangle.

We're moving ahead with updating the Firefox implementation to match the BiDi logic for this, but it would be great to get the Classic spec updated to reflect this as well so we don't have diverging behaviors!

Let me know what you think.

Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=2013176

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions