fix(electron): tolerate connection closed during quit (#18993)

This commit is contained in:
Pavel Feldman 2022-11-22 11:50:35 -08:00 committed by GitHub
parent a0ea9b5fba
commit 73e7c0ed3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

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

View File

@ -29,9 +29,10 @@ process.argv[1] = appPath;
for (const arg of chromiumSwitches) {
const match = arg.match(/--([^=]*)=?(.*)/)!;
app.commandLine.appendSwitch(match[1], match[2]);
app.getAppPath = () => path.dirname(appPath);
}
app.getAppPath = () => path.dirname(appPath);
let launchInfoEventPayload: any;
app.on('ready', launchInfo => launchInfoEventPayload = launchInfo);

View File

@ -154,6 +154,7 @@ test('should create page for browser view', async ({ playwright }) => {
const app = await playwright._electron.launch({
args: [path.join(__dirname, 'electron-window-app.js')],
});
await app.firstWindow();
await app.evaluate(async electron => {
const window = electron.BrowserWindow.getAllWindows()[0];
const view = new electron.BrowserView();
@ -169,6 +170,7 @@ test('should return same browser window for browser view pages', async ({ playwr
const app = await playwright._electron.launch({
args: [path.join(__dirname, 'electron-window-app.js')],
});
await app.firstWindow();
await app.evaluate(async electron => {
const window = electron.BrowserWindow.getAllWindows()[0];
const view = new electron.BrowserView();