fix(trace-viewer): popup snapshot utf-8 support (#32006)

This commit is contained in:
Max Schmitt 2024-08-05 09:11:31 +02:00 committed by GitHub
parent c54567a46b
commit dbc4bc84d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -37,7 +37,7 @@ export class SnapshotServer {
return new Response(null, { status: 404 }); return new Response(null, { status: 404 });
const renderedSnapshot = snapshot.render(); const renderedSnapshot = snapshot.render();
this._snapshotIds.set(snapshotUrl, snapshot); this._snapshotIds.set(snapshotUrl, snapshot);
return new Response(renderedSnapshot.html, { status: 200, headers: { 'Content-Type': 'text/html' } }); return new Response(renderedSnapshot.html, { status: 200, headers: { 'Content-Type': 'text/html; charset=utf-8' } });
} }
serveSnapshotInfo(pathname: string, searchParams: URLSearchParams): Response { serveSnapshotInfo(pathname: string, searchParams: URLSearchParams): Response {

View File

@ -291,13 +291,13 @@ test('should show snapshot URL', async ({ page, runAndTrace, server }) => {
test('should popup snapshot', async ({ page, runAndTrace, server }) => { test('should popup snapshot', async ({ page, runAndTrace, server }) => {
const traceViewer = await runAndTrace(async () => { const traceViewer = await runAndTrace(async () => {
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);
await page.setContent('hello'); await page.setContent('hello äöü 🙂');
}); });
await traceViewer.snapshotFrame('page.setContent'); await traceViewer.snapshotFrame('page.setContent');
const popupPromise = traceViewer.page.context().waitForEvent('page'); const popupPromise = traceViewer.page.context().waitForEvent('page');
await traceViewer.page.getByTitle('Open snapshot in a new tab').click(); await traceViewer.page.getByTitle('Open snapshot in a new tab').click();
const popup = await popupPromise; const popup = await popupPromise;
await expect(popup.getByText('hello')).toBeVisible(); await expect(popup.getByText('hello äöü 🙂')).toBeVisible();
}); });
test('should capture iframe with sandbox attribute', async ({ page, server, runAndTrace }) => { test('should capture iframe with sandbox attribute', async ({ page, server, runAndTrace }) => {