Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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