Skip to content

Commit f39f058

Browse files
feat(roll): roll Playwright to 1.12.0-next-1621812078000 (microsoft#715)
Co-authored-by: Max Schmitt <max@schmitt.mx>
1 parent f2d100c commit f39f058

File tree

9 files changed

+83
-6
lines changed

9 files changed

+83
-6
lines changed

playwright/_impl/_browser.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@
2828
from playwright._impl._browser_context import BrowserContext
2929
from playwright._impl._cdp_session import CDPSession
3030
from playwright._impl._connection import ChannelOwner, from_channel
31-
from playwright._impl._helper import ColorScheme, is_safe_close_error, locals_to_params
31+
from playwright._impl._helper import (
32+
ColorScheme,
33+
ReducedMotion,
34+
is_safe_close_error,
35+
locals_to_params,
36+
)
3237
from playwright._impl._network import serialize_headers
3338
from playwright._impl._page import Page
3439

@@ -90,6 +95,7 @@ async def new_context(
9095
isMobile: bool = None,
9196
hasTouch: bool = None,
9297
colorScheme: ColorScheme = None,
98+
reducedMotion: ReducedMotion = None,
9399
acceptDownloads: bool = None,
94100
defaultBrowserType: str = None,
95101
proxy: ProxySettings = None,
@@ -129,6 +135,7 @@ async def new_page(
129135
isMobile: bool = None,
130136
hasTouch: bool = None,
131137
colorScheme: ColorScheme = None,
138+
reducedMotion: ReducedMotion = None,
132139
acceptDownloads: bool = None,
133140
defaultBrowserType: str = None,
134141
proxy: ProxySettings = None,

playwright/_impl/_browser_type.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
BrowserChannel,
3737
ColorScheme,
3838
Env,
39+
ReducedMotion,
3940
locals_to_params,
4041
not_installed_error,
4142
)
@@ -124,6 +125,7 @@ async def launch_persistent_context(
124125
isMobile: bool = None,
125126
hasTouch: bool = None,
126127
colorScheme: ColorScheme = None,
128+
reducedMotion: ReducedMotion = None,
127129
acceptDownloads: bool = None,
128130
traceDir: Union[pathlib.Path, str] = None,
129131
chromiumSandbox: bool = None,

playwright/_impl/_helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
RouteHandler = Union[Callable[["Route"], Any], Callable[["Route", "Request"], Any]]
5151

5252
ColorScheme = Literal["dark", "light", "no-preference"]
53+
ReducedMotion = Literal["no-preference", "reduce"]
5354
DocumentLoadState = Literal["domcontentloaded", "load", "networkidle"]
5455
KeyboardModifier = Literal["Alt", "Control", "Meta", "Shift"]
5556
MouseButton = Literal["left", "middle", "right"]

playwright/_impl/_page.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
DocumentLoadState,
4747
KeyboardModifier,
4848
MouseButton,
49+
ReducedMotion,
4950
RouteHandler,
5051
RouteHandlerEntry,
5152
TimeoutSettings,
@@ -477,6 +478,7 @@ async def emulate_media(
477478
self,
478479
media: Literal["print", "screen"] = None,
479480
colorScheme: ColorScheme = None,
481+
reducedMotion: ReducedMotion = None,
480482
) -> None:
481483
await self._channel.send("emulateMedia", locals_to_params(locals()))
482484

playwright/async_api/_generated.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6258,7 +6258,8 @@ async def emulate_media(
62586258
self,
62596259
*,
62606260
media: Literal["print", "screen"] = None,
6261-
color_scheme: Literal["dark", "light", "no-preference"] = None
6261+
color_scheme: Literal["dark", "light", "no-preference"] = None,
6262+
reduced_motion: Literal["no-preference", "reduce"] = None
62626263
) -> NoneType:
62636264
"""Page.emulate_media
62646265
@@ -6302,12 +6303,17 @@ async def emulate_media(
63026303
color_scheme : Union["dark", "light", "no-preference", NoneType]
63036304
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing
63046305
`null` disables color scheme emulation.
6306+
reduced_motion : Union["no-preference", "reduce", NoneType]
6307+
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. Passing `null`
6308+
disables reduced motion emulation.
63056309
"""
63066310

63076311
return mapping.from_maybe_impl(
63086312
await self._async(
63096313
"page.emulate_media",
6310-
self._impl_obj.emulate_media(media=media, colorScheme=color_scheme),
6314+
self._impl_obj.emulate_media(
6315+
media=media, colorScheme=color_scheme, reducedMotion=reduced_motion
6316+
),
63116317
)
63126318
)
63136319

@@ -8892,6 +8898,7 @@ async def new_context(
88928898
is_mobile: bool = None,
88938899
has_touch: bool = None,
88948900
color_scheme: Literal["dark", "light", "no-preference"] = None,
8901+
reduced_motion: Literal["no-preference", "reduce"] = None,
88958902
accept_downloads: bool = None,
88968903
default_browser_type: str = None,
88978904
proxy: ProxySettings = None,
@@ -8958,6 +8965,9 @@ async def new_context(
89588965
color_scheme : Union["dark", "light", "no-preference", NoneType]
89598966
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
89608967
`page.emulate_media()` for more details. Defaults to `'light'`.
8968+
reduced_motion : Union["no-preference", "reduce", NoneType]
8969+
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. See
8970+
`page.emulate_media()` for more details. Defaults to `'no-preference'`.
89618971
accept_downloads : Union[bool, NoneType]
89628972
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
89638973
proxy : Union[{server: str, bypass: Union[str, NoneType], username: Union[str, NoneType], password: Union[str, NoneType]}, NoneType]
@@ -9011,6 +9021,7 @@ async def new_context(
90119021
isMobile=is_mobile,
90129022
hasTouch=has_touch,
90139023
colorScheme=color_scheme,
9024+
reducedMotion=reduced_motion,
90149025
acceptDownloads=accept_downloads,
90159026
defaultBrowserType=default_browser_type,
90169027
proxy=proxy,
@@ -9044,6 +9055,7 @@ async def new_page(
90449055
is_mobile: bool = None,
90459056
has_touch: bool = None,
90469057
color_scheme: Literal["dark", "light", "no-preference"] = None,
9058+
reduced_motion: Literal["no-preference", "reduce"] = None,
90479059
accept_downloads: bool = None,
90489060
default_browser_type: str = None,
90499061
proxy: ProxySettings = None,
@@ -9105,6 +9117,9 @@ async def new_page(
91059117
color_scheme : Union["dark", "light", "no-preference", NoneType]
91069118
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
91079119
`page.emulate_media()` for more details. Defaults to `'light'`.
9120+
reduced_motion : Union["no-preference", "reduce", NoneType]
9121+
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. See
9122+
`page.emulate_media()` for more details. Defaults to `'no-preference'`.
91089123
accept_downloads : Union[bool, NoneType]
91099124
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
91109125
proxy : Union[{server: str, bypass: Union[str, NoneType], username: Union[str, NoneType], password: Union[str, NoneType]}, NoneType]
@@ -9158,6 +9173,7 @@ async def new_page(
91589173
isMobile=is_mobile,
91599174
hasTouch=has_touch,
91609175
colorScheme=color_scheme,
9176+
reducedMotion=reduced_motion,
91619177
acceptDownloads=accept_downloads,
91629178
defaultBrowserType=default_browser_type,
91639179
proxy=proxy,
@@ -9481,6 +9497,7 @@ async def launch_persistent_context(
94819497
is_mobile: bool = None,
94829498
has_touch: bool = None,
94839499
color_scheme: Literal["dark", "light", "no-preference"] = None,
9500+
reduced_motion: Literal["no-preference", "reduce"] = None,
94849501
accept_downloads: bool = None,
94859502
trace_dir: typing.Union[str, pathlib.Path] = None,
94869503
chromium_sandbox: bool = None,
@@ -9584,6 +9601,9 @@ async def launch_persistent_context(
95849601
color_scheme : Union["dark", "light", "no-preference", NoneType]
95859602
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
95869603
`page.emulate_media()` for more details. Defaults to `'light'`.
9604+
reduced_motion : Union["no-preference", "reduce", NoneType]
9605+
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. See
9606+
`page.emulate_media()` for more details. Defaults to `'no-preference'`.
95879607
accept_downloads : Union[bool, NoneType]
95889608
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
95899609
trace_dir : Union[pathlib.Path, str, NoneType]
@@ -9646,6 +9666,7 @@ async def launch_persistent_context(
96469666
isMobile=is_mobile,
96479667
hasTouch=has_touch,
96489668
colorScheme=color_scheme,
9669+
reducedMotion=reduced_motion,
96499670
acceptDownloads=accept_downloads,
96509671
traceDir=trace_dir,
96519672
chromiumSandbox=chromium_sandbox,

playwright/sync_api/_generated.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6220,7 +6220,8 @@ def emulate_media(
62206220
self,
62216221
*,
62226222
media: Literal["print", "screen"] = None,
6223-
color_scheme: Literal["dark", "light", "no-preference"] = None
6223+
color_scheme: Literal["dark", "light", "no-preference"] = None,
6224+
reduced_motion: Literal["no-preference", "reduce"] = None
62246225
) -> NoneType:
62256226
"""Page.emulate_media
62266227
@@ -6263,12 +6264,17 @@ def emulate_media(
62636264
color_scheme : Union["dark", "light", "no-preference", NoneType]
62646265
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing
62656266
`null` disables color scheme emulation.
6267+
reduced_motion : Union["no-preference", "reduce", NoneType]
6268+
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. Passing `null`
6269+
disables reduced motion emulation.
62666270
"""
62676271

62686272
return mapping.from_maybe_impl(
62696273
self._sync(
62706274
"page.emulate_media",
6271-
self._impl_obj.emulate_media(media=media, colorScheme=color_scheme),
6275+
self._impl_obj.emulate_media(
6276+
media=media, colorScheme=color_scheme, reducedMotion=reduced_motion
6277+
),
62726278
)
62736279
)
62746280

@@ -8838,6 +8844,7 @@ def new_context(
88388844
is_mobile: bool = None,
88398845
has_touch: bool = None,
88408846
color_scheme: Literal["dark", "light", "no-preference"] = None,
8847+
reduced_motion: Literal["no-preference", "reduce"] = None,
88418848
accept_downloads: bool = None,
88428849
default_browser_type: str = None,
88438850
proxy: ProxySettings = None,
@@ -8904,6 +8911,9 @@ def new_context(
89048911
color_scheme : Union["dark", "light", "no-preference", NoneType]
89058912
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
89068913
`page.emulate_media()` for more details. Defaults to `'light'`.
8914+
reduced_motion : Union["no-preference", "reduce", NoneType]
8915+
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. See
8916+
`page.emulate_media()` for more details. Defaults to `'no-preference'`.
89078917
accept_downloads : Union[bool, NoneType]
89088918
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
89098919
proxy : Union[{server: str, bypass: Union[str, NoneType], username: Union[str, NoneType], password: Union[str, NoneType]}, NoneType]
@@ -8957,6 +8967,7 @@ def new_context(
89578967
isMobile=is_mobile,
89588968
hasTouch=has_touch,
89598969
colorScheme=color_scheme,
8970+
reducedMotion=reduced_motion,
89608971
acceptDownloads=accept_downloads,
89618972
defaultBrowserType=default_browser_type,
89628973
proxy=proxy,
@@ -8990,6 +9001,7 @@ def new_page(
89909001
is_mobile: bool = None,
89919002
has_touch: bool = None,
89929003
color_scheme: Literal["dark", "light", "no-preference"] = None,
9004+
reduced_motion: Literal["no-preference", "reduce"] = None,
89939005
accept_downloads: bool = None,
89949006
default_browser_type: str = None,
89959007
proxy: ProxySettings = None,
@@ -9051,6 +9063,9 @@ def new_page(
90519063
color_scheme : Union["dark", "light", "no-preference", NoneType]
90529064
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
90539065
`page.emulate_media()` for more details. Defaults to `'light'`.
9066+
reduced_motion : Union["no-preference", "reduce", NoneType]
9067+
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. See
9068+
`page.emulate_media()` for more details. Defaults to `'no-preference'`.
90549069
accept_downloads : Union[bool, NoneType]
90559070
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
90569071
proxy : Union[{server: str, bypass: Union[str, NoneType], username: Union[str, NoneType], password: Union[str, NoneType]}, NoneType]
@@ -9104,6 +9119,7 @@ def new_page(
91049119
isMobile=is_mobile,
91059120
hasTouch=has_touch,
91069121
colorScheme=color_scheme,
9122+
reducedMotion=reduced_motion,
91079123
acceptDownloads=accept_downloads,
91089124
defaultBrowserType=default_browser_type,
91099125
proxy=proxy,
@@ -9427,6 +9443,7 @@ def launch_persistent_context(
94279443
is_mobile: bool = None,
94289444
has_touch: bool = None,
94299445
color_scheme: Literal["dark", "light", "no-preference"] = None,
9446+
reduced_motion: Literal["no-preference", "reduce"] = None,
94309447
accept_downloads: bool = None,
94319448
trace_dir: typing.Union[str, pathlib.Path] = None,
94329449
chromium_sandbox: bool = None,
@@ -9530,6 +9547,9 @@ def launch_persistent_context(
95309547
color_scheme : Union["dark", "light", "no-preference", NoneType]
95319548
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. See
95329549
`page.emulate_media()` for more details. Defaults to `'light'`.
9550+
reduced_motion : Union["no-preference", "reduce", NoneType]
9551+
Emulates `'prefers-reduced-motion'` media feature, supported values are `'reduce'`, `'no-preference'`. See
9552+
`page.emulate_media()` for more details. Defaults to `'no-preference'`.
95339553
accept_downloads : Union[bool, NoneType]
95349554
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
95359555
trace_dir : Union[pathlib.Path, str, NoneType]
@@ -9592,6 +9612,7 @@ def launch_persistent_context(
95929612
isMobile=is_mobile,
95939613
hasTouch=has_touch,
95949614
colorScheme=color_scheme,
9615+
reducedMotion=reduced_motion,
95959616
acceptDownloads=accept_downloads,
95969617
traceDir=trace_dir,
95979618
chromiumSandbox=chromium_sandbox,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
InWheel = None
2929
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand
3030

31-
driver_version = "1.12.0-next-1621639045000"
31+
driver_version = "1.12.0-next-1621812078000"
3232

3333

3434
def extractall(zip: zipfile.ZipFile, path: str) -> None:

tests/async/test_defaultbrowsercontext.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,8 @@ async def test_should_fire_close_event_for_a_persistent_context(launch_persisten
376376
context.on("close", lambda: fired_event.set_result(True))
377377
await context.close()
378378
await fired_event
379+
380+
381+
async def test_should_support_reduced_motion(launch_persistent):
382+
(page, context) = await launch_persistent(reduced_motion="reduce")
383+
assert await page.evaluate("matchMedia('(prefers-reduced-motion: reduce)').matches")

tests/async/test_page.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,3 +1219,21 @@ async def test_frame_press_should_work(page, server):
12191219
frame = page.frame("inner")
12201220
await frame.press("textarea", "a")
12211221
assert await frame.evaluate("document.querySelector('textarea').value") == "a"
1222+
1223+
1224+
async def test_should_emulate_reduced_motion(page, server):
1225+
assert await page.evaluate(
1226+
"matchMedia('(prefers-reduced-motion: no-preference)').matches"
1227+
)
1228+
await page.emulate_media(reduced_motion="reduce")
1229+
assert await page.evaluate("matchMedia('(prefers-reduced-motion: reduce)').matches")
1230+
assert not await page.evaluate(
1231+
"matchMedia('(prefers-reduced-motion: no-preference)').matches"
1232+
)
1233+
await page.emulate_media(reduced_motion="no-preference")
1234+
assert not await page.evaluate(
1235+
"matchMedia('(prefers-reduced-motion: reduce)').matches"
1236+
)
1237+
assert await page.evaluate(
1238+
"matchMedia('(prefers-reduced-motion: no-preference)').matches"
1239+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy