Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/playwright-core/src/client/clientInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface ClientInstrumentation {
removeAllListeners(): void;
onApiCallBegin(apiCall: string, params: Record<string, any>, frames: StackFrame[], userData: any, out: { stepId?: string }): void;
onApiCallEnd(userData: any, error?: Error): void;
onWillPause(): void;
onWillPause(options: { keepTestTimeout: boolean }): void;

runAfterCreateBrowserContext(context: BrowserContext): Promise<void>;
runAfterCreateRequestContext(context: APIRequestContext): Promise<void>;
Expand All @@ -35,7 +35,7 @@ export interface ClientInstrumentation {
export interface ClientInstrumentationListener {
onApiCallBegin?(apiName: string, params: Record<string, any>, frames: StackFrame[], userData: any, out: { stepId?: string }): void;
onApiCallEnd?(userData: any, error?: Error): void;
onWillPause?(): void;
onWillPause?(options: { keepTestTimeout: boolean }): void;

runAfterCreateBrowserContext?(context: BrowserContext): Promise<void>;
runAfterCreateRequestContext?(context: APIRequestContext): Promise<void>;
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/src/client/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,14 +786,14 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
return [...this._workers];
}

async pause() {
async pause(_options?: { __testHookKeepTestTimeout: boolean }) {
if (require('inspector').url())
return;
const defaultNavigationTimeout = this._browserContext._timeoutSettings.defaultNavigationTimeout();
const defaultTimeout = this._browserContext._timeoutSettings.defaultTimeout();
this._browserContext.setDefaultNavigationTimeout(0);
this._browserContext.setDefaultTimeout(0);
this._instrumentation?.onWillPause();
this._instrumentation?.onWillPause({ keepTestTimeout: !!_options?.__testHookKeepTestTimeout });
await this._closedOrCrashedScope.safeRace(this.context()._channel.pause());
this._browserContext.setDefaultNavigationTimeout(defaultNavigationTimeout);
this._browserContext.setDefaultTimeout(defaultTimeout);
Expand Down
5 changes: 3 additions & 2 deletions packages/playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
const step = userData.step;
step?.complete({ error });
},
onWillPause: () => {
currentTestInfo()?._setDebugMode();
onWillPause: ({ keepTestTimeout }) => {
if (!keepTestTimeout)
currentTestInfo()?._setDebugMode();
},
runAfterCreateBrowserContext: async (context: BrowserContext) => {
await artifactsRecorder?.didCreateBrowserContext(context);
Expand Down
3 changes: 2 additions & 1 deletion tests/library/browsertype-connect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ for (const kind of ['launchServer', 'run-server'] as const) {
const browser = await connect(remoteServer.wsEndpoint());
const browserContext = await browser.newContext();
const page = await browserContext.newPage();
await page.pause();
// @ts-ignore
await page.pause({ __testHookKeepTestTimeout: true });
await browser.close();
(browserType as any)._defaultLaunchOptions.headless = headless;
});
Expand Down
3 changes: 2 additions & 1 deletion tests/library/inspector/console-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ let scriptPromise: Promise<void>;

it.beforeEach(async ({ page, recorderPageGetter }) => {
scriptPromise = (async () => {
await page.pause();
// @ts-ignore
await page.pause({ __testHookKeepTestTimeout: true });
})();
await recorderPageGetter();
});
Expand Down
Loading
Loading