Skip to content

Commit 809803e

Browse files
committed
Bug 1998734 - [wdspec] Add a test for "emulation.setScreenOrientationOverride" command to set an override to a browsing context and then to a user context. r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D278002
1 parent 9e6c5ec commit 809803e

File tree

1 file changed

+79
-5
lines changed
  • testing/web-platform/tests/webdriver/tests/bidi/emulation/set_screen_orientation_override

1 file changed

+79
-5
lines changed

testing/web-platform/tests/webdriver/tests/bidi/emulation/set_screen_orientation_override/user_contexts.py

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,9 @@ async def test_set_to_multiple_user_contexts(bidi_session, create_user_context,
101101

102102

103103
async def test_set_to_user_context_and_then_to_context(bidi_session,
104-
create_user_context, new_tab, get_screen_orientation,
104+
create_user_context, get_screen_orientation,
105105
some_bidi_screen_orientation, some_web_screen_orientation,
106-
another_bidi_screen_orientation, another_web_screen_orientation,
107-
default_screen_orientation):
106+
another_bidi_screen_orientation, another_web_screen_orientation):
108107
user_context = await create_user_context()
109108
context_in_user_context_1 = await bidi_session.browsing_context.create(
110109
user_context=user_context, type_hint="tab"
@@ -144,6 +143,81 @@ async def test_set_to_user_context_and_then_to_context(bidi_session,
144143
screen_orientation=None,
145144
)
146145

147-
# Make sure that the screen orientation override was reset.
146+
# Make sure that the screen orientation is still set to user context override.
148147
assert await get_screen_orientation(
149-
context_in_user_context_1) == default_screen_orientation
148+
context_in_user_context_1) == some_web_screen_orientation
149+
150+
151+
async def test_set_to_context_and_then_to_user_context(
152+
bidi_session,
153+
create_user_context,
154+
get_screen_orientation,
155+
some_bidi_screen_orientation,
156+
some_web_screen_orientation,
157+
another_bidi_screen_orientation,
158+
another_web_screen_orientation,
159+
default_screen_orientation,
160+
):
161+
user_context = await create_user_context()
162+
context_in_user_context_1 = await bidi_session.browsing_context.create(
163+
user_context=user_context, type_hint="tab"
164+
)
165+
166+
# Apply screen orientation override to the context.
167+
await bidi_session.emulation.set_screen_orientation_override(
168+
contexts=[context_in_user_context_1["context"]],
169+
screen_orientation=another_bidi_screen_orientation,
170+
)
171+
172+
assert (
173+
await get_screen_orientation(context_in_user_context_1)
174+
== another_web_screen_orientation
175+
)
176+
177+
# Apply screen orientation override to the user context.
178+
await bidi_session.emulation.set_screen_orientation_override(
179+
user_contexts=[user_context], screen_orientation=some_bidi_screen_orientation
180+
)
181+
182+
# Make sure that context has still the context override.
183+
assert (
184+
await get_screen_orientation(context_in_user_context_1)
185+
== another_web_screen_orientation
186+
)
187+
188+
await bidi_session.browsing_context.reload(
189+
context=context_in_user_context_1["context"], wait="complete"
190+
)
191+
192+
# Make sure that after reload the screen orientation still has the context override.
193+
assert (
194+
await get_screen_orientation(context_in_user_context_1)
195+
== another_web_screen_orientation
196+
)
197+
198+
# Create a new context in the user context.
199+
context_in_user_context_2 = await bidi_session.browsing_context.create(
200+
user_context=user_context, type_hint="tab"
201+
)
202+
203+
# Make sure that the screen orientation override for the user context is applied.
204+
assert (
205+
await get_screen_orientation(context_in_user_context_2)
206+
== some_web_screen_orientation
207+
)
208+
209+
# Reset override for user context.
210+
await bidi_session.emulation.set_screen_orientation_override(
211+
user_contexts=[user_context], screen_orientation=None
212+
)
213+
214+
# Make sure that the screen orientation override for the first context is still set.
215+
assert (
216+
await get_screen_orientation(context_in_user_context_1)
217+
== another_web_screen_orientation
218+
)
219+
# Make sure that the screen orientation override for the second context is reset.
220+
assert (
221+
await get_screen_orientation(context_in_user_context_2)
222+
== default_screen_orientation
223+
)

0 commit comments

Comments
 (0)