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

This commit is contained in:
Dmitry Gozman 2020-07-21 14:41:33 -07:00 committed by GitHub
parent 3dd61629e0
commit 18cb1c017a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 8 deletions

View file

@ -118,9 +118,7 @@ export interface SelectorsChannel extends Channel {
export type SelectorsRegisterParams = { export type SelectorsRegisterParams = {
name: string, name: string,
source: string, source: string,
options: { contentScript?: boolean,
contentScript?: boolean,
},
}; };
export type SelectorsRegisterResult = void; export type SelectorsRegisterResult = void;
export type SelectorsCreateSelectorParams = { export type SelectorsCreateSelectorParams = {

View file

@ -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> { async register(name: string, script: string | Function | { path?: string, content?: string }, options: { contentScript?: boolean } = {}): Promise<void> {
const source = await helper.evaluationScript(script, undefined, false); 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> { async _createSelector(name: string, handle: ElementHandle<Element>): Promise<string | undefined> {

View file

@ -108,8 +108,7 @@ interface Selectors
parameters parameters
name: string name: string
source: string source: string
options: object contentScript?: boolean
contentScript?: boolean
command createSelector command createSelector
parameters parameters

View file

@ -25,8 +25,8 @@ export class SelectorsDispatcher extends Dispatcher<Selectors, SelectorsInitiali
super(scope, selectors, 'selectors', {}); super(scope, selectors, 'selectors', {});
} }
async register(params: { name: string, source: string, options: { contentScript?: boolean } }): Promise<void> { async register(params: { name: string, source: string, contentScript?: boolean }): Promise<void> {
await this._object.register(params.name, params.source, params.options); await this._object.register(params.name, params.source, params);
} }
async createSelector(params: { name: string, handle: ElementHandleDispatcher }): Promise<{ value?: string }> { async createSelector(params: { name: string, handle: ElementHandleDispatcher }): Promise<{ value?: string }> {