Skip to content

Commit eb28cc7

Browse files
authored
chore(roll): roll Playwright to v1.47.0 (microsoft#2546)
1 parent 876a414 commit eb28cc7

13 files changed

+306
-139
lines changed

README.md

Lines changed: 2 additions & 2 deletions
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 -->128.0.6613.18<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->129.0.6668.29<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->18.0<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->128.0<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->130.0<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

playwright/_impl/_api_structures.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ class StorageState(TypedDict, total=False):
104104
class ClientCertificate(TypedDict, total=False):
105105
origin: str
106106
certPath: Optional[Union[str, Path]]
107+
cert: Optional[bytes]
107108
keyPath: Optional[Union[str, Path]]
109+
key: Optional[bytes]
108110
pfxPath: Optional[Union[str, Path]]
111+
pfx: Optional[bytes]
109112
passphrase: Optional[str]
110113

111114

playwright/_impl/_element_handle.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ async def select_option(
157157
params = locals_to_params(
158158
dict(
159159
timeout=timeout,
160-
noWaitAfter=noWaitAfter,
161160
force=force,
162161
**convert_select_option_values(value, index, label, element)
163162
)

playwright/_impl/_fetch.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import typing
1919
from pathlib import Path
2020
from typing import Any, Dict, List, Optional, Union, cast
21+
from urllib.parse import parse_qs
2122

2223
import playwright._impl._network as network
2324
from playwright._impl._api_structures import (
@@ -53,7 +54,7 @@
5354
FormType = Dict[str, Union[bool, float, str]]
5455
DataType = Union[Any, bytes, str]
5556
MultipartType = Dict[str, Union[bytes, bool, float, str, FilePayload]]
56-
ParamsType = Dict[str, Union[bool, float, str]]
57+
ParamsType = Union[Dict[str, Union[bool, float, str]], str]
5758

5859

5960
class APIRequest:
@@ -404,7 +405,7 @@ async def _inner_fetch(
404405
"fetch",
405406
{
406407
"url": url,
407-
"params": object_to_array(params),
408+
"params": params_to_protocol(params),
408409
"method": method,
409410
"headers": serialized_headers,
410411
"postData": post_data,
@@ -429,6 +430,23 @@ async def storage_state(
429430
return result
430431

431432

433+
def params_to_protocol(params: Optional[ParamsType]) -> Optional[List[NameValue]]:
434+
if not params:
435+
return None
436+
if isinstance(params, dict):
437+
return object_to_array(params)
438+
if params.startswith("?"):
439+
params = params[1:]
440+
parsed = parse_qs(params)
441+
if not parsed:
442+
return None
443+
out = []
444+
for name, values in parsed.items():
445+
for value in values:
446+
out.append(NameValue(name=name, value=value))
447+
return out
448+
449+
432450
def file_payload_to_json(payload: FilePayload) -> ServerFilePayload:
433451
return ServerFilePayload(
434452
name=payload["name"],

playwright/_impl/_frame.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,6 @@ async def select_option(
670670
dict(
671671
selector=selector,
672672
timeout=timeout,
673-
noWaitAfter=noWaitAfter,
674673
strict=strict,
675674
force=force,
676675
**convert_select_option_values(value, index, label, element),

playwright/_impl/_network.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,20 @@ async def to_client_certificates_protocol(
9696
}
9797
if passphrase := clientCertificate.get("passphrase"):
9898
out_record["passphrase"] = passphrase
99+
if pfx := clientCertificate.get("pfx"):
100+
out_record["pfx"] = base64.b64encode(pfx).decode()
99101
if pfx_path := clientCertificate.get("pfxPath"):
100102
out_record["pfx"] = base64.b64encode(
101103
await async_readfile(pfx_path)
102104
).decode()
105+
if cert := clientCertificate.get("cert"):
106+
out_record["cert"] = base64.b64encode(cert).decode()
103107
if cert_path := clientCertificate.get("certPath"):
104108
out_record["cert"] = base64.b64encode(
105109
await async_readfile(cert_path)
106110
).decode()
111+
if key := clientCertificate.get("key"):
112+
out_record["key"] = base64.b64encode(key).decode()
107113
if key_path := clientCertificate.get("keyPath"):
108114
out_record["key"] = base64.b64encode(
109115
await async_readfile(key_path)

playwright/async_api/_generated.py

Lines changed: 58 additions & 64 deletions
Large diffs are not rendered by default.

playwright/sync_api/_generated.py

Lines changed: 58 additions & 64 deletions
Large diffs are not rendered by default.

setup.py

Lines changed: 1 addition & 1 deletion
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.46.0"
33+
driver_version = "1.47.0-beta-1725889926000"
3434

3535

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

tests/async/test_browsercontext_client_certificates.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,47 @@ async def test_should_work_with_new_context(browser: Browser, assetdir: Path) ->
172172
await context.close()
173173

174174

175+
async def test_should_work_with_new_context_passing_as_content(
176+
browser: Browser, assetdir: Path
177+
) -> None:
178+
context = await browser.new_context(
179+
# TODO: Remove this once we can pass a custom CA.
180+
ignore_https_errors=True,
181+
client_certificates=[
182+
{
183+
"origin": "https://127.0.0.1:8000",
184+
"cert": (
185+
assetdir / "client-certificates/client/trusted/cert.pem"
186+
).read_bytes(),
187+
"key": (
188+
assetdir / "client-certificates/client/trusted/key.pem"
189+
).read_bytes(),
190+
}
191+
],
192+
)
193+
page = await context.new_page()
194+
await page.goto("https://localhost:8000")
195+
await expect(page.get_by_test_id("message")).to_have_text(
196+
"Sorry, but you need to provide a client certificate to continue."
197+
)
198+
await page.goto("https://127.0.0.1:8000")
199+
await expect(page.get_by_test_id("message")).to_have_text(
200+
"Hello Alice, your certificate was issued by localhost!"
201+
)
202+
203+
response = await page.context.request.get("https://localhost:8000")
204+
assert (
205+
"Sorry, but you need to provide a client certificate to continue."
206+
in await response.text()
207+
)
208+
response = await page.context.request.get("https://127.0.0.1:8000")
209+
assert (
210+
"Hello Alice, your certificate was issued by localhost!"
211+
in await response.text()
212+
)
213+
await context.close()
214+
215+
175216
async def test_should_work_with_new_persistent_context(
176217
browser_type: BrowserType, assetdir: Path, launch_arguments: Dict
177218
) -> None:

tests/async/test_fetch_browser_context.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,48 @@ async def test_should_support_query_params(
9797
server.EMPTY_PAGE + "?p1=foo", params=expected_params
9898
),
9999
)
100-
assert server_req.args["p1".encode()][0].decode() == "v1"
101-
assert len(server_req.args["p1".encode()]) == 1
100+
assert list(map(lambda x: x.decode(), server_req.args["p1".encode()])) == [
101+
"foo",
102+
"v1",
103+
]
104+
assert server_req.args["парам2".encode()][0].decode() == "знач2"
105+
106+
107+
@pytest.mark.parametrize(
108+
"method", ["fetch", "delete", "get", "head", "patch", "post", "put"]
109+
)
110+
async def test_should_support_params_passed_as_object(
111+
context: BrowserContext, server: Server, method: str
112+
) -> None:
113+
params = {
114+
"param1": "value1",
115+
"парам2": "знач2",
116+
}
117+
[server_req, _] = await asyncio.gather(
118+
server.wait_for_request("/empty.html"),
119+
getattr(context.request, method)(server.EMPTY_PAGE, params=params),
120+
)
121+
assert server_req.args["param1".encode()][0].decode() == "value1"
122+
assert len(server_req.args["param1".encode()]) == 1
123+
assert server_req.args["парам2".encode()][0].decode() == "знач2"
124+
125+
126+
@pytest.mark.parametrize(
127+
"method", ["fetch", "delete", "get", "head", "patch", "post", "put"]
128+
)
129+
async def test_should_support_params_passed_as_strings(
130+
context: BrowserContext, server: Server, method: str
131+
) -> None:
132+
params = "?param1=value1&param1=value2&парам2=знач2"
133+
[server_req, _] = await asyncio.gather(
134+
server.wait_for_request("/empty.html"),
135+
getattr(context.request, method)(server.EMPTY_PAGE, params=params),
136+
)
137+
assert list(map(lambda x: x.decode(), server_req.args["param1".encode()])) == [
138+
"value1",
139+
"value2",
140+
]
141+
assert len(server_req.args["param1".encode()]) == 2
102142
assert server_req.args["парам2".encode()][0].decode() == "знач2"
103143

104144

tests/sync/test_browsercontext_client_certificates.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,44 @@ def test_should_work_with_new_context(browser: Browser, assetdir: Path) -> None:
168168
context.close()
169169

170170

171+
def test_should_work_with_new_context_passing_as_content(
172+
browser: Browser, assetdir: Path
173+
) -> None:
174+
context = browser.new_context(
175+
# TODO: Remove this once we can pass a custom CA.
176+
ignore_https_errors=True,
177+
client_certificates=[
178+
{
179+
"origin": "https://127.0.0.1:8000",
180+
"cert": (
181+
assetdir / "client-certificates/client/trusted/cert.pem"
182+
).read_bytes(),
183+
"key": (
184+
assetdir / "client-certificates/client/trusted/key.pem"
185+
).read_bytes(),
186+
}
187+
],
188+
)
189+
page = context.new_page()
190+
page.goto("https://localhost:8000")
191+
expect(page.get_by_test_id("message")).to_have_text(
192+
"Sorry, but you need to provide a client certificate to continue."
193+
)
194+
page.goto("https://127.0.0.1:8000")
195+
expect(page.get_by_test_id("message")).to_have_text(
196+
"Hello Alice, your certificate was issued by localhost!"
197+
)
198+
199+
response = page.context.request.get("https://localhost:8000")
200+
assert (
201+
"Sorry, but you need to provide a client certificate to continue."
202+
in response.text()
203+
)
204+
response = page.context.request.get("https://127.0.0.1:8000")
205+
assert "Hello Alice, your certificate was issued by localhost!" in response.text()
206+
context.close()
207+
208+
171209
def test_should_work_with_new_persistent_context(
172210
browser_type: BrowserType, assetdir: Path, launch_arguments: Dict
173211
) -> None:

tests/sync/test_fetch_browser_context.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,43 @@ def test_should_support_query_params(
8989
getattr(context.request, method)(
9090
server.EMPTY_PAGE + "?p1=foo", params=expected_params
9191
)
92-
assert server_req.value.args["p1".encode()][0].decode() == "v1"
93-
assert len(server_req.value.args["p1".encode()]) == 1
92+
assert list(map(lambda x: x.decode(), server_req.value.args["p1".encode()])) == [
93+
"foo",
94+
"v1",
95+
]
96+
assert server_req.value.args["парам2".encode()][0].decode() == "знач2"
97+
98+
99+
@pytest.mark.parametrize(
100+
"method", ["fetch", "delete", "get", "head", "patch", "post", "put"]
101+
)
102+
def test_should_support_params_passed_as_object(
103+
context: BrowserContext, server: Server, method: str
104+
) -> None:
105+
params = {
106+
"param1": "value1",
107+
"парам2": "знач2",
108+
}
109+
with server.expect_request("/empty.html") as server_req:
110+
getattr(context.request, method)(server.EMPTY_PAGE, params=params)
111+
assert server_req.value.args["param1".encode()][0].decode() == "value1"
112+
assert len(server_req.value.args["param1".encode()]) == 1
113+
assert server_req.value.args["парам2".encode()][0].decode() == "знач2"
114+
115+
116+
@pytest.mark.parametrize(
117+
"method", ["fetch", "delete", "get", "head", "patch", "post", "put"]
118+
)
119+
def test_should_support_params_passed_as_strings(
120+
context: BrowserContext, server: Server, method: str
121+
) -> None:
122+
params = "?param1=value1&param1=value2&парам2=знач2"
123+
with server.expect_request("/empty.html") as server_req:
124+
getattr(context.request, method)(server.EMPTY_PAGE, params=params)
125+
assert list(
126+
map(lambda x: x.decode(), server_req.value.args["param1".encode()])
127+
) == ["value1", "value2"]
128+
assert len(server_req.value.args["param1".encode()]) == 2
94129
assert server_req.value.args["парам2".encode()][0].decode() == "знач2"
95130

96131

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