Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: mark outofprocess connection not as remote (#28156)
Max Schmitt2d2c270388a5
diff --git a/packages/playwright-core/src/client/channelOwner.ts b/packages/playwright-core/src/client/channelOwner.tsindex b81d757156..2093f6ca26 100644--- a/packages/playwright-core/src/client/channelOwner.ts+++ b/packages/playwright-core/src/client/channelOwner.ts@@ -147,7 +147,7 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.ChannelapiZone.reported = true;if (csi && apiName)csi.onApiCallBegin(apiName, params, frames, wallTime, callCookie);- return this._connection.sendMessageToServer(this, prop, validator(params, '', { tChannelImpl: tChannelImplToWire, binary: this._connection.isRemote() ? 'toBase64' : 'buffer' }), apiName, frames, wallTime);+ return this._connection.sendMessageToServer(this, prop, validator(params, '', { tChannelImpl: tChannelImplToWire, binary: this._connection.rawBuffers() ? 'buffer' : 'toBase64' }), apiName, frames, wallTime);});};}diff --git a/packages/playwright-core/src/client/connection.ts b/packages/playwright-core/src/client/connection.tsindex e7805e5243..6184666eed 100644--- a/packages/playwright-core/src/client/connection.ts+++ b/packages/playwright-core/src/client/connection.ts@@ -70,6 +70,7 @@ export class Connection extends EventEmitter {private _closedError: Error | undefined;private _isRemote = false;private _localUtils?: LocalUtils;+ private _rawBuffers = false;// Some connections allow resolving in-process dispatchers.toImpl: ((client: ChannelOwner) => any) | undefined;private _tracingCount = 0;@@ -90,6 +91,14 @@ export class Connection extends EventEmitter {return this._isRemote;}+ useRawBuffers() {+ this._rawBuffers = true;+ }++ rawBuffers() {+ return this._rawBuffers;+ }+localUtils(): LocalUtils {return this._localUtils!;}@@ -149,7 +158,7 @@ export class Connection extends EventEmitter {callback.reject(parsedError);} else {const validator = findValidator(callback.type, callback.method, 'Result');- callback.resolve(validator(result, '', { tChannelImpl: this._tChannelImplFromWire.bind(this), binary: this.isRemote() ? 'fromBase64' : 'buffer' }));+ callback.resolve(validator(result, '', { tChannelImpl: this._tChannelImplFromWire.bind(this), binary: this._rawBuffers ? 'buffer' : 'fromBase64' }));}return;}@@ -179,7 +188,7 @@ export class Connection extends EventEmitter {}const validator = findValidator(object._type, method, 'Event');- (object._channel as any).emit(method, validator(params, '', { tChannelImpl: this._tChannelImplFromWire.bind(this), binary: this.isRemote() ? 'fromBase64' : 'buffer' }));+ (object._channel as any).emit(method, validator(params, '', { tChannelImpl: this._tChannelImplFromWire.bind(this), binary: this._rawBuffers ? 'buffer' : 'fromBase64' }));}close(cause?: Error) {@@ -208,7 +217,7 @@ export class Connection extends EventEmitter {throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);let result: ChannelOwner<any>;const validator = findValidator(type, '', 'Initializer');- initializer = validator(initializer, '', { tChannelImpl: this._tChannelImplFromWire.bind(this), binary: this.isRemote() ? 'fromBase64' : 'buffer' });+ initializer = validator(initializer, '', { tChannelImpl: this._tChannelImplFromWire.bind(this), binary: this._rawBuffers ? 'buffer' : 'fromBase64' });switch (type) {case 'Android':result = new Android(parent, type, guid, initializer);diff --git a/packages/playwright-core/src/inProcessFactory.ts b/packages/playwright-core/src/inProcessFactory.tsindex 8bbfa82379..f38589f0b2 100644--- a/packages/playwright-core/src/inProcessFactory.ts+++ b/packages/playwright-core/src/inProcessFactory.ts@@ -25,6 +25,7 @@ export function createInProcessPlaywright(): PlaywrightAPI {const playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' });const clientConnection = new Connection(undefined, undefined);+ clientConnection.useRawBuffers();const dispatcherConnection = new DispatcherConnection(true /* local */);// Dispatch synchronously at first.diff --git a/packages/playwright-core/src/outofprocess.ts b/packages/playwright-core/src/outofprocess.tsindex adc0783387..537f37c28d 100644--- a/packages/playwright-core/src/outofprocess.ts+++ b/packages/playwright-core/src/outofprocess.ts@@ -46,7 +46,6 @@ class PlaywrightClient {this._driverProcess.stderr!.on('data', data => process.stderr.write(data));const connection = new Connection(undefined, undefined);- connection.markAsRemote();const transport = new PipeTransport(this._driverProcess.stdin!, this._driverProcess.stdout!);connection.onmessage = message => transport.send(JSON.stringify(message));transport.onmessage = message => connection.dispatch(JSON.parse(message));diff --git a/tests/library/download.spec.ts b/tests/library/download.spec.tsindex 9fd0656f33..9e6fb2b8e5 100644--- a/tests/library/download.spec.ts+++ b/tests/library/download.spec.ts@@ -666,7 +666,7 @@ it('should save to user-specified path', async ({ browser, server, mode }, testIpage.waitForEvent('download'),page.click('a')]);- if (mode !== 'default') {+ if (mode.startsWith('service')) {const error = await download.path().catch(e => e);expect(error.message).toContain('Path is not available when connecting remotely. Use saveAs() to save a local copy.');}