Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function snapshotScript(viewport: ViewportSize, ...targetIds: (string | undefine
frameBoundingRectsInfo.frames.set(iframe, { boundingRect, scrollLeft: 0, scrollTop: 0 });
const src = iframe.getAttribute('__playwright_src__');
if (!src) {
iframe.setAttribute('src', 'data:text/html,<body style="background: #ddd"></body>');
iframe.setAttribute('src', blankSnapshotUrl);
} else {
// Retain query parameters to inherit name=, time=, pointX=, pointY= and other values from parent.
const url = new URL(win.location.href);
Expand Down Expand Up @@ -639,3 +639,5 @@ function escapeURLsInStyleSheet(text: string): string {
};
return text.replace(urlToEscapeRegex1, replacer).replace(urlToEscapeRegex2, replacer);
}

export const blankSnapshotUrl = 'data:text/html;base64,' + btoa(`<body></body><style>body { color-scheme: light dark; background: light-dark(white, #333) }</style>`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why base64 is needed here? Seems like a nice html snippet.

Copy link
Member Author

@Skn0tt Skn0tt Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of the , in light-dark() - it truncated behind that. i was a little surprised.

2 changes: 1 addition & 1 deletion packages/trace-viewer/src/ui/snapshotTab.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ iframe[name=snapshot] {
width: 100%;
height: 100%;
border: none;
background: white;
background: light-dark(white, #333);
visibility: hidden;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/trace-viewer/src/ui/snapshotTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { clsx, useMeasure, useSetting } from '@web/uiUtils';
import { InjectedScript } from '@injected/injectedScript';
import { Recorder } from '@injected/recorder/recorder';
import { asLocator } from '@isomorphic/locatorGenerators';
import { blankSnapshotUrl } from '@isomorphic/trace/snapshotRenderer';
import type { Language } from '@isomorphic/locatorGenerators';
import { locatorOrSelectorAsSelector } from '@isomorphic/locatorParser';
import { TabbedPaneTab } from '@web/components/tabbedPane';
Expand Down Expand Up @@ -133,7 +134,7 @@ export const SnapshotView: React.FunctionComponent<{
iframe.addEventListener('error', loadedCallback);

// Try preventing history entry from being created.
const snapshotUrl = snapshotUrls?.snapshotUrl || kBlankSnapshotUrl;
const snapshotUrl = snapshotUrls?.snapshotUrl || blankSnapshotUrl;
if (iframe.contentWindow)
iframe.contentWindow.location.replace(snapshotUrl);
else
Expand Down Expand Up @@ -457,4 +458,3 @@ export async function fetchSnapshotInfo(snapshotInfoUrl: string | undefined) {
}

export const kDefaultViewport = { width: 1280, height: 720 };
const kBlankSnapshotUrl = 'data:text/html,<body style="background: #ddd"></body>';
Loading