From 610c0dc0f90f6eeaaba848f048426c63ac6d3581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjalonthomas=E2=80=9D?= Date: Tue, 14 Oct 2025 14:24:53 -0400 Subject: [PATCH 1/6] Add embedded_origin to testdriver --- resources/testdriver.js | 4 +++- tools/wptrunner/wptrunner/executors/asyncactions.py | 4 +++- tools/wptrunner/wptrunner/executors/protocol.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/testdriver.js b/resources/testdriver.js index e25c8989da2580..ced2a15a87c2db 100644 --- a/resources/testdriver.js +++ b/resources/testdriver.js @@ -973,9 +973,11 @@ * @param {PermissionState} params.state - a `PermissionState * `_ * value. - * @param {string} [params.origin] - an optional `origin` string to set the + * @param {string} [params.origin] - an optional top-level `origin` string to set the * permission for. If omitted, the permission is set for the * current window's origin. + * @param {string} [params.embeddedOrigin] - an optional embedded `origin` string to set the + * permission for. If omitted, the top-level origin is used as the embedded origin. * @returns {Promise} fulfilled after the permission is set, or rejected if setting * the permission fails. */ diff --git a/tools/wptrunner/wptrunner/executors/asyncactions.py b/tools/wptrunner/wptrunner/executors/asyncactions.py index 783656984c3966..bd27b62f61d0ea 100644 --- a/tools/wptrunner/wptrunner/executors/asyncactions.py +++ b/tools/wptrunner/wptrunner/executors/asyncactions.py @@ -292,9 +292,11 @@ async def __call__(self, payload): descriptor = payload['descriptor'] state = payload['state'] origin = payload['origin'] + embedded_origin = payload.get('embeddedOrigin') return await self.protocol.bidi_permissions.set_permission(descriptor, state, - origin) + origin, + embedded_origin) async_actions = [ diff --git a/tools/wptrunner/wptrunner/executors/protocol.py b/tools/wptrunner/wptrunner/executors/protocol.py index bcdcfcc21e737c..2d6cf47df05b23 100644 --- a/tools/wptrunner/wptrunner/executors/protocol.py +++ b/tools/wptrunner/wptrunner/executors/protocol.py @@ -598,7 +598,7 @@ class BidiPermissionsProtocolPart(ProtocolPart): name = "bidi_permissions" @abstractmethod - async def set_permission(self, descriptor, state, origin): + async def set_permission(self, descriptor, state, origin, embedded_origin=None): pass From 9a7f35e2b5a2b0bef41de08886ce66ad43e3aeea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjalonthomas=E2=80=9D?= Date: Tue, 14 Oct 2025 15:29:06 -0400 Subject: [PATCH 2/6] Add param to WebDriverBidiPermissionsProtocolPart --- tools/wptrunner/wptrunner/executors/executorwebdriver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/tools/wptrunner/wptrunner/executors/executorwebdriver.py index b004f007300e6d..2bec0644fa0ad5 100644 --- a/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -398,9 +398,9 @@ def __init__(self, parent): def setup(self): self.webdriver = self.parent.webdriver - async def set_permission(self, descriptor, state, origin): + async def set_permission(self, descriptor, state, origin, embedding_origin=None): return await self.webdriver.bidi_session.permissions.set_permission( - descriptor=descriptor, state=state, origin=origin) + descriptor=descriptor, state=state, origin=origin, embedding_origin=embedding_origin) class WebDriverBidiWebExtensionsProtocolPart(WebExtensionsProtocolPart): def __init__(self, parent): From 343edfbb66815858b6453c43654633850ac3505f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjalonthomas=E2=80=9D?= Date: Wed, 15 Oct 2025 13:09:05 -0400 Subject: [PATCH 3/6] Finish updating to embeddedOrigin --- resources/testdriver.js | 3 ++- .../wptrunner/executors/executorwebdriver.py | 13 ++++++++++--- tools/wptrunner/wptrunner/executors/protocol.py | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/resources/testdriver.js b/resources/testdriver.js index ced2a15a87c2db..e7df7ede41eb97 100644 --- a/resources/testdriver.js +++ b/resources/testdriver.js @@ -977,7 +977,8 @@ * permission for. If omitted, the permission is set for the * current window's origin. * @param {string} [params.embeddedOrigin] - an optional embedded `origin` string to set the - * permission for. If omitted, the top-level origin is used as the embedded origin. + * permission for. If omitted, the top-level `origin` is used as the + * embedded origin. * @returns {Promise} fulfilled after the permission is set, or rejected if setting * the permission fails. */ diff --git a/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/tools/wptrunner/wptrunner/executors/executorwebdriver.py index 2bec0644fa0ad5..527f189f5d0904 100644 --- a/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -398,9 +398,16 @@ def __init__(self, parent): def setup(self): self.webdriver = self.parent.webdriver - async def set_permission(self, descriptor, state, origin, embedding_origin=None): - return await self.webdriver.bidi_session.permissions.set_permission( - descriptor=descriptor, state=state, origin=origin, embedding_origin=embedding_origin) + async def set_permission(self, descriptor, state, origin, embedded_origin:Optional[str] = None): + params = { + "descriptor": descriptor, + "state": state, + "origin": origin + } + if embedded_origin is not None: + params["embeddedOrigin"] = embedded_origin + + return await self.webdriver.bidi_session.permissions.set_permission(**params) class WebDriverBidiWebExtensionsProtocolPart(WebExtensionsProtocolPart): def __init__(self, parent): diff --git a/tools/wptrunner/wptrunner/executors/protocol.py b/tools/wptrunner/wptrunner/executors/protocol.py index 2d6cf47df05b23..2c10f9370fa5aa 100644 --- a/tools/wptrunner/wptrunner/executors/protocol.py +++ b/tools/wptrunner/wptrunner/executors/protocol.py @@ -598,7 +598,7 @@ class BidiPermissionsProtocolPart(ProtocolPart): name = "bidi_permissions" @abstractmethod - async def set_permission(self, descriptor, state, origin, embedded_origin=None): + async def set_permission(self, descriptor, state, origin, embedded_origin: Optional[str] = None): pass From 952f8442b982e691c2d94ee448c40f01d2456dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjalonthomas=E2=80=9D?= Date: Wed, 15 Oct 2025 14:18:21 -0400 Subject: [PATCH 4/6] Add param types and return types --- .../wptrunner/executors/executorwebdriver.py | 14 ++++++++------ tools/wptrunner/wptrunner/executors/protocol.py | 8 +++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/tools/wptrunner/wptrunner/executors/executorwebdriver.py index 527f189f5d0904..3acdc897fc6140 100644 --- a/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -398,12 +398,14 @@ def __init__(self, parent): def setup(self): self.webdriver = self.parent.webdriver - async def set_permission(self, descriptor, state, origin, embedded_origin:Optional[str] = None): - params = { - "descriptor": descriptor, - "state": state, - "origin": origin - } + async def set_permission( + self, + descriptor: Dict[str, Any], + state: str, + origin: str, + embedded_origin: Optional[str] = None, + ) -> None: + params = {"descriptor": descriptor, "state": state, "origin": origin} if embedded_origin is not None: params["embeddedOrigin"] = embedded_origin diff --git a/tools/wptrunner/wptrunner/executors/protocol.py b/tools/wptrunner/wptrunner/executors/protocol.py index 2c10f9370fa5aa..c937010759358e 100644 --- a/tools/wptrunner/wptrunner/executors/protocol.py +++ b/tools/wptrunner/wptrunner/executors/protocol.py @@ -598,7 +598,13 @@ class BidiPermissionsProtocolPart(ProtocolPart): name = "bidi_permissions" @abstractmethod - async def set_permission(self, descriptor, state, origin, embedded_origin: Optional[str] = None): + async def set_permission( + self, + descriptor: Dict[str, Any], + state: str, + origin: str, + embedded_origin: Optional[str] = None, + ) -> None: pass From 71970b742e252b0631c0e05167da32753e478f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjalonthomas=E2=80=9D?= Date: Wed, 15 Oct 2025 14:51:15 -0400 Subject: [PATCH 5/6] Return awaitable instead of None --- tools/wptrunner/wptrunner/executors/executorwebdriver.py | 3 ++- tools/wptrunner/wptrunner/executors/protocol.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/tools/wptrunner/wptrunner/executors/executorwebdriver.py index 3acdc897fc6140..9f6add4fb52949 100644 --- a/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -6,6 +6,7 @@ import socket import threading import traceback +from typing import Awaitable from urllib.parse import urljoin from .base import (AsyncCallbackHandler, @@ -404,7 +405,7 @@ async def set_permission( state: str, origin: str, embedded_origin: Optional[str] = None, - ) -> None: + ) -> Awaitable[Any]: params = {"descriptor": descriptor, "state": state, "origin": origin} if embedded_origin is not None: params["embeddedOrigin"] = embedded_origin diff --git a/tools/wptrunner/wptrunner/executors/protocol.py b/tools/wptrunner/wptrunner/executors/protocol.py index c937010759358e..0bf63d6fffc008 100644 --- a/tools/wptrunner/wptrunner/executors/protocol.py +++ b/tools/wptrunner/wptrunner/executors/protocol.py @@ -604,7 +604,7 @@ async def set_permission( state: str, origin: str, embedded_origin: Optional[str] = None, - ) -> None: + ) -> Awaitable[Any]: pass From cbbdbd1b0c5687958174a813a07a71ff9d8f19bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjalonthomas=E2=80=9D?= Date: Wed, 15 Oct 2025 15:17:33 -0400 Subject: [PATCH 6/6] Use Any return type --- tools/wptrunner/wptrunner/executors/executorwebdriver.py | 3 +-- tools/wptrunner/wptrunner/executors/protocol.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/tools/wptrunner/wptrunner/executors/executorwebdriver.py index 9f6add4fb52949..5738aa05434d44 100644 --- a/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -6,7 +6,6 @@ import socket import threading import traceback -from typing import Awaitable from urllib.parse import urljoin from .base import (AsyncCallbackHandler, @@ -405,7 +404,7 @@ async def set_permission( state: str, origin: str, embedded_origin: Optional[str] = None, - ) -> Awaitable[Any]: + ) -> Any: params = {"descriptor": descriptor, "state": state, "origin": origin} if embedded_origin is not None: params["embeddedOrigin"] = embedded_origin diff --git a/tools/wptrunner/wptrunner/executors/protocol.py b/tools/wptrunner/wptrunner/executors/protocol.py index 0bf63d6fffc008..d5f9b0bfc4bb89 100644 --- a/tools/wptrunner/wptrunner/executors/protocol.py +++ b/tools/wptrunner/wptrunner/executors/protocol.py @@ -604,7 +604,7 @@ async def set_permission( state: str, origin: str, embedded_origin: Optional[str] = None, - ) -> Awaitable[Any]: + ) -> Any: pass