Skip to content

Commit

Permalink
cherry-pick(#18993): fix(electron): tolerate connection closed during…
Browse files Browse the repository at this point in the history
… quit
  • Loading branch information
pavelfeldman committed Nov 22, 2022
1 parent f38b2c8 commit 76dc43e
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 76dc43e

Please sign in to comment.