Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: wait for downloads getting removed on context.close() (#23500)

Max Schmitt8bc26a2b4471
diff --git a/packages/playwright-core/src/server/browserContext.ts b/packages/playwright-core/src/server/browserContext.ts
index e0515d3f3e..5469028964 100644
--- a/packages/playwright-core/src/server/browserContext.ts
+++ b/packages/playwright-core/src/server/browserContext.ts
@@ -232,9 +232,12 @@ export abstract class BrowserContext extends SdkObject {
// at the same time.
return;
}
+ const gotClosedGracefully = this._closedStatus === 'closing';
this._closedStatus = 'closed';
- this._deleteAllDownloads();
- this._downloads.clear();
+ if (!gotClosedGracefully) {
+ this._deleteAllDownloads();
+ this._downloads.clear();
+ }
this.tracing.dispose().catch(() => {});
if (this._isPersistentContext)
this.onClosePersistent();