Skip to content

Commit 60673b0

Browse files
committed
Bug 1978027 - [wdspec] Update "test_timezone_offset" to assert timezone offset instead of timezone id. r=webdriver-reviewers,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D259031
1 parent 3c9d216 commit 60673b0

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

testing/web-platform/tests/webdriver/tests/bidi/emulation/set_timezone_override/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,16 @@ def another_timezone(default_timezone, some_timezone):
5555

5656
raise Exception(
5757
f"Unexpectedly could not find timezone different from the default {default_timezone}")
58+
59+
60+
@pytest_asyncio.fixture
61+
async def get_timezone_offset(bidi_session):
62+
async def get_timezone_offset(timestamp, context):
63+
result = await bidi_session.script.evaluate(
64+
expression=f"(new Date({timestamp})).getTimezoneOffset()",
65+
target=ContextTarget(context["context"]),
66+
await_promise=False,
67+
)
68+
return result["value"]
69+
70+
return get_timezone_offset

testing/web-platform/tests/webdriver/tests/bidi/emulation/set_timezone_override/timezone.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ async def test_timezone_set_override_and_reset(bidi_session, top_context,
3333
assert await get_current_timezone(top_context) == default_timezone
3434

3535

36-
@pytest.mark.parametrize("timezone_offset", ["+10:00"])
37-
async def test_timezone_offset(bidi_session, top_context, get_current_timezone,
38-
default_timezone, timezone_offset):
39-
assert await get_current_timezone(top_context) == default_timezone
40-
36+
@pytest.mark.parametrize("timezone_offset", ["+10", "-10"])
37+
async def test_timezone_offset(
38+
bidi_session, new_tab, get_timezone_offset, timezone_offset
39+
):
4140
# Set timezone override.
4241
await bidi_session.emulation.set_timezone_override(
43-
contexts=[top_context["context"]],
44-
timezone=timezone_offset
42+
contexts=[new_tab["context"]], timezone=f"{timezone_offset}:00"
4543
)
4644

47-
assert await get_current_timezone(top_context) == timezone_offset
45+
assert await get_timezone_offset(1753453789196, new_tab) == int(
46+
timezone_offset
47+
) * (-60)

0 commit comments

Comments
 (0)