From 0830f001231b795a56724407562d81b8e0a469ab Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:40:23 +0200 Subject: [PATCH] fix: provide invalid set cache props (#2590) Provides the type checks for the command Ref: #2385 --------- Co-authored-by: browser-automation-bot <133232582+browser-automation-bot@users.noreply.github.com> --- src/bidiMapper/BidiNoOpParser.ts | 3 ++ src/bidiMapper/BidiParser.ts | 1 + src/bidiMapper/CommandProcessor.ts | 4 +- .../modules/network/NetworkProcessor.ts | 10 ++++ src/bidiTab/BidiParser.ts | 3 ++ src/protocol-parser/protocol-parser.ts | 7 +++ .../navigation_failed.py.ini | 3 ++ .../network/set_cache_behavior/invalid.py.ini | 51 ------------------- .../network/set_cache_behavior/invalid.py.ini | 51 ------------------- .../network/set_cache_behavior/invalid.py.ini | 51 ------------------- 10 files changed, 29 insertions(+), 155 deletions(-) diff --git a/src/bidiMapper/BidiNoOpParser.ts b/src/bidiMapper/BidiNoOpParser.ts index 6bc3270494..c8d445dc4b 100644 --- a/src/bidiMapper/BidiNoOpParser.ts +++ b/src/bidiMapper/BidiNoOpParser.ts @@ -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 diff --git a/src/bidiMapper/BidiParser.ts b/src/bidiMapper/BidiParser.ts index bffd3bdbac..989de0ba2f 100644 --- a/src/bidiMapper/BidiParser.ts +++ b/src/bidiMapper/BidiParser.ts @@ -109,6 +109,7 @@ export interface BidiCommandParameterParser { parseRemoveInterceptParams( params: unknown ): Network.RemoveInterceptParameters; + parseSetCacheBehavior(params: unknown): Network.SetCacheBehaviorParameters; // keep-sorted end block=yes // Script domain diff --git a/src/bidiMapper/CommandProcessor.ts b/src/bidiMapper/CommandProcessor.ts index 0b49d3402e..3270a809ee 100644 --- a/src/bidiMapper/CommandProcessor.ts +++ b/src/bidiMapper/CommandProcessor.ts @@ -279,8 +279,8 @@ export class CommandProcessor extends EventEmitter { 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 diff --git a/src/bidiMapper/modules/network/NetworkProcessor.ts b/src/bidiMapper/modules/network/NetworkProcessor.ts index e517939b14..694e9af824 100644 --- a/src/bidiMapper/modules/network/NetworkProcessor.ts +++ b/src/bidiMapper/modules/network/NetworkProcessor.ts @@ -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'; @@ -188,6 +189,15 @@ export class NetworkProcessor { return {}; } + // eslint-disable-next-line @typescript-eslint/require-await + async setCacheBehavior( + _params: Network.SetCacheBehaviorParameters + ): Promise { + throw new UnknownErrorException( + "Method 'network.setCacheBehavior' is not implemented." + ); + } + #getRequestOrFail(id: Network.Request): NetworkRequest { const request = this.#networkStorage.getRequestById(id); if (!request) { diff --git a/src/bidiTab/BidiParser.ts b/src/bidiTab/BidiParser.ts index 3905664081..660e2f1435 100644 --- a/src/bidiTab/BidiParser.ts +++ b/src/bidiTab/BidiParser.ts @@ -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 diff --git a/src/protocol-parser/protocol-parser.ts b/src/protocol-parser/protocol-parser.ts index b9421025a7..e04f8f8f18 100644 --- a/src/protocol-parser/protocol-parser.ts +++ b/src/protocol-parser/protocol-parser.ts @@ -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 */ diff --git a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/browsing_context/navigation_failed/navigation_failed.py.ini b/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/browsing_context/navigation_failed/navigation_failed.py.ini index 8f1cfe37fc..5571718a39 100644 --- a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/browsing_context/navigation_failed/navigation_failed.py.ini +++ b/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/browsing_context/navigation_failed/navigation_failed.py.ini @@ -25,3 +25,6 @@ [test_close_iframe] expected: FAIL + + [test_with_new_navigation] + expected: [PASS, FAIL] diff --git a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini b/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini index 4ce6ec2901..42eb5aab20 100644 --- a/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini +++ b/wpt-metadata/chromedriver/headful/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini @@ -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 diff --git a/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini b/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini index 4ce6ec2901..42eb5aab20 100644 --- a/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini +++ b/wpt-metadata/chromedriver/headless/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini @@ -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 diff --git a/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini b/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini index 4ce6ec2901..42eb5aab20 100644 --- a/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini +++ b/wpt-metadata/mapper/headless/webdriver/tests/bidi/network/set_cache_behavior/invalid.py.ini @@ -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