Skip to content

Commit fa15b1b

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Restore the scroll in all frames before taking a screenshot.
Tests run in a subframe and `scrollIntoView` could scroll the parent frame, which could change the visible portion of the test frame. Bug: 401489541 Change-Id: I4e167448f66d5ba54414c9a9ce369e048b876921 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6382080 Commit-Queue: Philip Pfaffe <[email protected]> Auto-Submit: Danil Somsikov <[email protected]> Reviewed-by: Philip Pfaffe <[email protected]>
1 parent 2b7dae6 commit fa15b1b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

front_end/testing/DOMHelpers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ export function querySelectorErrorOnMissing<T extends HTMLElement = HTMLElement>
324324
export async function assertScreenshot(filename: string) {
325325
// To avoid a lot of empty space in the screenshot.
326326
document.getElementById(TEST_CONTAINER_ID)!.style.width = 'fit-content';
327+
let frame: Window|null = window;
328+
while (frame) {
329+
frame.scrollTo(0, 0);
330+
frame = frame.parent !== frame ? frame.parent : null;
331+
}
327332
await raf();
328333
// @ts-expect-error see karma config.
329334
const result = await window.assertScreenshot(`#${TEST_CONTAINER_ID}`, filename);

0 commit comments

Comments
 (0)