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;
|
apiZone.reported = true;
|
||||||
if (csi && apiName)
|
if (csi && apiName)
|
||||||
csi.onApiCallBegin(apiName, params, frames, wallTime, callCookie);
|
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 _closedError: Error | undefined;
|
||||||
private _isRemote = false;
|
private _isRemote = false;
|
||||||
private _localUtils?: LocalUtils;
|
private _localUtils?: LocalUtils;
|
||||||
|
private _rawBuffers = false;
|
||||||
// Some connections allow resolving in-process dispatchers.
|
// Some connections allow resolving in-process dispatchers.
|
||||||
toImpl: ((client: ChannelOwner) => any) | undefined;
|
toImpl: ((client: ChannelOwner) => any) | undefined;
|
||||||
private _tracingCount = 0;
|
private _tracingCount = 0;
|
||||||
|
|
@ -90,6 +91,14 @@ export class Connection extends EventEmitter {
|
||||||
return this._isRemote;
|
return this._isRemote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useRawBuffers() {
|
||||||
|
this._rawBuffers = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
rawBuffers() {
|
||||||
|
return this._rawBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
localUtils(): LocalUtils {
|
localUtils(): LocalUtils {
|
||||||
return this._localUtils!;
|
return this._localUtils!;
|
||||||
}
|
}
|
||||||
|
|
@ -149,7 +158,7 @@ export class Connection extends EventEmitter {
|
||||||
callback.reject(parsedError);
|
callback.reject(parsedError);
|
||||||
} else {
|
} else {
|
||||||
const validator = findValidator(callback.type, callback.method, 'Result');
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -179,7 +188,7 @@ export class Connection extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
const validator = findValidator(object._type, method, 'Event');
|
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) {
|
close(cause?: Error) {
|
||||||
|
|
@ -208,7 +217,7 @@ export class Connection extends EventEmitter {
|
||||||
throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);
|
throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);
|
||||||
let result: ChannelOwner<any>;
|
let result: ChannelOwner<any>;
|
||||||
const validator = findValidator(type, '', 'Initializer');
|
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) {
|
switch (type) {
|
||||||
case 'Android':
|
case 'Android':
|
||||||
result = new Android(parent, type, guid, initializer);
|
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 playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' });
|
||||||
|
|
||||||
const clientConnection = new Connection(undefined, undefined);
|
const clientConnection = new Connection(undefined, undefined);
|
||||||
|
clientConnection.useRawBuffers();
|
||||||
const dispatcherConnection = new DispatcherConnection(true /* local */);
|
const dispatcherConnection = new DispatcherConnection(true /* local */);
|
||||||
|
|
||||||
// Dispatch synchronously at first.
|
// Dispatch synchronously at first.
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ class PlaywrightClient {
|
||||||
this._driverProcess.stderr!.on('data', data => process.stderr.write(data));
|
this._driverProcess.stderr!.on('data', data => process.stderr.write(data));
|
||||||
|
|
||||||
const connection = new Connection(undefined, undefined);
|
const connection = new Connection(undefined, undefined);
|
||||||
connection.markAsRemote();
|
|
||||||
const transport = new PipeTransport(this._driverProcess.stdin!, this._driverProcess.stdout!);
|
const transport = new PipeTransport(this._driverProcess.stdin!, this._driverProcess.stdout!);
|
||||||
connection.onmessage = message => transport.send(JSON.stringify(message));
|
connection.onmessage = message => transport.send(JSON.stringify(message));
|
||||||
transport.onmessage = message => connection.dispatch(JSON.parse(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.waitForEvent('download'),
|
||||||
page.click('a')
|
page.click('a')
|
||||||
]);
|
]);
|
||||||
if (mode !== 'default') {
|
if (mode.startsWith('service')) {
|
||||||
const error = await download.path().catch(e => e);
|
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.');
|
expect(error.message).toContain('Path is not available when connecting remotely. Use saveAs() to save a local copy.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue