Skip to content

Commit

Permalink
fix: parse browser.RemoveUserContextParameters (#1905)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: sadym-chromium <[email protected]>
  • Loading branch information
sadym-chromium and sadym-chromium authored Feb 27, 2024
1 parent 6d42b9c commit a50821b
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 47 deletions.
10 changes: 10 additions & 0 deletions src/bidiMapper/BidiNoOpParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import type {
Browser,
BrowsingContext,
Cdp,
Input,
Expand All @@ -29,6 +30,15 @@ import type {
import type {BidiCommandParameterParser} from './BidiParser.js';

export class BidiNoOpParser implements BidiCommandParameterParser {
// Browser domain
// keep-sorted start block=yes
parseRemoveUserContextParams(
params: unknown
): Browser.RemoveUserContextParameters {
return params as Browser.RemoveUserContextParameters;
}
// keep-sorted end

// Browsing Context domain
// keep-sorted start block=yes
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters {
Expand Down
8 changes: 8 additions & 0 deletions src/bidiMapper/BidiParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import type {
Browser,
BrowsingContext,
Cdp,
Input,
Expand All @@ -27,6 +28,13 @@ import type {
} from '../protocol/protocol.js';

export interface BidiCommandParameterParser {
// Browser domain
// keep-sorted start block=yes
parseRemoveUserContextParams(
params: unknown
): Browser.RemoveUserContextParameters;
// keep-sorted end

// Browsing Context domain
// keep-sorted start block=yes
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters;
Expand Down
2 changes: 1 addition & 1 deletion src/bidiMapper/CommandProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
return await this.#browserProcessor.getUserContexts();
case 'browser.removeUserContext':
return await this.#browserProcessor.removeUserContext(
command.params.userContext
this.#parser.parseRemoveUserContextParams(command.params)
);
// keep-sorted end

Expand Down
3 changes: 2 additions & 1 deletion src/bidiMapper/domains/browser/BrowserProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ export class BrowserProcessor {
}

async removeUserContext(
userContext: Browser.UserContext
params: Browser.RemoveUserContextParameters
): Promise<EmptyResult> {
const userContext = params.userContext;
if (userContext === 'default') {
throw new InvalidArgumentException(
'`default` user context cannot be removed'
Expand Down
10 changes: 10 additions & 0 deletions src/bidiTab/BidiParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
import type {BidiCommandParameterParser} from '../bidiMapper/BidiMapper.js';
import type {
Browser,
BrowsingContext,
Cdp,
Input,
Expand All @@ -28,6 +29,15 @@ import type {
import * as Parser from '../protocol-parser/protocol-parser.js';

export class BidiParser implements BidiCommandParameterParser {
// Browser domain
// keep-sorted start block=yes
parseRemoveUserContextParams(
params: unknown
): Browser.RemoveUserContextParameters {
return Parser.Browser.parseRemoveUserContextParams(params);
}
// keep-sorted end

// Browsing Context domain
// keep-sorted start block=yes
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters {
Expand Down
12 changes: 12 additions & 0 deletions src/protocol-parser/protocol-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ export function parseObject<T extends ZodType>(
throw new InvalidArgumentException(errorMessage);
}

/** @see https://w3c.github.io/webdriver-bidi/#module-browser */
export namespace Browser {
export function parseRemoveUserContextParams(
params: unknown
): Protocol.Browser.RemoveUserContextParameters {
return parseObject(
params,
WebDriverBidi.Browser.RemoveUserContextParametersSchema
);
}
}

/** @see https://w3c.github.io/webdriver-bidi/#module-network */
export namespace Network {
export function parseAddInterceptParameters(params: unknown) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit a50821b

Please sign in to comment.