From 0007dd59b74166902a5e6c2405ede0768983da8e Mon Sep 17 00:00:00 2001 From: Sameem-baba Date: Wed, 4 Mar 2026 15:07:56 +0530 Subject: [PATCH] Use visual viewport instead of initial viewport in screenshot algorithms The screenshot algorithms reference the initial viewport when computing framebuffer bounds. If the browser window is resized after the document loads, this can lead to incorrect clipping. Update the algorithms to reference the visual viewport instead. Fixes #1947 --- index.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index f2d116d7..4ad304fe 100644 --- a/index.html +++ b/index.html @@ -10926,12 +10926,12 @@

Screen capture

Screenshots are a mechanism for providing additional visual diagnostic information. - They work by dumping a snapshot of the initial viewport's + They work by dumping a snapshot of the visual viewport's framebuffer as a lossless PNG image. It is returned to the local end as a Base64 encoded string.

WebDriver provides the Take Screenshot command - to capture the top-level browsing context's initial viewport, + to capture the top-level browsing context's visual viewport, and a command Take Element Screenshot for doing the same with the visible region of an element's bounding rectangle after it has been scrolled into view. @@ -10940,15 +10940,15 @@

Screen capture

given a rectangle:
    -
  1. If either the initial viewport's width or height +

  2. If either the visual viewport's width or height is 0 CSS pixels, return error with error code unable to capture screen. -

  3. Let paint width be the initial viewport's width – +

  4. Let paint width be the visual viewport's width – min(rectangle x coordinate, rectangle x coordinate + rectangle width dimension). -

  5. Let paint height be the initial viewport's height – +

  6. Let paint height be the visual viewport's height – min(rectangle y coordinate, rectangle y coordinate + rectangle height dimension). @@ -11973,6 +11973,7 @@

    Index

  7. ScrollIntoViewOptions
  8. Logical scroll position "block"
  9. Logical scroll position "inline" +
  10. visual viewport
    The following terms are defined in [[mediaqueries-4]]: