commit e9d2ff003b4b98d42f09ff2dd7fd09145da7f511
parent 8ba54d35c821fdc8df0be67ed97560664edb2c79
Author: Maksim Sadym <69349599+sadym-chromium@users.noreply.github.com>
Date: Wed, 15 Oct 2025 08:43:12 +0000
Bug 1993017 [wpt PR 55278] - [no-op][wdspec] apply nullable and maybe in `tools/webdriver/webdriver/bidi/modules/browser.py`, a=testonly
Automatic update from web-platform-tests
[wdspec] apply nullable and maybe in `tools/webdriver/webdriver/bidi/modules/browser.py` (#55278)
--
wpt-commits: 1145bf1e0c9bddb8e261e0c24bd67db13676777d
wpt-pr: 55278
Diffstat:
2 files changed, 20 insertions(+), 33 deletions(-)
diff --git a/testing/web-platform/tests/tools/webdriver/webdriver/bidi/modules/browser.py b/testing/web-platform/tests/tools/webdriver/webdriver/bidi/modules/browser.py
@@ -1,7 +1,7 @@
-from typing import Any, List, Mapping, MutableMapping, Optional, Union
+from typing import Any, List, Mapping
from ._module import BidiModule, command
-from ..undefined import UNDEFINED, Undefined
+from ..undefined import UNDEFINED, Maybe, Nullable
class Browser(BidiModule):
@@ -29,22 +29,15 @@ class Browser(BidiModule):
@command
def create_user_context(
- self, accept_insecure_certs: Optional[bool] = None,
- proxy: Optional[Mapping[str, Any]] = None,
- unhandled_prompt_behavior: Optional[Mapping[str, str]] = None,
+ self, accept_insecure_certs: Maybe[bool] = UNDEFINED,
+ proxy: Maybe[Mapping[str, Any]] = UNDEFINED,
+ unhandled_prompt_behavior: Maybe[Mapping[str, str]] = UNDEFINED,
) -> Mapping[str, Any]:
- params: MutableMapping[str, Any] = {}
-
- if accept_insecure_certs is not None:
- params["acceptInsecureCerts"] = accept_insecure_certs
-
- if proxy is not None:
- params["proxy"] = proxy
-
- if unhandled_prompt_behavior is not None:
- params["unhandledPromptBehavior"] = unhandled_prompt_behavior
-
- return params
+ return {
+ "acceptInsecureCerts": accept_insecure_certs,
+ "proxy": proxy,
+ "unhandledPromptBehavior": unhandled_prompt_behavior
+ }
@create_user_context.result
def _create_user_context(self, result: Mapping[str, Any]) -> Any:
@@ -68,26 +61,19 @@ class Browser(BidiModule):
@command
def remove_user_context(
- self, user_context: str
+ self, user_context: str
) -> Mapping[str, Any]:
- params: MutableMapping[str, Any] = {}
-
- if user_context is not None:
- params["userContext"] = user_context
-
- return params
+ return {
+ "userContext": user_context
+ }
@command
def set_download_behavior(
- self, download_behavior: Optional[Mapping[str, Any]] = None,
- user_contexts: Union[Undefined, List[str]] = UNDEFINED
+ self, download_behavior: Nullable[Mapping[str, Any]],
+ user_contexts: Maybe[List[str]] = UNDEFINED
) -> Mapping[str, Any]:
- params: MutableMapping[str, Any] = {
+ return {
"downloadBehavior": download_behavior,
+ "userContexts": user_contexts
}
-
- if user_contexts != UNDEFINED:
- params["userContexts"] = user_contexts
-
- return params
diff --git a/testing/web-platform/tests/webdriver/tests/bidi/browser/remove_user_context/invalid.py b/testing/web-platform/tests/webdriver/tests/bidi/browser/remove_user_context/invalid.py
@@ -1,10 +1,11 @@
import pytest
import webdriver.bidi.error as error
+from webdriver.bidi.undefined import UNDEFINED
pytestmark = pytest.mark.asyncio
-@pytest.mark.parametrize("value", [None, False, 42, {}, []])
+@pytest.mark.parametrize("value", [UNDEFINED, None, False, 42, {}, []])
async def test_params_user_context_invalid_type(bidi_session, value):
with pytest.raises(error.InvalidArgumentException):
await bidi_session.browser.remove_user_context(user_context=value)