diff --git a/packages/playwright-core/src/cli/program.ts b/packages/playwright-core/src/cli/program.ts index 1895f2dfcfe18..59ad0cd9f81f0 100644 --- a/packages/playwright-core/src/cli/program.ts +++ b/packages/playwright-core/src/cli/program.ts @@ -554,6 +554,7 @@ async function open(options: Options, url: string | undefined, language: string) contextOptions, device: options.device, saveStorage: options.saveStorage, + handleSIGINT: false, }); await openPage(context, url); } @@ -577,6 +578,7 @@ async function codegen(options: Options & { target: string, output?: string, tes codegenMode: process.env.PW_RECORDER_IS_TRACE_VIEWER ? 'trace-events' : 'actions', testIdAttributeName, outputFile: outputFile ? path.resolve(outputFile) : undefined, + handleSIGINT: false, }); await openPage(context, url); } diff --git a/packages/playwright-core/src/protocol/validator.ts b/packages/playwright-core/src/protocol/validator.ts index d5d91b165de75..864533677cb5e 100644 --- a/packages/playwright-core/src/protocol/validator.ts +++ b/packages/playwright-core/src/protocol/validator.ts @@ -976,6 +976,7 @@ scheme.BrowserContextEnableRecorderParams = tObject({ device: tOptional(tString), saveStorage: tOptional(tString), outputFile: tOptional(tString), + handleSIGINT: tOptional(tBoolean), omitCallTracking: tOptional(tBoolean), }); scheme.BrowserContextEnableRecorderResult = tOptional(tObject({})); diff --git a/packages/playwright-core/src/server/recorder.ts b/packages/playwright-core/src/server/recorder.ts index 386e4dece6f1d..1518e2db4c17a 100644 --- a/packages/playwright-core/src/server/recorder.ts +++ b/packages/playwright-core/src/server/recorder.ts @@ -34,6 +34,7 @@ import { buildFullSelector } from '../utils/isomorphic/recorderUtils'; const recorderSymbol = Symbol('recorderSymbol'); export class Recorder implements InstrumentationListener, IRecorder { + readonly handleSIGINT: boolean | undefined; private _context: BrowserContext; private _mode: Mode; private _highlightedSelector = ''; @@ -75,6 +76,7 @@ export class Recorder implements InstrumentationListener, IRecorder { constructor(codegenMode: 'actions' | 'trace-events', context: BrowserContext, params: channels.BrowserContextEnableRecorderParams) { this._mode = params.mode || 'none'; + this.handleSIGINT = params.handleSIGINT; this._contextRecorder = new ContextRecorder(codegenMode, context, params, {}); this._context = context; this._omitCallTracking = !!params.omitCallTracking; diff --git a/packages/playwright-core/src/server/recorder/recorderApp.ts b/packages/playwright-core/src/server/recorder/recorderApp.ts index 3f9a636579efe..cdb2923af546b 100644 --- a/packages/playwright-core/src/server/recorder/recorderApp.ts +++ b/packages/playwright-core/src/server/recorder/recorderApp.ts @@ -111,7 +111,7 @@ export class RecorderApp extends EventEmitter implements IRecorderApp { noDefaultViewport: true, headless: !!process.env.PWTEST_CLI_HEADLESS || (isUnderTest() && !headed), useWebSocket: isUnderTest(), - handleSIGINT: false, + handleSIGINT: recorder.handleSIGINT, executablePath: inspectedContext._browser.options.isChromium ? inspectedContext._browser.options.customExecutablePath : undefined, } }); diff --git a/packages/playwright-core/src/server/recorder/recorderFrontend.ts b/packages/playwright-core/src/server/recorder/recorderFrontend.ts index 9bf48022a7087..1550314e38f05 100644 --- a/packages/playwright-core/src/server/recorder/recorderFrontend.ts +++ b/packages/playwright-core/src/server/recorder/recorderFrontend.ts @@ -21,6 +21,7 @@ import type { EventEmitter } from 'events'; export interface IRecorder { setMode(mode: Mode): void; mode(): Mode; + readonly handleSIGINT: boolean | undefined; } export interface IRecorderApp extends EventEmitter { diff --git a/packages/protocol/src/channels.ts b/packages/protocol/src/channels.ts index a0d6a30b9faea..7aae5ec99417d 100644 --- a/packages/protocol/src/channels.ts +++ b/packages/protocol/src/channels.ts @@ -1777,6 +1777,7 @@ export type BrowserContextEnableRecorderParams = { device?: string, saveStorage?: string, outputFile?: string, + handleSIGINT?: boolean, omitCallTracking?: boolean, }; export type BrowserContextEnableRecorderOptions = { @@ -1790,6 +1791,7 @@ export type BrowserContextEnableRecorderOptions = { device?: string, saveStorage?: string, outputFile?: string, + handleSIGINT?: boolean, omitCallTracking?: boolean, }; export type BrowserContextEnableRecorderResult = void; diff --git a/packages/protocol/src/protocol.yml b/packages/protocol/src/protocol.yml index a32ebde3d47cf..a88465f9a3574 100644 --- a/packages/protocol/src/protocol.yml +++ b/packages/protocol/src/protocol.yml @@ -1208,6 +1208,7 @@ BrowserContext: device: string? saveStorage: string? outputFile: string? + handleSIGINT: boolean? omitCallTracking: boolean? newCDPSession: