Skip to content

Commit c76a772

Browse files
committed
Bug 1978027 - [wdspec] Add tests for timezone override in sandboxes. r=webdriver-reviewers,jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D261392
1 parent 4171631 commit c76a772

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[contexts.py]
2+
[test_timezone_override_applies_to_existing_sandbox]
3+
bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1983807
4+
expected: FAIL

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
@pytest_asyncio.fixture
1212
async def get_current_timezone(bidi_session):
13-
async def get_current_timezone(context):
13+
async def get_current_timezone(context, sandbox=None):
1414
result = await bidi_session.script.evaluate(
1515
expression="Intl.DateTimeFormat().resolvedOptions().timeZone",
16-
target=ContextTarget(context["context"]),
16+
target=ContextTarget(context["context"], sandbox=sandbox),
1717
await_promise=False,
1818
)
1919
return result["value"]

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from webdriver.bidi.modules.script import ContextTarget
23

34
pytestmark = pytest.mark.asyncio
45

@@ -92,3 +93,34 @@ async def test_iframe(
9293

9394
# Assert timezone is emulated in the iframe context.
9495
assert await get_current_timezone(iframe) == another_timezone
96+
97+
98+
async def test_timezone_override_applies_to_new_sandbox(
99+
bidi_session, new_tab, some_timezone, get_current_timezone
100+
):
101+
await bidi_session.emulation.set_timezone_override(
102+
contexts=[new_tab["context"]], timezone=some_timezone
103+
)
104+
105+
# Make sure the override got applied to the newly created sandbox.
106+
assert await get_current_timezone(new_tab, "test") == some_timezone
107+
108+
109+
async def test_timezone_override_applies_to_existing_sandbox(
110+
bidi_session,
111+
new_tab,
112+
default_timezone,
113+
another_timezone,
114+
get_current_timezone
115+
):
116+
sandbox_name = "test"
117+
118+
# Create a sandbox.
119+
assert await get_current_timezone(new_tab, sandbox_name) == default_timezone
120+
121+
await bidi_session.emulation.set_timezone_override(
122+
contexts=[new_tab["context"]], timezone=another_timezone
123+
)
124+
125+
# Make sure the override got applied to the existing sandbox.
126+
assert await get_current_timezone(new_tab, sandbox_name) == another_timezone

0 commit comments

Comments
 (0)