Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(rpc): inline selectors.register options in the protocol (#3072)

Dmitry Gozman18cb1c017a4c
diff --git a/src/rpc/channels.ts b/src/rpc/channels.ts
index b9333abe58..9ee5fd81e9 100644
--- a/src/rpc/channels.ts
+++ b/src/rpc/channels.ts
@@ -118,9 +118,7 @@ export interface SelectorsChannel extends Channel {
export type SelectorsRegisterParams = {
name: string,
source: string,
- options: {
- contentScript?: boolean,
- },
+ contentScript?: boolean,
};
export type SelectorsRegisterResult = void;
export type SelectorsCreateSelectorParams = {
diff --git a/src/rpc/client/selectors.ts b/src/rpc/client/selectors.ts
index 87ede311e2..1fac829cbf 100644
--- a/src/rpc/client/selectors.ts
+++ b/src/rpc/client/selectors.ts
@@ -30,7 +30,7 @@ export class Selectors extends ChannelOwner<SelectorsChannel, SelectorsInitializ
async register(name: string, script: string | Function | { path?: string, content?: string }, options: { contentScript?: boolean } = {}): Promise<void> {
const source = await helper.evaluationScript(script, undefined, false);
- await this._channel.register({ name, source, options });
+ await this._channel.register({ ...options, name, source });
}
async _createSelector(name: string, handle: ElementHandle<Element>): Promise<string | undefined> {
diff --git a/src/rpc/protocol.pdl b/src/rpc/protocol.pdl
index be45a1b545..bc559cbf52 100644
--- a/src/rpc/protocol.pdl
+++ b/src/rpc/protocol.pdl
@@ -108,8 +108,7 @@ interface Selectors
parameters
name: string
source: string
- options: object
- contentScript?: boolean
+ contentScript?: boolean
command createSelector
parameters
diff --git a/src/rpc/server/selectorsDispatcher.ts b/src/rpc/server/selectorsDispatcher.ts
index 1cae7b1803..987cdedf98 100644
--- a/src/rpc/server/selectorsDispatcher.ts
+++ b/src/rpc/server/selectorsDispatcher.ts
@@ -25,8 +25,8 @@ export class SelectorsDispatcher extends Dispatcher<Selectors, SelectorsInitiali
super(scope, selectors, 'selectors', {});
}
- async register(params: { name: string, source: string, options: { contentScript?: boolean } }): Promise<void> {
- await this._object.register(params.name, params.source, params.options);
+ async register(params: { name: string, source: string, contentScript?: boolean }): Promise<void> {
+ await this._object.register(params.name, params.source, params);
}
async createSelector(params: { name: string, handle: ElementHandleDispatcher }): Promise<{ value?: string }> {