Have the lifecycle dependent on the Page since we only support 1 window for now (#264099)

This makes sure that closing the window actually closes everything to workaround the macOS behavior of having all windows closed but it's still running.
This commit is contained in:
Tyler James Leonhardt
2025-08-29 16:07:36 -07:00
committed by GitHub
parent 8adf7c1c39
commit 3c90d276e0
2 changed files with 6 additions and 2 deletions

View File

@@ -323,7 +323,7 @@ export async function getApplication() {
extraArgs: (opts.electronArgs || '').split(' ').map(arg => arg.trim()).filter(arg => !!arg),
});
await application.start();
application.code.driver.browserContext.on('close', async () => {
application.code.driver.currentPage.on('close', async () => {
fs.rmSync(testDataPath, { recursive: true, force: true, maxRetries: 10 });
});
return application;
@@ -355,7 +355,7 @@ export class ApplicationService {
}
if (!this._application) {
this._application = await getApplication();
this._application.code.driver.browserContext.on('close', () => {
this._application.code.driver.currentPage.on('close', () => {
this._closing = (async () => {
if (this._application) {
this._application.code.driver.browserContext.removeAllListeners();