Skip to content

Commit

Permalink
fix: provide invalid set cache props (#2590)
Browse files Browse the repository at this point in the history
Provides the type checks for the command

Ref: #2385

---------

Co-authored-by: browser-automation-bot <133232582+browser-automation-bot@users.noreply.github.com>
  • Loading branch information
1 parent 98ad2d9 commit 0830f00
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 155 deletions.
3 changes: 3 additions & 0 deletions src/bidiMapper/BidiNoOpParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ export class BidiNoOpParser implements BidiCommandParameterParser {
): Network.RemoveInterceptParameters {
return params as Network.RemoveInterceptParameters;
}
parseSetCacheBehavior(params: unknown): Network.SetCacheBehaviorParameters {
return params as Network.SetCacheBehaviorParameters;
}
// keep-sorted end

// Permissions domain
Expand Down
1 change: 1 addition & 0 deletions src/bidiMapper/BidiParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export interface BidiCommandParameterParser {
parseRemoveInterceptParams(
params: unknown
): Network.RemoveInterceptParameters;
parseSetCacheBehavior(params: unknown): Network.SetCacheBehaviorParameters;
// keep-sorted end block=yes

// Script domain
Expand Down
4 changes: 2 additions & 2 deletions src/bidiMapper/CommandProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
this.#parser.parseRemoveInterceptParams(command.params)
);
case 'network.setCacheBehavior':
throw new UnknownErrorException(
"Method 'network.setCacheBehavior' is not implemented."
return await this.#networkProcessor.setCacheBehavior(
this.#parser.parseSetCacheBehavior(command.params)
);
// keep-sorted end

Expand Down
10 changes: 10 additions & 0 deletions src/bidiMapper/modules/network/NetworkProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
type EmptyResult,
NoSuchRequestException,
InvalidArgumentException,
UnknownErrorException,
} from '../../../protocol/protocol.js';
import {URLPattern} from '../../../utils/UrlPattern.js';
import type {BrowsingContextStorage} from '../context/BrowsingContextStorage.js';
Expand Down Expand Up @@ -188,6 +189,15 @@ export class NetworkProcessor {
return {};
}

// eslint-disable-next-line @typescript-eslint/require-await
async setCacheBehavior(
_params: Network.SetCacheBehaviorParameters
): Promise<EmptyResult> {
throw new UnknownErrorException(
"Method 'network.setCacheBehavior' is not implemented."
);
}

#getRequestOrFail(id: Network.Request): NetworkRequest {
const request = this.#networkStorage.getRequestById(id);
if (!request) {
Expand Down
3 changes: 3 additions & 0 deletions src/bidiTab/BidiParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export class BidiParser implements BidiCommandParameterParser {
): Network.RemoveInterceptParameters {
return Parser.Network.parseRemoveInterceptParameters(params);
}
parseSetCacheBehavior(params: unknown): Network.SetCacheBehaviorParameters {
return Parser.Network.parseSetCacheBehavior(params);
}
// keep-sorted end

// Permissions domain
Expand Down
7 changes: 7 additions & 0 deletions src/protocol-parser/protocol-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ export namespace Network {
WebDriverBidi.Network.RemoveInterceptParametersSchema
);
}

export function parseSetCacheBehavior(params: unknown) {
return parseObject(
params,
WebDriverBidi.Network.SetCacheBehaviorParametersSchema
) as Protocol.Network.SetCacheBehaviorParameters;
}
}

/** @see https://w3c.github.io/webdriver-bidi/#module-script */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@

[test_close_iframe]
expected: FAIL

[test_with_new_navigation]
expected: [PASS, FAIL]
Original file line number Diff line number Diff line change
@@ -1,54 +1,3 @@
[invalid.py]
[test_params_cache_behavior_invalid_type[None\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[False\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[42\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[value3\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[value4\]]
expected: FAIL

[test_params_cache_behavior_invalid_value[bypas\]]
expected: FAIL

[test_params_cache_behavior_invalid_value[DEFAULT\]]
expected: FAIL

[test_params_contexts_invalid_type[foo\]]
expected: FAIL

[test_params_contexts_invalid_type[42\]]
expected: FAIL

[test_params_contexts_invalid_type[False\]]
expected: FAIL

[test_params_contexts_invalid_type[value3\]]
expected: FAIL

[test_params_contexts_invalid_value_empty_array]
expected: FAIL

[test_params_contexts_invalid_array_element_type[None\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[42\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[False\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[value3\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[value4\]]
expected: FAIL

[test_params_contexts_invalid_array_element_value]
expected: FAIL
Original file line number Diff line number Diff line change
@@ -1,54 +1,3 @@
[invalid.py]
[test_params_cache_behavior_invalid_type[None\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[False\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[42\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[value3\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[value4\]]
expected: FAIL

[test_params_cache_behavior_invalid_value[bypas\]]
expected: FAIL

[test_params_cache_behavior_invalid_value[DEFAULT\]]
expected: FAIL

[test_params_contexts_invalid_type[foo\]]
expected: FAIL

[test_params_contexts_invalid_type[42\]]
expected: FAIL

[test_params_contexts_invalid_type[False\]]
expected: FAIL

[test_params_contexts_invalid_type[value3\]]
expected: FAIL

[test_params_contexts_invalid_value_empty_array]
expected: FAIL

[test_params_contexts_invalid_array_element_type[None\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[42\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[False\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[value3\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[value4\]]
expected: FAIL

[test_params_contexts_invalid_array_element_value]
expected: FAIL
Original file line number Diff line number Diff line change
@@ -1,54 +1,3 @@
[invalid.py]
[test_params_cache_behavior_invalid_type[None\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[False\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[42\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[value3\]]
expected: FAIL

[test_params_cache_behavior_invalid_type[value4\]]
expected: FAIL

[test_params_cache_behavior_invalid_value[bypas\]]
expected: FAIL

[test_params_cache_behavior_invalid_value[DEFAULT\]]
expected: FAIL

[test_params_contexts_invalid_type[foo\]]
expected: FAIL

[test_params_contexts_invalid_type[42\]]
expected: FAIL

[test_params_contexts_invalid_type[False\]]
expected: FAIL

[test_params_contexts_invalid_type[value3\]]
expected: FAIL

[test_params_contexts_invalid_value_empty_array]
expected: FAIL

[test_params_contexts_invalid_array_element_type[None\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[42\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[False\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[value3\]]
expected: FAIL

[test_params_contexts_invalid_array_element_type[value4\]]
expected: FAIL

[test_params_contexts_invalid_array_element_value]
expected: FAIL

0 comments on commit 0830f00

Please sign in to comment.