fix: electron video tests (#28004)

This commit is contained in:
Max Schmitt 2023-11-07 23:42:17 +01:00 committed by GitHub
parent cb14de7a5b
commit e788c711c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -525,7 +525,7 @@ export class CRBrowserContext extends BrowserContext {
await Promise.all(openedBeforeUnloadDialogs.map(dialog => dialog.dismiss()));
if (!this._browserContextId) {
await Promise.all(this._crPages().map(crPage => crPage._mainFrameSession._stopVideoRecording()));
await this.stopVideoRecording();
// Closing persistent context should close the browser.
await this._browser.close({ reason });
return;
@ -545,6 +545,10 @@ export class CRBrowserContext extends BrowserContext {
}
}
async stopVideoRecording() {
await Promise.all(this._crPages().map(crPage => crPage._mainFrameSession._stopVideoRecording()));
}
onClosePersistent() {
// When persistent context is closed, we do not necessary get Target.detachedFromTarget
// for all the background pages.

View File

@ -78,6 +78,7 @@ export class ElectronApplication extends SdkObject {
});
});
this._browserContext.setCustomCloseHandler(async () => {
await this._browserContext.stopVideoRecording();
const electronHandle = await this._nodeElectronHandlePromise;
await electronHandle.evaluate(({ app }) => app.quit()).catch(() => {});
});