Skip to content

Commit

Permalink
Implement input command scaffold (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf-2 authored May 26, 2023
1 parent 760986c commit 298611c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
17 changes: 15 additions & 2 deletions src/bidiMapper/CommandProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import {
BrowsingContext,
CDP,
Input,
Message,
Script,
Session,
Expand Down Expand Up @@ -59,6 +60,8 @@ export interface BidiParser {
params: object
): BrowsingContext.CaptureScreenshotParameters;
parsePrintParams(params: object): BrowsingContext.PrintParameters;
parsePerformActionsParams(params: object): Input.PerformActionsParameters;
parseReleaseActionsParams(params: object): Input.ReleaseActionsParameters;
}

class BidiNoOpParser implements BidiParser {
Expand Down Expand Up @@ -118,6 +121,12 @@ class BidiNoOpParser implements BidiParser {
parsePrintParams(params: object): BrowsingContext.PrintParameters {
return params as BrowsingContext.PrintParameters;
}
parsePerformActionsParams(params: object): Input.PerformActionsParameters {
return params as Input.PerformActionsParameters;
}
parseReleaseActionsParams(params: object): Input.ReleaseActionsParameters {
return params as Input.ReleaseActionsParameters;
}
}

export class CommandProcessor extends EventEmitter<CommandProcessorEvents> {
Expand Down Expand Up @@ -249,9 +258,13 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEvents> {
);

case 'input.performActions':
throw new Message.UnsupportedOperationException('Not yet supported');
return this.#contextProcessor.process_input_performActions(
this.#parser.parsePerformActionsParams(commandData.params)
);
case 'input.releaseActions':
throw new Message.UnsupportedOperationException('Not yet supported');
return this.#contextProcessor.process_input_releaseActions(
this.#parser.parseReleaseActionsParams(commandData.params)
);

case 'cdp.sendCommand':
return this.#contextProcessor.process_cdp_sendCommand(
Expand Down
24 changes: 18 additions & 6 deletions src/bidiMapper/domains/context/browsingContextProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ import Protocol from 'devtools-protocol';
import {
BrowsingContext,
CDP,
Input,
Message,
Script,
} from '../../../protocol/protocol.js';
import {LogType, LoggerFn} from '../../../utils/log.js';
import {CdpClient, CdpConnection} from '../../CdpConnection.js';
import {LoggerFn, LogType} from '../../../utils/log.js';
import {IEventManager} from '../events/EventManager.js';
import {Realm} from '../script/realm.js';
import {RealmStorage} from '../script/realmStorage.js';

import {BrowsingContextStorage} from './browsingContextStorage.js';
import {BrowsingContextImpl} from './browsingContextImpl.js';
import {CdpTarget} from './cdpTarget.js';
import {
PreloadScriptStorage,
CdpPreloadScript,
BidiPreloadScript,
CdpPreloadScript,
PreloadScriptStorage,
} from './PreloadScriptStorage.js';
import {BrowsingContextImpl} from './browsingContextImpl.js';
import {BrowsingContextStorage} from './browsingContextStorage.js';
import {CdpTarget} from './cdpTarget.js';

export class BrowsingContextProcessor {
readonly #browsingContextStorage: BrowsingContextStorage;
Expand Down Expand Up @@ -426,6 +427,17 @@ export class BrowsingContextProcessor {
return {result: {}};
}

process_input_performActions(
_params: Input.PerformActionsParameters
): Promise<Message.EmptyResult> {
throw new Message.UnsupportedOperationException('Not implemented yet.');
}
process_input_releaseActions(
_params: Input.ReleaseActionsParameters
): Promise<Message.EmptyResult> {
throw new Message.UnsupportedOperationException('Not implemented yet.');
}

async process_browsingContext_close(
commandParams: BrowsingContext.CloseParameters
): Promise<Message.EmptyResult> {
Expand Down
8 changes: 8 additions & 0 deletions src/bidiTab/bidiTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import * as Parser from '../protocol-parser/protocol-parser.js';
import {
BrowsingContext,
CDP,
Input,
Message,
Script,
Session,
Expand Down Expand Up @@ -324,6 +325,13 @@ class BidiParserImpl implements BidiParser {
parsePrintParams(params: object): BrowsingContext.PrintParameters {
return Parser.BrowsingContext.parsePrintParams(params);
}

parsePerformActionsParams(params: object): Input.PerformActionsParameters {
return Parser.Input.parsePerformActionsParams(params);
}
parseReleaseActionsParams(params: object): Input.ReleaseActionsParameters {
return Parser.Input.parseReleaseActionsParams(params);
}
}

// Needed to filter out info related to BiDi target.
Expand Down

0 comments on commit 298611c

Please sign in to comment.