From bedc5ee082db73472ff8848687695c241faab7c4 Mon Sep 17 00:00:00 2001 From: Rui Figueira Date: Mon, 27 May 2024 13:29:46 +0100 Subject: [PATCH] fix(trace-viewer): fix snapshot.html Actual path to get trace contexts is /contexts, not /context --- packages/trace-viewer/snapshot.html | 2 +- tests/library/trace-viewer.spec.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/trace-viewer/snapshot.html b/packages/trace-viewer/snapshot.html index bee3af79db3f4..3f27586af5aa9 100644 --- a/packages/trace-viewer/snapshot.html +++ b/packages/trace-viewer/snapshot.html @@ -26,7 +26,7 @@ const traceUrl = new URL(location.href).searchParams.get('trace'); const params = new URLSearchParams(); params.set('trace', traceUrl); - await fetch('context?' + params.toString()).then(r => r.json()); + await fetch('contexts?' + params.toString()).then(r => r.json()); await location.reload(); })(); diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.ts index 4a6acb5e85dc5..71358d9d20e38 100644 --- a/tests/library/trace-viewer.spec.ts +++ b/tests/library/trace-viewer.spec.ts @@ -1207,3 +1207,20 @@ test('should remove noscript when javaScriptEnabled is set to true', async ({ br await expect(frame.getByText('Always visible')).toBeVisible(); await expect(frame.getByText('Enable JavaScript to run this app.')).toBeHidden(); }); + +test('should open snapshot in new browser context', async ({ browser, page, runAndTrace, server }) => { + const traceViewer = await runAndTrace(async () => { + await page.goto(server.EMPTY_PAGE); + await page.setContent('hello'); + }); + await traceViewer.snapshotFrame('page.setContent'); + const popupPromise = traceViewer.page.context().waitForEvent('page'); + await traceViewer.page.getByTitle('Open snapshot in a new tab').click(); + const popup = await popupPromise; + + // doesn't share sw.bundle.js + const newPage = await browser.newPage(); + await newPage.goto(popup.url()); + await expect(newPage.getByText('hello')).toBeVisible(); + await newPage.close(); +});