fix: exception in exposeFunction when oopif detaches (#18078)
The test is racy but it was reliably failing several times in 100 iterations. Fixes https://github.com/microsoft/playwright/issues/18067
This commit is contained in:
parent
1c1060e85b
commit
7219a68b12
|
|
@ -133,7 +133,7 @@ export class CRPage implements PageDelegate {
|
|||
return cb(frameSession);
|
||||
return cb(frameSession).catch(e => {
|
||||
// Broadcasting a message to the closed iframe shoule be a noop.
|
||||
if (e.message && (e.message.includes('Target closed.') || e.message.includes('Session closed.')))
|
||||
if (e.message && e.message.includes('Target closed'))
|
||||
return;
|
||||
throw e;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -326,6 +326,16 @@ it('should emit filechooser event for iframe', async ({ page, server, browser })
|
|||
expect(chooser).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not throw on exposeFunction when oopif detaches', async ({ page, browser, server }) => {
|
||||
await page.goto(server.PREFIX + '/dynamic-oopif.html');
|
||||
expect(await countOOPIFs(browser)).toBe(1);
|
||||
await Promise.all([
|
||||
page.exposeFunction('myFunc', () => 2022),
|
||||
page.evaluate(() => document.querySelector('iframe').remove()),
|
||||
]);
|
||||
expect(await page.evaluate(() => (window as any).myFunc())).toBe(2022);
|
||||
});
|
||||
|
||||
async function countOOPIFs(browser) {
|
||||
const browserSession = await browser.newBrowserCDPSession();
|
||||
const oopifs = [];
|
||||
|
|
|
|||
Loading…
Reference in a new issue