Skip to content

Commit 5555e0c

Browse files
committed
merge branch trunk
2 parents 923a640 + 9564733 commit 5555e0c

File tree

5 files changed

+126
-12
lines changed

5 files changed

+126
-12
lines changed

multitool.lock.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,41 @@
44
"binaries": [
55
{
66
"kind": "archive",
7-
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.0/ruff-aarch64-unknown-linux-musl.tar.gz",
7+
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.2/ruff-aarch64-unknown-linux-musl.tar.gz",
88
"file": "ruff-aarch64-unknown-linux-musl/ruff",
9-
"sha256": "34a25398f03e7d32a4ec406c5c841c6e183fa0a96fbdd40b7e7eec1f177b360e",
9+
"sha256": "e323e9716661c9e18152aefe62e3fada497c10c9b3ef3095359c31b4df4f866a",
1010
"os": "linux",
1111
"cpu": "arm64"
1212
},
1313
{
1414
"kind": "archive",
15-
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.0/ruff-x86_64-unknown-linux-musl.tar.gz",
15+
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.2/ruff-x86_64-unknown-linux-musl.tar.gz",
1616
"file": "ruff-x86_64-unknown-linux-musl/ruff",
17-
"sha256": "ed6d1b8407a1d228dc332fb19057e86e04a6cd3c2beacdb324ad6ff2a3f9071b",
17+
"sha256": "e5e177a829b370376abb6a1dc9edc8c59ac519ebe64b1366b65e2952fa524a8d",
1818
"os": "linux",
1919
"cpu": "x86_64"
2020
},
2121
{
2222
"kind": "archive",
23-
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.0/ruff-aarch64-apple-darwin.tar.gz",
23+
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.2/ruff-aarch64-apple-darwin.tar.gz",
2424
"file": "ruff-aarch64-apple-darwin/ruff",
25-
"sha256": "0b7c193d5c45eda02226720eb75239fabeca995d5a0eb3830fd2973caa3030ec",
25+
"sha256": "33225f67ce61188fce91b801ab50a4028f8b0d66abbf81810841dd7d42371e38",
2626
"os": "macos",
2727
"cpu": "arm64"
2828
},
2929
{
3030
"kind": "archive",
31-
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.0/ruff-x86_64-apple-darwin.tar.gz",
31+
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.2/ruff-x86_64-apple-darwin.tar.gz",
3232
"file": "ruff-x86_64-apple-darwin/ruff",
33-
"sha256": "880ae046b435eb306cd557a7481eed6da463b85f283ba1f2c1e2ad7c139ed6c5",
33+
"sha256": "f119057618599e8983bdeed64e949af54f67d7a62464d11de0ba1237619a9990",
3434
"os": "macos",
3535
"cpu": "x86_64"
3636
},
3737
{
3838
"kind": "archive",
39-
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.0/ruff-x86_64-pc-windows-msvc.zip",
39+
"url": "https://github.com/astral-sh/ruff/releases/download/0.14.2/ruff-x86_64-pc-windows-msvc.zip",
4040
"file": "ruff-x86_64-pc-windows-msvc/ruff.exe",
41-
"sha256": "f81f957c862f310ac0be70ae7cef2e99afb4cc09648e40c039432e11465c2c1c",
41+
"sha256": "0a1160f45263cc847acd4b42392bf0484c9420806eeb7f776e1384fb557aeade",
4242
"os": "windows",
4343
"cpu": "x86_64"
4444
}

py/selenium/webdriver/common/bidi/emulation.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,41 @@ def set_geolocation_override(
216216

217217
self.conn.execute(command_builder("emulation.setGeolocationOverride", params))
218218

219+
def set_timezone_override(
220+
self,
221+
timezone: Optional[str] = None,
222+
contexts: Optional[list[str]] = None,
223+
user_contexts: Optional[list[str]] = None,
224+
) -> None:
225+
"""Set timezone override for the given contexts or user contexts.
226+
227+
Parameters:
228+
-----------
229+
timezone: Timezone identifier (IANA timezone name or offset string like '+01:00'),
230+
or None to clear the override.
231+
contexts: List of browsing context IDs to apply the override to.
232+
user_contexts: List of user context IDs to apply the override to.
233+
234+
Raises:
235+
------
236+
ValueError: If both contexts and user_contexts are provided, or if neither
237+
contexts nor user_contexts are provided.
238+
"""
239+
if contexts is not None and user_contexts is not None:
240+
raise ValueError("Cannot specify both contexts and user_contexts")
241+
242+
if contexts is None and user_contexts is None:
243+
raise ValueError("Must specify either contexts or user_contexts")
244+
245+
params: dict[str, Any] = {"timezone": timezone}
246+
247+
if contexts is not None:
248+
params["contexts"] = contexts
249+
elif user_contexts is not None:
250+
params["userContexts"] = user_contexts
251+
252+
self.conn.execute(command_builder("emulation.setTimezoneOverride", params))
253+
219254
def set_locale_override(
220255
self,
221256
locale: Optional[str] = None,

py/test/selenium/webdriver/common/bidi_emulation_tests.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@
2121
from selenium.webdriver.common.window import WindowTypes
2222

2323

24+
def get_browser_timezone_string(driver):
25+
result = driver.script._evaluate(
26+
"Intl.DateTimeFormat().resolvedOptions().timeZone",
27+
{"context": driver.current_window_handle},
28+
await_promise=False,
29+
)
30+
return result.result["value"]
31+
32+
33+
def get_browser_timezone_offset(driver):
34+
result = driver.script._evaluate(
35+
"new Date().getTimezoneOffset()", {"context": driver.current_window_handle}, await_promise=False
36+
)
37+
return result.result["value"]
38+
39+
2440
def get_browser_geolocation(driver, user_context=None):
2541
origin = driver.execute_script("return window.location.origin;")
2642
driver.permissions.set_permission("geolocation", PermissionState.GRANTED, origin, user_context=user_context)
@@ -225,6 +241,69 @@ def test_set_geolocation_override_with_error(driver, pages):
225241
assert "error" in result, f"Expected geolocation error, got: {result}"
226242

227243

244+
def test_set_timezone_override_with_context(driver, pages):
245+
"""Test setting timezone override with a browsing context."""
246+
context_id = driver.current_window_handle
247+
pages.load("blank.html")
248+
249+
initial_timezone_string = get_browser_timezone_string(driver)
250+
251+
# Set timezone to Tokyo (UTC+9)
252+
driver.emulation.set_timezone_override(timezone="Asia/Tokyo", contexts=[context_id])
253+
254+
timezone_offset = get_browser_timezone_offset(driver)
255+
timezone_string = get_browser_timezone_string(driver)
256+
257+
# Tokyo is UTC+9, so the offset should be -540 minutes (negative because it's ahead of UTC)
258+
assert timezone_offset == -540, f"Expected timezone offset -540, got: {timezone_offset}"
259+
assert timezone_string == "Asia/Tokyo", f"Expected timezone 'Asia/Tokyo', got: {timezone_string}"
260+
261+
# Clear the timezone override
262+
driver.emulation.set_timezone_override(timezone=None, contexts=[context_id])
263+
264+
# verify setting timezone to None clears the timezone override
265+
timezone_after_clear_with_none = get_browser_timezone_string(driver)
266+
assert timezone_after_clear_with_none == initial_timezone_string
267+
268+
269+
def test_set_timezone_override_with_user_context(driver, pages):
270+
"""Test setting timezone override with a user context."""
271+
user_context = driver.browser.create_user_context()
272+
context_id = driver.browsing_context.create(type=WindowTypes.TAB, user_context=user_context)
273+
274+
driver.switch_to.window(context_id)
275+
pages.load("blank.html")
276+
277+
driver.emulation.set_timezone_override(timezone="America/New_York", user_contexts=[user_context])
278+
279+
timezone_string = get_browser_timezone_string(driver)
280+
assert timezone_string == "America/New_York", f"Expected timezone 'America/New_York', got: {timezone_string}"
281+
282+
driver.emulation.set_timezone_override(timezone=None, user_contexts=[user_context])
283+
284+
driver.browsing_context.close(context_id)
285+
driver.browser.remove_user_context(user_context)
286+
287+
288+
@pytest.mark.xfail_firefox(reason="Firefox returns UTC as timezone string in case of offset.")
289+
def test_set_timezone_override_using_offset(driver, pages):
290+
"""Test setting timezone override using offset."""
291+
context_id = driver.current_window_handle
292+
pages.load("blank.html")
293+
294+
# set timezone to India (UTC+05:30) using offset
295+
driver.emulation.set_timezone_override(timezone="+05:30", contexts=[context_id])
296+
297+
timezone_offset = get_browser_timezone_offset(driver)
298+
timezone_string = get_browser_timezone_string(driver)
299+
300+
# India is UTC+05:30, so the offset should be -330 minutes (negative because it's ahead of UTC)
301+
assert timezone_offset == -330, f"Expected timezone offset -540, got: {timezone_offset}"
302+
assert timezone_string == "+05:30", f"Expected timezone '+05:30', got: {timezone_string}"
303+
304+
driver.emulation.set_timezone_override(timezone=None, contexts=[context_id])
305+
306+
228307
@pytest.mark.parametrize(
229308
"locale,expected_locale",
230309
[

py/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ commands =
4343
[testenv:linting]
4444
skip_install = true
4545
deps =
46-
ruff==0.14.0
46+
ruff==0.14.2
4747
commands =
4848
ruff check --fix --show-fixes --exit-non-zero-on-fix .
4949
ruff format --exit-non-zero-on-format .

rust/tests/browser_download_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn browser_latest_download_test(#[case] browser: String) {
5454
#[case("firefox", "121.0.1")]
5555
#[case("firefox", "beta")]
5656
#[case("firefox", "esr")]
57-
#[case("edge", "137.0.3296.93")]
57+
#[case("edge", "stable")]
5858
#[case("edge", "beta")]
5959
fn browser_version_download_test(#[case] browser: String, #[case] browser_version: String) {
6060
if OS.eq("windows") && browser.eq("edge") {

0 commit comments

Comments
 (0)