review feedback

This commit is contained in:
Max Schmitt 2024-04-12 19:17:23 +02:00
parent 6e245ed33e
commit 407547750a
4 changed files with 8 additions and 9 deletions

View file

@ -432,7 +432,7 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
this._browser._contexts.delete(this);
this._browserType?._contexts?.delete(this);
this._disposeHarRouters();
this.tracing._resetStackCounterIfNeeded();
this.tracing._resetStackCounter();
this.emit(Events.BrowserContext.Close, this);
}

View file

@ -102,6 +102,7 @@ export class APIRequestContext extends ChannelOwner<channels.APIRequestContextCh
async dispose(): Promise<void> {
await this._instrumentation.onWillCloseRequestContext(this);
await this._channel.dispose();
this._tracing._resetStackCounter();
this._request?._contexts.delete(this);
}

View file

@ -76,7 +76,7 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
}
private async _doStopChunk(filePath: string | undefined) {
this._resetStackCounterIfNeeded();
this._resetStackCounter();
if (!filePath) {
// Not interested in artifacts.
@ -111,7 +111,7 @@ export class Tracing extends ChannelOwner<channels.TracingChannel> implements ap
await this._connection.localUtils()._channel.zip({ zipFile: filePath, entries: [], mode: 'append', stacksId: this._stacksId, includeSources: this._includeSources });
}
_resetStackCounterIfNeeded() {
_resetStackCounter() {
if (this._isTracing) {
this._isTracing = false;
this._connection.setIsTracing(false);

View file

@ -17,19 +17,17 @@
import { browserTest, expect } from '../config/browserTest';
import type { BrowserContext, BrowserContextOptions } from '@playwright/test';
const test = browserTest.extend<{}, { reusedContext: (options?: BrowserContextOptions) => Promise<BrowserContext> }>({
reusedContext: [async ({ browserType, browser }, use) => {
let context;
const test = browserTest.extend<{ reusedContext: (options?: BrowserContextOptions) => Promise<BrowserContext> }>({
reusedContext: async ({ browserType, browser }, use) => {
await use(async (options: BrowserContextOptions = {}) => {
const defaultContextOptions = (browserType as any)._defaultContextOptions;
context = await (browser as any)._newContextForReuse({
const context = await (browser as any)._newContextForReuse({
...defaultContextOptions,
...options,
});
return context;
});
await context.close();
}, { scope: 'worker' }],
},
});
test('should re-add binding after reset', async ({ reusedContext }) => {