mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-05 19:04:43 +03:00
chore: mark outofprocess connection not as remote (#28156)
This commit is contained in:
parent
2adfbf24a9
commit
2d2c270388
@ -147,7 +147,7 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
|
||||
apiZone.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);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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));
|
||||
|
@ -666,7 +666,7 @@ it('should save to user-specified path', async ({ browser, server, mode }, testI
|
||||
page.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.');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user