Skip to content

Commit

Permalink
fix(electron): tolerate connection closed during quit (#18993)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Nov 22, 2022
1 parent a0ea9b5 commit 73e7c0e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/electron/electron.ts
Expand Up @@ -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(() => {});
});
}

Expand Down
3 changes: 2 additions & 1 deletion packages/playwright-core/src/server/electron/loader.ts
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions tests/electron/electron-app.spec.ts
Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 73e7c0e

Please sign in to comment.