From 2e087e514688c783b9b07d1be2b018e874887d91 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 2 Oct 2026 16:10:22 +0100 Subject: [PATCH] test: add fixme test for binding called from pagehide in chromium References: https://github.com/microsoft/playwright/issues/43064 --- .../browsercontext-expose-function.spec.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/library/browsercontext-expose-function.spec.ts b/tests/library/browsercontext-expose-function.spec.ts index ab1acc37ab882..6050f5961f4c7 100644 --- a/tests/library/browsercontext-expose-function.spec.ts +++ b/tests/library/browsercontext-expose-function.spec.ts @@ -97,3 +97,24 @@ it('should work with CSP', async ({ page, context, server }) => { await page.evaluate(() => (window as any).hi()); expect(called).toBe(true); }); + +it('should call binding from pagehide handler when navigating away', { + annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43064' }, +}, async ({ context, page, server, browserName }) => { + it.fixme(browserName === 'chromium', 'Chromium drops CDP events from the old document after the frame host swap'); + const calls: string[] = []; + await context.exposeBinding('reportFromPage', (_source, message: string) => { calls.push(message); }); + const html = (body: string) => `${body}`; + server.setRoute('/a.html', (req, res) => { + res.writeHead(200, { 'content-type': 'text/html' }); + res.end(html(``)); + }); + server.setRoute('/b.html', (req, res) => { + res.writeHead(200, { 'content-type': 'text/html' }); + res.end(html(`

b

`)); + }); + await page.goto(server.PREFIX + '/a.html'); + await page.click('#next'); + await page.waitForURL('**/b.html'); + await expect.poll(() => calls).toContain('pagehide of /a.html'); +});