Skip to content

Commit

Permalink
don't draw checkerboard when canvas is uncaptured
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Oct 18, 2024
1 parent 455be13 commit ea4116e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/trace-viewer/src/sw/snapshotRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,20 +459,20 @@ function snapshotScript(...targetIds: (string | undefined)[]) {
const xEnd = boundingRect.right / window.innerWidth;
const yEnd = boundingRect.bottom / window.innerHeight;

drawCheckerboard(context, canvas);

const partiallyUncaptured = xEnd > 1 || yEnd > 1;
const fullyUncaptured = xStart > 1 || yStart > 1;
if (fullyUncaptured) {
canvas.title = `Playwright couldn't capture canvas contents because it's located outside the viewport.`;
continue;
}

drawCheckerboard(context, canvas);

context.drawImage(img, xStart * img.width, yStart * img.height, (xEnd - xStart) * img.width, (yEnd - yStart) * img.height, 0, 0, canvas.width, canvas.height);
if (isUnderTest)
// eslint-disable-next-line no-console
console.log(`canvas drawn:`, JSON.stringify([xStart, yStart, xEnd, yEnd].map(v => Math.floor(v * 100))));

const partiallyUncaptured = xEnd > 1 || yEnd > 1;
if (partiallyUncaptured)
canvas.title = `Playwright couldn't capture full canvas contents because it's located partially outside the viewport.`;
else
Expand Down

0 comments on commit ea4116e

Please sign in to comment.