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
fix(rpc): ensure better error messages when rpc misbehaves (#3838)
Dmitry Gozman46f9151795f3
diff --git a/src/client/connection.ts b/src/client/connection.tsindex c092b8d8ca..802f1f33f3 100644--- a/src/client/connection.ts+++ b/src/client/connection.ts@@ -133,7 +133,9 @@ export class Connection {}private _createRemoteObject(parentGuid: string, type: string, guid: string, initializer: any): any {- const parent = this._objects.get(parentGuid)!;+ const parent = this._objects.get(parentGuid);+ if (!parent)+ throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);let result: ChannelOwner<any, any>;initializer = this._replaceGuidsWithChannels(initializer);switch (type) {diff --git a/src/dispatchers/dispatcher.ts b/src/dispatchers/dispatcher.tsindex 7fbd537904..7ce5cd2b08 100644--- a/src/dispatchers/dispatcher.ts+++ b/src/dispatchers/dispatcher.ts@@ -18,7 +18,7 @@ import { EventEmitter } from 'events';import * as channels from '../protocol/channels';import { serializeError } from '../protocol/serializers';import { createScheme, Validator, ValidationError } from '../protocol/validator';-import { assert, createGuid, debugAssert } from '../utils/utils';+import { assert, createGuid, debugAssert, isUnderTest } from '../utils/utils';export const dispatcherSymbol = Symbol('dispatcher');@@ -75,6 +75,12 @@ export class Dispatcher<Type, Initializer> extends EventEmitter implements chann}_dispatchEvent(method: string, params: Dispatcher<any, any> | any = {}) {+ if (this._disposed) {+ if (isUnderTest())+ throw new Error(`${this._guid} is sending "${method}" event after being disposed`);+ // Just ignore this event outside of tests.+ return;+ }this._connection.sendMessageToClient(this._guid, method, params);}