Skip to content

Commit 417a5b0

Browse files
authored
chore: roll Playwright to 1.20 (#1206)
1 parent 9ad1147 commit 417a5b0

16 files changed

+128
-67
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
44

55
| | Linux | macOS | Windows |
66
| :--- | :---: | :---: | :---: |
7-
| Chromium <!-- GEN:chromium-version -->101.0.4915.0<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->101.0.4929.0<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->96.0.1<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->97.0.1<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

Diff for: playwright/_impl/_browser_type.py

+2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ async def connect(
182182
if timeout is None:
183183
timeout = 30000
184184

185+
headers = {**(headers if headers else {}), "x-playwright-browser": self.name}
186+
185187
transport = WebSocketTransport(
186188
self._connection._loop, ws_endpoint, headers, slow_mo
187189
)

Diff for: playwright/_impl/_element_handle.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ async def screenshot(
270270
path: Union[str, Path] = None,
271271
quality: int = None,
272272
omitBackground: bool = None,
273-
disableAnimations: bool = None,
273+
animations: Literal["disabled"] = None,
274274
mask: List["Locator"] = None,
275275
) -> bytes:
276276
params = locals_to_params(locals())

Diff for: playwright/_impl/_locator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ async def screenshot(
373373
path: Union[str, pathlib.Path] = None,
374374
quality: int = None,
375375
omitBackground: bool = None,
376-
disableAnimations: bool = None,
376+
animations: Literal["disabled"] = None,
377377
mask: List["Locator"] = None,
378378
) -> bytes:
379379
params = locals_to_params(locals())

Diff for: playwright/_impl/_page.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ async def screenshot(
604604
omitBackground: bool = None,
605605
fullPage: bool = None,
606606
clip: FloatRect = None,
607-
disableAnimations: bool = None,
607+
animations: Literal["disabled"] = None,
608608
mask: List["Locator"] = None,
609609
) -> bytes:
610610
params = locals_to_params(locals())

Diff for: playwright/async_api/_generated.py

+21-16
Original file line numberDiff line numberDiff line change
@@ -2537,7 +2537,7 @@ async def screenshot(
25372537
path: typing.Union[str, pathlib.Path] = None,
25382538
quality: int = None,
25392539
omit_background: bool = None,
2540-
disable_animations: bool = None,
2540+
animations: Literal["disabled"] = None,
25412541
mask: typing.List["Locator"] = None
25422542
) -> bytes:
25432543
"""ElementHandle.screenshot
@@ -2563,9 +2563,11 @@ async def screenshot(
25632563
omit_background : Union[bool, NoneType]
25642564
Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
25652565
Defaults to `false`.
2566-
disable_animations : Union[bool, NoneType]
2567-
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
2568-
their duration:
2566+
animations : Union["disabled", NoneType]
2567+
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
2568+
depending on their duration:
2569+
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
2570+
- infinite animations are canceled to initial state, and then played over after the screenshot.
25692571
mask : Union[List[Locator], NoneType]
25702572
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
25712573
`#FF00FF` that completely covers its bounding box.
@@ -2584,7 +2586,7 @@ async def screenshot(
25842586
path=path,
25852587
quality=quality,
25862588
omitBackground=omit_background,
2587-
disableAnimations=disable_animations,
2589+
animations=animations,
25882590
mask=mapping.to_impl(mask),
25892591
),
25902592
)
@@ -8054,7 +8056,7 @@ async def screenshot(
80548056
omit_background: bool = None,
80558057
full_page: bool = None,
80568058
clip: FloatRect = None,
8057-
disable_animations: bool = None,
8059+
animations: Literal["disabled"] = None,
80588060
mask: typing.List["Locator"] = None
80598061
) -> bytes:
80608062
"""Page.screenshot
@@ -8082,9 +8084,11 @@ async def screenshot(
80828084
`false`.
80838085
clip : Union[{x: float, y: float, width: float, height: float}, NoneType]
80848086
An object which specifies clipping of the resulting image. Should have the following fields:
8085-
disable_animations : Union[bool, NoneType]
8086-
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
8087-
their duration:
8087+
animations : Union["disabled", NoneType]
8088+
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
8089+
depending on their duration:
8090+
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
8091+
- infinite animations are canceled to initial state, and then played over after the screenshot.
80888092
mask : Union[List[Locator], NoneType]
80898093
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
80908094
`#FF00FF` that completely covers its bounding box.
@@ -8105,7 +8109,7 @@ async def screenshot(
81058109
omitBackground=omit_background,
81068110
fullPage=full_page,
81078111
clip=clip,
8108-
disableAnimations=disable_animations,
8112+
animations=animations,
81098113
mask=mapping.to_impl(mask),
81108114
),
81118115
)
@@ -10431,7 +10435,6 @@ async def grant_permissions(
1043110435
- `'midi'`
1043210436
- `'midi-sysex'` (system-exclusive midi)
1043310437
- `'notifications'`
10434-
- `'push'`
1043510438
- `'camera'`
1043610439
- `'microphone'`
1043710440
- `'background-sync'`
@@ -13342,7 +13345,7 @@ async def screenshot(
1334213345
path: typing.Union[str, pathlib.Path] = None,
1334313346
quality: int = None,
1334413347
omit_background: bool = None,
13345-
disable_animations: bool = None,
13348+
animations: Literal["disabled"] = None,
1334613349
mask: typing.List["Locator"] = None
1334713350
) -> bytes:
1334813351
"""Locator.screenshot
@@ -13368,9 +13371,11 @@ async def screenshot(
1336813371
omit_background : Union[bool, NoneType]
1336913372
Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
1337013373
Defaults to `false`.
13371-
disable_animations : Union[bool, NoneType]
13372-
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
13373-
their duration:
13374+
animations : Union["disabled", NoneType]
13375+
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
13376+
depending on their duration:
13377+
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
13378+
- infinite animations are canceled to initial state, and then played over after the screenshot.
1337413379
mask : Union[List[Locator], NoneType]
1337513380
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
1337613381
`#FF00FF` that completely covers its bounding box.
@@ -13389,7 +13394,7 @@ async def screenshot(
1338913394
path=path,
1339013395
quality=quality,
1339113396
omitBackground=omit_background,
13392-
disableAnimations=disable_animations,
13397+
animations=animations,
1339313398
mask=mapping.to_impl(mask),
1339413399
),
1339513400
)

Diff for: playwright/sync_api/_generated.py

+21-16
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ def screenshot(
24862486
path: typing.Union[str, pathlib.Path] = None,
24872487
quality: int = None,
24882488
omit_background: bool = None,
2489-
disable_animations: bool = None,
2489+
animations: Literal["disabled"] = None,
24902490
mask: typing.List["Locator"] = None
24912491
) -> bytes:
24922492
"""ElementHandle.screenshot
@@ -2512,9 +2512,11 @@ def screenshot(
25122512
omit_background : Union[bool, NoneType]
25132513
Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
25142514
Defaults to `false`.
2515-
disable_animations : Union[bool, NoneType]
2516-
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
2517-
their duration:
2515+
animations : Union["disabled", NoneType]
2516+
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
2517+
depending on their duration:
2518+
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
2519+
- infinite animations are canceled to initial state, and then played over after the screenshot.
25182520
mask : Union[List[Locator], NoneType]
25192521
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
25202522
`#FF00FF` that completely covers its bounding box.
@@ -2533,7 +2535,7 @@ def screenshot(
25332535
path=path,
25342536
quality=quality,
25352537
omitBackground=omit_background,
2536-
disableAnimations=disable_animations,
2538+
animations=animations,
25372539
mask=mapping.to_impl(mask),
25382540
),
25392541
)
@@ -7865,7 +7867,7 @@ def screenshot(
78657867
omit_background: bool = None,
78667868
full_page: bool = None,
78677869
clip: FloatRect = None,
7868-
disable_animations: bool = None,
7870+
animations: Literal["disabled"] = None,
78697871
mask: typing.List["Locator"] = None
78707872
) -> bytes:
78717873
"""Page.screenshot
@@ -7893,9 +7895,11 @@ def screenshot(
78937895
`false`.
78947896
clip : Union[{x: float, y: float, width: float, height: float}, NoneType]
78957897
An object which specifies clipping of the resulting image. Should have the following fields:
7896-
disable_animations : Union[bool, NoneType]
7897-
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
7898-
their duration:
7898+
animations : Union["disabled", NoneType]
7899+
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
7900+
depending on their duration:
7901+
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
7902+
- infinite animations are canceled to initial state, and then played over after the screenshot.
78997903
mask : Union[List[Locator], NoneType]
79007904
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
79017905
`#FF00FF` that completely covers its bounding box.
@@ -7916,7 +7920,7 @@ def screenshot(
79167920
omitBackground=omit_background,
79177921
fullPage=full_page,
79187922
clip=clip,
7919-
disableAnimations=disable_animations,
7923+
animations=animations,
79207924
mask=mapping.to_impl(mask),
79217925
),
79227926
)
@@ -10187,7 +10191,6 @@ def grant_permissions(
1018710191
- `'midi'`
1018810192
- `'midi-sysex'` (system-exclusive midi)
1018910193
- `'notifications'`
10190-
- `'push'`
1019110194
- `'camera'`
1019210195
- `'microphone'`
1019310196
- `'background-sync'`
@@ -13062,7 +13065,7 @@ def screenshot(
1306213065
path: typing.Union[str, pathlib.Path] = None,
1306313066
quality: int = None,
1306413067
omit_background: bool = None,
13065-
disable_animations: bool = None,
13068+
animations: Literal["disabled"] = None,
1306613069
mask: typing.List["Locator"] = None
1306713070
) -> bytes:
1306813071
"""Locator.screenshot
@@ -13088,9 +13091,11 @@ def screenshot(
1308813091
omit_background : Union[bool, NoneType]
1308913092
Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
1309013093
Defaults to `false`.
13091-
disable_animations : Union[bool, NoneType]
13092-
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
13093-
their duration:
13094+
animations : Union["disabled", NoneType]
13095+
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
13096+
depending on their duration:
13097+
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
13098+
- infinite animations are canceled to initial state, and then played over after the screenshot.
1309413099
mask : Union[List[Locator], NoneType]
1309513100
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
1309613101
`#FF00FF` that completely covers its bounding box.
@@ -13109,7 +13114,7 @@ def screenshot(
1310913114
path=path,
1311013115
quality=quality,
1311113116
omitBackground=omit_background,
13112-
disableAnimations=disable_animations,
13117+
animations=animations,
1311313118
mask=mapping.to_impl(mask),
1311413119
),
1311513120
)

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
InWheel = None
3131
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand
3232

33-
driver_version = "1.20.0-alpha-1646324243000"
33+
driver_version = "1.20.0"
3434

3535

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

Diff for: tests/async/test_browsercontext_add_cookies.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ async def test_should_default_to_setting_secure_cookie_for_https_websites(
302302

303303

304304
async def test_should_be_able_to_set_unsecure_cookie_for_http_website(
305-
context, page, server, is_firefox
305+
context, page, server
306306
):
307307
await page.goto(server.EMPTY_PAGE)
308308
HTTP_URL = "http://example.com"
@@ -354,7 +354,9 @@ async def test_should_set_cookies_for_a_frame(context, page, server):
354354
assert await page.frames[1].evaluate("document.cookie") == "frame-cookie=value"
355355

356356

357-
async def test_should_not_block_third_party_cookies(context, page, server):
357+
async def test_should_not_block_third_party_cookies(
358+
context, page, server, is_chromium, is_firefox
359+
):
358360
await page.goto(server.EMPTY_PAGE)
359361
await page.evaluate(
360362
"""src => {
@@ -370,5 +372,21 @@ async def test_should_not_block_third_party_cookies(context, page, server):
370372
)
371373
await page.frames[1].evaluate("document.cookie = 'username=John Doe'")
372374
await page.wait_for_timeout(2000)
375+
allows_third_party = is_firefox
373376
cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + "/grid.html")
374-
assert cookies == []
377+
378+
if allows_third_party:
379+
assert cookies == [
380+
{
381+
"domain": "127.0.0.1",
382+
"expires": -1,
383+
"httpOnly": False,
384+
"name": "username",
385+
"path": "/",
386+
"sameSite": "Lax" if is_chromium else "None",
387+
"secure": False,
388+
"value": "John Doe",
389+
}
390+
]
391+
else:
392+
assert cookies == []

Diff for: tests/async/test_browsercontext_cookies.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async def test_should_return_no_cookies_in_pristine_browser_context(context):
2121
assert await context.cookies() == []
2222

2323

24-
async def test_should_get_a_cookie(context, page, server, is_chromium, is_firefox):
24+
async def test_should_get_a_cookie(context, page, server, is_chromium):
2525
await page.goto(server.EMPTY_PAGE)
2626
document_cookie = await page.evaluate(
2727
"""() => {
@@ -39,14 +39,12 @@ async def test_should_get_a_cookie(context, page, server, is_chromium, is_firefo
3939
"expires": -1,
4040
"httpOnly": False,
4141
"secure": False,
42-
"sameSite": "Lax" if (is_chromium or is_firefox) else "None",
42+
"sameSite": "Lax" if is_chromium else "None",
4343
}
4444
]
4545

4646

47-
async def test_should_get_a_non_session_cookie(
48-
context, page, server, is_chromium, is_firefox
49-
):
47+
async def test_should_get_a_non_session_cookie(context, page, server, is_chromium):
5048
await page.goto(server.EMPTY_PAGE)
5149
# @see https://en.wikipedia.org/wiki/Year_2038_problem
5250
date = int(datetime.datetime(2038, 1, 1).timestamp() * 1000)
@@ -68,7 +66,7 @@ async def test_should_get_a_non_session_cookie(
6866
"expires": date / 1000,
6967
"httpOnly": False,
7068
"secure": False,
71-
"sameSite": "Lax" if (is_chromium or is_firefox) else "None",
69+
"sameSite": "Lax" if is_chromium else "None",
7270
}
7371
]
7472

@@ -126,9 +124,7 @@ async def test_should_properly_report_lax_sameSite_cookie(
126124
assert cookies[0]["sameSite"] == "Lax"
127125

128126

129-
async def test_should_get_multiple_cookies(
130-
context, page, server, is_chromium, is_firefox
131-
):
127+
async def test_should_get_multiple_cookies(context, page, server, is_chromium):
132128
await page.goto(server.EMPTY_PAGE)
133129
document_cookie = await page.evaluate(
134130
"""() => {
@@ -149,7 +145,7 @@ async def test_should_get_multiple_cookies(
149145
"expires": -1,
150146
"httpOnly": False,
151147
"secure": False,
152-
"sameSite": "Lax" if (is_chromium or is_firefox) else "None",
148+
"sameSite": "Lax" if is_chromium else "None",
153149
},
154150
{
155151
"name": "username",
@@ -159,7 +155,7 @@ async def test_should_get_multiple_cookies(
159155
"expires": -1,
160156
"httpOnly": False,
161157
"secure": False,
162-
"sameSite": "Lax" if (is_chromium or is_firefox) else "None",
158+
"sameSite": "Lax" if is_chromium else "None",
163159
},
164160
]
165161

0 commit comments

Comments
 (0)