fix(chromium): properly detect session closed errors for oopifs (#28197)

Exposed by the flaky test `should not throw on exposeFunction when oopif
detaches`.
This commit is contained in:
Dmitry Gozman 2023-11-16 11:44:10 -08:00 committed by GitHub
parent ff706ec8bd
commit da6707f785
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,6 +46,7 @@ import type { Protocol } from './protocol';
import { VideoRecorder } from './videoRecorder'; import { VideoRecorder } from './videoRecorder';
import { BrowserContext } from '../browserContext'; import { BrowserContext } from '../browserContext';
import { TargetClosedError } from '../errors'; import { TargetClosedError } from '../errors';
import { isSessionClosedError } from '../protocolError';
const UTILITY_WORLD_NAME = '__playwright_utility_world__'; const UTILITY_WORLD_NAME = '__playwright_utility_world__';
@ -132,7 +133,7 @@ export class CRPage implements PageDelegate {
return cb(frameSession); return cb(frameSession);
return cb(frameSession).catch(e => { return cb(frameSession).catch(e => {
// Broadcasting a message to the closed iframe should be a noop. // Broadcasting a message to the closed iframe should be a noop.
if (e.message && e.message.includes('Target closed')) if (isSessionClosedError(e))
return; return;
throw e; throw e;
}); });