Skip to content

Commit 4d9e815

Browse files
authored
fix(mcp): do not disable extensions in persistent mode (#37325)
1 parent 44327df commit 4d9e815

File tree

16 files changed

+45
-62
lines changed

16 files changed

+45
-62
lines changed

docs/src/api/params.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,18 @@ Dangerous option; use with care. Defaults to `false`.
235235

236236
Network proxy settings.
237237

238+
## js-browser-option-env
239+
* langs: js
240+
- `env` <[Object]<[string], [string]|[undefined]>>
241+
238242
## csharp-java-browser-option-env
239243
* langs: csharp, java
240244
- `env` <[Object]<[string], [string]>>
241245

242246
Specify environment variables that will be visible to the browser. Defaults to `process.env`.
243247

244-
## js-python-browser-option-env
245-
* langs: js, python
248+
## python-browser-option-env
249+
* langs: python
246250
- `env` <[Object]<[string], [string]|[float]|[boolean]>>
247251

248252
Specify environment variables that will be visible to the browser. Defaults to `process.env`.
@@ -1122,7 +1126,8 @@ Slows down Playwright operations by the specified amount of milliseconds. Useful
11221126
- %%-browser-option-devtools-%%
11231127
- %%-browser-option-downloadspath-%%
11241128
- %%-csharp-java-browser-option-env-%%
1125-
- %%-js-python-browser-option-env-%%
1129+
- %%-js-browser-option-env-%%
1130+
- %%-python-browser-option-env-%%
11261131
- %%-browser-option-executablepath-%%
11271132
- %%-browser-option-handlesigint-%%
11281133
- %%-browser-option-handlesigterm-%%

packages/playwright-client/types/types.d.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14918,10 +14918,7 @@ export interface BrowserType<Unused = {}> {
1491814918
*/
1491914919
downloadsPath?: string;
1492014920

14921-
/**
14922-
* Specify environment variables that will be visible to the browser. Defaults to `process.env`.
14923-
*/
14924-
env?: { [key: string]: string|number|boolean; };
14921+
env?: { [key: string]: string|undefined; };
1492514922

1492614923
/**
1492714924
* Path to a browser executable to run instead of the bundled one. If
@@ -15351,10 +15348,7 @@ export interface BrowserType<Unused = {}> {
1535115348
*/
1535215349
downloadsPath?: string;
1535315350

15354-
/**
15355-
* Specify environment variables that will be visible to the browser. Defaults to `process.env`.
15356-
*/
15357-
env?: { [key: string]: string|number|boolean; };
15351+
env?: { [key: string]: string|undefined; };
1535815352

1535915353
/**
1536015354
* Path to a browser executable to run instead of the bundled one. If
@@ -21766,10 +21760,7 @@ export interface LaunchOptions {
2176621760
*/
2176721761
downloadsPath?: string;
2176821762

21769-
/**
21770-
* Specify environment variables that will be visible to the browser. Defaults to `process.env`.
21771-
*/
21772-
env?: { [key: string]: string|number|boolean; };
21763+
env?: { [key: string]: string|undefined; };
2177321764

2177421765
/**
2177521766
* Path to a browser executable to run instead of the bundled one. If

packages/playwright-core/src/browserServerImpl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import * as validatorPrimitives from './protocol/validatorPrimitives';
2626
import { ProgressController } from './server/progress';
2727

2828
import type { BrowserServer, BrowserServerLauncher } from './client/browserType';
29-
import type { LaunchOptions, LaunchServerOptions, Logger, Env } from './client/types';
29+
import type { LaunchOptions, LaunchServerOptions, Logger } from './client/types';
3030
import type { ProtocolLogger } from './server/types';
3131
import type { WebSocketEventEmitter } from './utilsBundle';
3232
import type { Browser } from './server/browser';
@@ -112,7 +112,7 @@ function toProtocolLogger(logger: Logger | undefined): ProtocolLogger | undefine
112112
} : undefined;
113113
}
114114

115-
function envObjectToArray(env: Env): { name: string, value: string }[] {
115+
function envObjectToArray(env: NodeJS.ProcessEnv): { name: string, value: string }[] {
116116
const result: { name: string, value: string }[] = [];
117117
for (const name in env) {
118118
if (!Object.is(env[name], undefined))

packages/playwright-core/src/client/clientHelper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717

1818
import { isString } from '../utils/isomorphic/rtti';
1919

20-
import type * as types from './types';
2120
import type { Platform } from './platform';
2221

23-
export function envObjectToArray(env: types.Env): { name: string, value: string }[] {
22+
export function envObjectToArray(env: NodeJS.ProcessEnv): { name: string, value: string }[] {
2423
const result: { name: string, value: string }[] = [];
2524
for (const name in env) {
2625
if (!Object.is(env[name], undefined))

packages/playwright-core/src/client/electron.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { Waiter } from './waiter';
2525
import { TimeoutSettings } from './timeoutSettings';
2626

2727
import type { Page } from './page';
28-
import type { BrowserContextOptions, Env, Headers, WaitForEventOptions } from './types';
28+
import type { BrowserContextOptions, Headers, WaitForEventOptions } from './types';
2929
import type * as structs from '../../types/structs';
3030
import type * as api from '../../types/types';
3131
import type * as channels from '@protocol/channels';
@@ -34,7 +34,7 @@ import type { BrowserWindow } from 'electron';
3434
import type { Playwright } from './playwright';
3535

3636
type ElectronOptions = Omit<channels.ElectronLaunchOptions, 'env'|'extraHTTPHeaders'|'recordHar'|'colorScheme'|'acceptDownloads'> & {
37-
env?: Env,
37+
env?: NodeJS.ProcessEnv,
3838
extraHTTPHeaders?: Headers,
3939
recordHar?: BrowserContextOptions['recordHar'],
4040
colorScheme?: 'dark' | 'light' | 'no-preference' | null,

packages/playwright-core/src/client/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export interface Logger {
2828
export type TimeoutOptions = { timeout?: number };
2929
export type StrictOptions = { strict?: boolean };
3030
export type Headers = { [key: string]: string };
31-
export type Env = { [key: string]: string | number | boolean | undefined };
3231

3332
export type WaitForEventOptions = Function | TimeoutOptions & { predicate?: Function };
3433
export type WaitForFunctionOptions = TimeoutOptions & { polling?: 'raf' | number };
@@ -88,7 +87,7 @@ export type BrowserContextOptions = Omit<channels.BrowserNewContextOptions, 'vie
8887

8988
type LaunchOverrides = {
9089
ignoreDefaultArgs?: boolean | string[];
91-
env?: Env;
90+
env?: NodeJS.ProcessEnv;
9291
logger?: Logger;
9392
firefoxUserPrefs?: { [key: string]: string | number | boolean };
9493
} & TimeoutOptions;

packages/playwright-core/src/server/bidi/bidiChromium.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { waitForReadyState } from '../chromium/chromium';
2626

2727
import type { BrowserOptions } from '../browser';
2828
import type { SdkObject } from '../instrumentation';
29-
import type { Env } from '../utils/processLauncher';
3029
import type { ProtocolError } from '../protocolError';
3130
import type { ConnectionTransport } from '../transport';
3231
import type * as types from '../types';
@@ -77,7 +76,7 @@ export class BidiChromium extends BrowserType {
7776
return error;
7877
}
7978

80-
override amendEnvironment(env: Env): Env {
79+
override amendEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
8180
return env;
8281
}
8382

packages/playwright-core/src/server/bidi/bidiFirefox.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { ManualPromise } from '../../utils/isomorphic/manualPromise';
2626

2727
import type { BrowserOptions } from '../browser';
2828
import type { SdkObject } from '../instrumentation';
29-
import type { Env } from '../utils/processLauncher';
3029
import type { ProtocolError } from '../protocolError';
3130
import type { ConnectionTransport } from '../transport';
3231
import type * as types from '../types';
@@ -57,7 +56,7 @@ export class BidiFirefox extends BrowserType {
5756
return error;
5857
}
5958

60-
override amendEnvironment(env: Env): Env {
59+
override amendEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
6160
if (!path.isAbsolute(os.homedir()))
6261
throw new Error(`Cannot launch Firefox with relative home directory. Did you set ${os.platform() === 'win32' ? 'USERPROFILE' : 'HOME'} to a relative path?`);
6362

packages/playwright-core/src/server/browserType.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import { RecentLogsCollector } from './utils/debugLogger';
3636

3737
import type { Browser, BrowserOptions, BrowserProcess } from './browser';
3838
import type { BrowserContext } from './browserContext';
39-
import type { Env } from './utils/processLauncher';
4039
import type { Progress } from './progress';
4140
import type { ProtocolError } from './protocolError';
4241
import type { BrowserName } from './registry';
@@ -341,7 +340,7 @@ export abstract class BrowserType extends SdkObject {
341340

342341
abstract defaultArgs(options: types.LaunchOptions, isPersistent: boolean, userDataDir: string): string[];
343342
abstract connectToTransport(transport: ConnectionTransport, options: BrowserOptions, browserLogsCollector: RecentLogsCollector): Promise<Browser>;
344-
abstract amendEnvironment(env: Env, userDataDir: string, isPersistent: boolean): Env;
343+
abstract amendEnvironment(env: NodeJS.ProcessEnv, userDataDir: string, isPersistent: boolean): NodeJS.ProcessEnv;
345344
abstract doRewriteStartupLog(error: ProtocolError): ProtocolError;
346345
abstract attemptToGracefullyCloseBrowser(transport: ConnectionTransport): void;
347346
}

packages/playwright-core/src/server/chromium/chromium.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import { gracefullyCloseSet } from '../utils/processLauncher';
4141
import type { HTTPRequestParams } from '../utils/network';
4242
import type { BrowserOptions, BrowserProcess } from '../browser';
4343
import type { SdkObject } from '../instrumentation';
44-
import type { Env } from '../utils/processLauncher';
4544
import type { Progress } from '../progress';
4645
import type { ProtocolError } from '../protocolError';
4746
import type { ConnectionTransport, ProtocolRequest } from '../transport';
@@ -165,7 +164,7 @@ export class Chromium extends BrowserType {
165164
return error;
166165
}
167166

168-
override amendEnvironment(env: Env): Env {
167+
override amendEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
169168
return env;
170169
}
171170

0 commit comments

Comments
 (0)