Skip to content

Commit af8baa0

Browse files
chore: roll Playwright to 1.66.0-next (8124fc3923) (#3353)
Co-authored-by: microsoft-playwright-automation[bot] <203992400+microsoft-playwright-automation[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 16fdfef commit af8baa0

72 files changed

Lines changed: 359 additions & 262 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎DRIVER_VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b4d016aadc5cbd2b898a284307975fe73e05483d
1+
8124fc39233c4c349b9dbebd4abc4103738eae81

‎playwright/_impl/_protocol.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,7 @@
13021302
"isLocal": "boolean?",
13031303
"noDefaults": "boolean?",
13041304
"isWebView": "boolean?",
1305+
"maxPageAttachTime": "float?",
13051306
"artifactsDir": "string?",
13061307
"transport": "binary?",
13071308
},

‎playwright/_impl/browser_type.py‎

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,7 @@ async def launch(
155155

156156
# Not ported: the logger option (JavaScript only).
157157
options = {**(self._playwright._default_launch_options or {}), **options}
158-
launch_options = {
159-
**_launch_params(options),
160-
"ignoreDefaultArgs": (
161-
options["ignore_default_args"]
162-
if _is_array(options.get("ignore_default_args"))
163-
else None
164-
),
165-
"ignoreAllDefaultArgs": bool(options.get("ignore_default_args"))
166-
and not _is_array(options.get("ignore_default_args")),
167-
"env": (
168-
env_object_to_array(options["env"])
169-
if options.get("env") is not None
170-
else None
171-
),
172-
}
158+
launch_options = to_launch_params(options)
173159
browser = Browser.from_(
174160
(
175161
await self._channel.launch(
@@ -373,6 +359,7 @@ async def connect(
373359
return await self._connect({**options, "endpoint": endpoint})
374360

375361
async def _connect(self, params: Dict[str, Any]) -> Browser:
362+
# Not ported: launchOptions (langs: js).
376363
browser = await connect_to_browser(
377364
self._playwright, {"browser_name": self.name, **params}
378365
)
@@ -388,6 +375,8 @@ async def connect_over_cdp(
388375
is_local: Optional[bool],
389376
no_defaults: Optional[bool],
390377
artifacts_dir: Optional[Union[str, Path]],
378+
# Python: an undocumented option, available only to implementation callers.
379+
max_page_attach_time: Optional[float] = None,
391380
) -> Browser:
392381
# Not ported: connectOverCDP() with an options object or with a
393382
# ConnectOverCDPTransport (JavaScript only), so there is no transport.
@@ -399,6 +388,7 @@ async def connect_over_cdp(
399388
headers=headers,
400389
is_local=is_local,
401390
no_defaults=no_defaults,
391+
max_page_attach_time=max_page_attach_time,
402392
artifacts_dir=_to_path_string(artifacts_dir),
403393
)
404394
if endpoint_url and self.name != "chromium" and self.name != "webkit":
@@ -417,6 +407,7 @@ async def connect_over_cdp(
417407
noDefaults=params.get("no_defaults"),
418408
# Python: the Python API has no isWebView option.
419409
isWebView=None,
410+
maxPageAttachTime=params.get("max_page_attach_time"),
420411
artifactsDir=params.get("artifacts_dir"),
421412
timeout=TimeoutSettings().timeout(params.get("timeout")),
422413
)
@@ -439,6 +430,24 @@ def __repr__(self) -> str:
439430
return f"<BrowserType name={self.name} executable_path={self.executable_path}>"
440431

441432

433+
def to_launch_params(options: Dict[str, Any]) -> Dict[str, Any]:
434+
return {
435+
**_launch_params(options),
436+
"ignoreDefaultArgs": (
437+
options["ignore_default_args"]
438+
if _is_array(options.get("ignore_default_args"))
439+
else None
440+
),
441+
"ignoreAllDefaultArgs": bool(options.get("ignore_default_args"))
442+
and not _is_array(options.get("ignore_default_args")),
443+
"env": (
444+
env_object_to_array(options["env"])
445+
if options.get("env") is not None
446+
else None
447+
),
448+
}
449+
450+
442451
# Not ported: isConnectionTransport(), for connectOverCDP() with a
443452
# ConnectOverCDPTransport (JavaScript only).
444453

‎playwright/_impl/protocol/validator.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,7 @@
17431743
"isLocal": t_optional(t_boolean),
17441744
"noDefaults": t_optional(t_boolean),
17451745
"isWebView": t_optional(t_boolean),
1746+
"maxPageAttachTime": t_optional(t_float),
17461747
"artifactsDir": t_optional(t_string),
17471748
"transport": t_optional(t_binary),
17481749
}

‎playwright/_impl/protocol_channels.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,7 @@ def connectOverCDP(
18831883
isLocal: Optional[bool],
18841884
noDefaults: Optional[bool],
18851885
isWebView: Optional[bool],
1886+
maxPageAttachTime: Optional[float],
18861887
artifactsDir: Optional[str],
18871888
transport: Optional[str],
18881889
timeout: float = 0,
@@ -1896,6 +1897,7 @@ def connectOverCDP(
18961897
"isLocal": isLocal,
18971898
"noDefaults": noDefaults,
18981899
"isWebView": isWebView,
1900+
"maxPageAttachTime": maxPageAttachTime,
18991901
"artifactsDir": artifactsDir,
19001902
"transport": transport,
19011903
},

‎tests/async/library/chromium/test_connect_over_cdp.py‎

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
import pytest
2828

29+
from playwright._impl._async_base import mapping as api_mapping
30+
from playwright._impl.utils.tasks import fire_and_forget
2931
from playwright.async_api import (
3032
Browser,
3133
BrowserType,
@@ -673,7 +675,7 @@ def handle(request: TestServerRequest) -> None:
673675
endpoint_url=server.PREFIX,
674676
)
675677
assert (
676-
f"BrowserType.connect_over_cdp: Unexpected status 404 when connecting to {server.PREFIX}/json/version/"
678+
f"Unexpected status 404 when connecting to {server.PREFIX}/json/version/"
677679
in exc_info.value.message
678680
)
679681

@@ -691,7 +693,7 @@ def handle(request: TestServerRequest) -> None:
691693
await browser_type.connect_over_cdp(
692694
endpoint_url=server.PREFIX,
693695
)
694-
assert "BrowserType.connect_over_cdp: Invalid URL" in exc_info.value.message
696+
assert "Invalid URL" in exc_info.value.message
695697

696698

697699
async def test_CD_022_should_connect_to_an_existing_cdp_session_when_passed_as_a_first_argument(
@@ -961,6 +963,63 @@ async def test_CD_035_no_defaults_should_not_affect_new_contexts(
961963
await browser_server.close()
962964

963965

966+
async def test_CD_054_should_not_wait_for_a_busy_page_longer_than_max_page_attach_time(
967+
browser_type: BrowserType, server: Server, launch_arguments: Dict, port: int
968+
) -> None:
969+
# The busy page should not share a renderer with the other page.
970+
browser_server = await launch(
971+
browser_type, launch_arguments, port, "--site-per-process"
972+
)
973+
try:
974+
cdp_browser1 = await browser_type.connect_over_cdp(
975+
endpoint_url=f"http://127.0.0.1:{port}/",
976+
)
977+
context1 = cdp_browser1.contexts[0]
978+
page1 = await context1.new_page()
979+
await page1.goto(server.CROSS_PROCESS_PREFIX + "/title.html")
980+
busy_page1 = await context1.new_page()
981+
await busy_page1.goto(server.EMPTY_PAGE)
982+
async with busy_page1.expect_event(
983+
"console", predicate=lambda message: message.text == "busy"
984+
):
985+
fire_and_forget(
986+
busy_page1.evaluate(
987+
"""() => {
988+
console.log('busy');
989+
const start = Date.now();
990+
while (Date.now() - start < 5000) {}
991+
}"""
992+
)
993+
)
994+
# Python: the option is undocumented; call the implementation directly.
995+
cdp_browser2: Browser = api_mapping.from_impl(
996+
await browser_type._impl_obj.connect_over_cdp(
997+
endpoint_url=f"http://127.0.0.1:{port}/",
998+
timeout=None,
999+
slow_mo=None,
1000+
headers=None,
1001+
is_local=None,
1002+
no_defaults=None,
1003+
artifacts_dir=None,
1004+
max_page_attach_time=500,
1005+
)
1006+
)
1007+
context2 = cdp_browser2.contexts[0]
1008+
pages = context2.pages
1009+
assert [page.url for page in pages] == [
1010+
server.CROSS_PROCESS_PREFIX + "/title.html"
1011+
]
1012+
assert await pages[0].title() == "Woof-Woof"
1013+
# The busy page is reported when its renderer responds again.
1014+
busy_page2 = await context2.wait_for_event("page")
1015+
assert busy_page2.url == server.EMPTY_PAGE
1016+
assert await busy_page2.evaluate("() => 1 + 1") == 2
1017+
await cdp_browser2.close()
1018+
await cdp_browser1.close()
1019+
finally:
1020+
await browser_server.close()
1021+
1022+
9641023
async def test_CD_053_should_connect_when_another_client_inspects_a_terminated_shared_worker(
9651024
browser_type: BrowserType, server: Server, launch_arguments: Dict, port: int
9661025
) -> None:

‎tests/async/library/test_browsercontext_fetch.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ async def test_FE_092_should_throw_on_network_error(
211211
server.set_route("/test", destroy_socket)
212212
with pytest.raises(Error) as exc_info:
213213
await context.request.get(server.PREFIX + "/test")
214-
assert "APIRequestContext.get: socket hang up" in exc_info.value.message
214+
assert "socket hang up" in exc_info.value.message
215215

216216

217217
async def test_FE_093_should_throw_on_network_error_after_redirect(
@@ -221,7 +221,7 @@ async def test_FE_093_should_throw_on_network_error_after_redirect(
221221
server.set_route("/test", destroy_socket)
222222
with pytest.raises(Error) as exc_info:
223223
await context.request.get(server.PREFIX + "/redirect")
224-
assert "APIRequestContext.get: socket hang up" in exc_info.value.message
224+
assert "socket hang up" in exc_info.value.message
225225

226226

227227
async def test_FE_094_should_throw_on_network_error_when_sending_body(
@@ -230,7 +230,7 @@ async def test_FE_094_should_throw_on_network_error_when_sending_body(
230230
server.set_route("/test", send_partial_body_and_destroy_socket)
231231
with pytest.raises(Error) as exc_info:
232232
await context.request.get(server.PREFIX + "/test")
233-
assert "APIRequestContext.get: aborted" in exc_info.value.message
233+
assert "aborted" in exc_info.value.message
234234

235235

236236
async def test_FE_095_should_throw_on_network_error_when_sending_body_after_redirect(
@@ -240,7 +240,7 @@ async def test_FE_095_should_throw_on_network_error_when_sending_body_after_redi
240240
server.set_route("/test", send_partial_body_and_destroy_socket)
241241
with pytest.raises(Error) as exc_info:
242242
await context.request.get(server.PREFIX + "/redirect")
243-
assert "APIRequestContext.get: aborted" in exc_info.value.message
243+
assert "aborted" in exc_info.value.message
244244

245245

246246
async def test_FE_096_should_add_session_cookies_to_request(
@@ -1172,7 +1172,7 @@ async def test_FE_148_should_support_timeout_option(
11721172

11731173
with pytest.raises(Error) as exc_info:
11741174
await context.request.get(server.PREFIX + "/slow", timeout=10)
1175-
assert "APIRequestContext.get: Timeout 10ms exceeded" in exc_info.value.message
1175+
assert "Timeout 10ms exceeded" in exc_info.value.message
11761176

11771177

11781178
async def test_FE_149_should_support_a_timeout_of_0(
@@ -1198,7 +1198,7 @@ async def test_FE_150_should_respect_timeout_after_redirects(
11981198
context.set_default_timeout(100)
11991199
with pytest.raises(Error) as exc_info:
12001200
await context.request.get(server.PREFIX + "/redirect")
1201-
assert "APIRequestContext.get: Timeout 100ms exceeded" in exc_info.value.message
1201+
assert "Timeout 100ms exceeded" in exc_info.value.message
12021202

12031203

12041204
async def test_FE_151_should_not_hang_on_a_brotli_encoded_range_request(

‎tests/async/library/test_browsercontext_storage_state.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async def test_ST_003_should_report_good_error_if_the_url_is_not_valid(
118118
],
119119
}
120120
)
121-
assert "Browser.new_context: Error setting storage state:" in exc_info.value.message
121+
assert "Error setting storage state:" in exc_info.value.message
122122
assert "foo" in exc_info.value.message
123123

124124

‎tests/async/library/test_browsertype_connect.py‎

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
List,
3434
Optional,
3535
)
36-
from urllib.parse import urlparse
3736

3837
import pytest
3938

@@ -77,6 +76,7 @@ async def connect_browser(
7776
) -> Browser:
7877
"""Port of the connect fixture: passes the launch options for run-server along."""
7978
with redirect_port_forwarding_for_test(browser_type, redirect_port_for_test):
79+
# Python: launchOptions is JavaScript-only; send its header directly.
8080
return await browser_type.connect(
8181
ws_endpoint,
8282
headers={
@@ -305,7 +305,7 @@ def handle_ws(ws: WebSocketProtocol) -> None:
305305
server.once_web_socket_connection(handle_ws)
306306
with pytest.raises(Error) as exc_info:
307307
await connect(f"ws://localhost:{server.PORT}/ws")
308-
assert "BrowserType.connect: Oh my!" in exc_info.value.message
308+
assert "Oh my!" in exc_info.value.message
309309

310310

311311
@pytest.mark.parametrize("kind", KINDS)
@@ -471,7 +471,7 @@ def upgrade() -> None:
471471
server.set_route("/ws-slow", handle_ws_slow)
472472
with pytest.raises(Error) as exc_info:
473473
await connect(f"ws://localhost:{server.PORT}/ws-slow", timeout=1000)
474-
assert "BrowserType.connect: Timeout 1000ms exceeded" in exc_info.value.message
474+
assert "Timeout 1000ms exceeded" in exc_info.value.message
475475

476476

477477
@pytest.mark.parametrize("kind", KINDS)
@@ -484,7 +484,7 @@ async def test_BT_045_should_timeout_in_connect_while_connecting(
484484
server.once_web_socket_connection(server_web_sockets.append)
485485
with pytest.raises(Error) as exc_info:
486486
await connect(f"ws://localhost:{server.PORT}/ws", timeout=100)
487-
assert "BrowserType.connect: Timeout 100ms exceeded" in exc_info.value.message
487+
assert "Timeout 100ms exceeded" in exc_info.value.message
488488

489489

490490
@pytest.mark.parametrize("kind", KINDS)
@@ -1138,6 +1138,7 @@ async def test_BT_071_should_be_able_to_connect_when_the_ws_endpoint_is_passed_a
11381138
start_remote_server: RemoteServerStarter,
11391139
) -> None:
11401140
remote_server = start_remote_server(kind)
1141+
# Python: launchOptions is JavaScript-only; send its header directly.
11411142
browser = await browser_type.connect(
11421143
endpoint=remote_server.ws_endpoint,
11431144
headers={
@@ -1376,20 +1377,6 @@ async def test_BT_078_set_input_files_should_preserve_last_modified_timestamp(
13761377
), f"expected: {expected_timestamps}; actual: {timestamps}"
13771378

13781379

1379-
@pytest.mark.parametrize("kind", KINDS)
1380-
async def test_BT_079_should_connect_over_http(
1381-
kind: str,
1382-
connect: Callable[..., Awaitable[Browser]],
1383-
start_remote_server: RemoteServerStarter,
1384-
) -> None:
1385-
remote_server = start_remote_server(kind)
1386-
1387-
url = urlparse(remote_server.ws_endpoint)
1388-
browser = await connect(f"http://localhost:{url.port}")
1389-
assert browser.version
1390-
await browser.close()
1391-
1392-
13931380
def skip_socks_proxy(kind: str) -> None:
13941381
"""Port of the test.skip() of the 'socks proxy' describe."""
13951382
if kind == KIND_LAUNCH_SERVER:
@@ -1872,23 +1859,3 @@ async def test_BT_094_should_filter_local_paths_from_unsafe_launch_options(
18721859

18731860
actions = trace_actions(read_trace(trace_path))
18741861
assert "Frame.setContent" in actions
1875-
1876-
1877-
async def test_BT_095_should_timeout_after_redirect_when_connecting_over_http(
1878-
playwright: Playwright,
1879-
connect: Callable[..., Awaitable[Browser]],
1880-
server: Server,
1881-
) -> None:
1882-
server.set_redirect("/connect/json", "/connect/slow")
1883-
aborted: List[bool] = []
1884-
1885-
def handle_slow(request: TestServerRequest) -> None:
1886-
request.notifyFinish().addErrback(lambda _: aborted.append(True))
1887-
1888-
server.set_route("/connect/slow", handle_slow)
1889-
with pytest.raises(Error) as exc_info:
1890-
await connect(
1891-
f"{server.PREFIX}/connect", timeout=2000, headers={"Connection": "Close"}
1892-
)
1893-
assert "Timeout 2000ms exceeded." in exc_info.value.message
1894-
await poll(playwright, lambda: aborted == [True])

‎tests/async/library/test_browsertype_launch.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def test_BT_010_should_reject_if_launched_browser_fails_immediately(
8080
assert "Failed to launch" in exc_info.value.message
8181
else:
8282
assert re.search(
83-
r"browserType\.launch(.|\n)*(spawn UNKNOWN|spawn EFTYPE|Browser logs:)",
83+
r"(spawn UNKNOWN|spawn EFTYPE|Browser logs:)",
8484
exc_info.value.message,
8585
re.IGNORECASE | re.MULTILINE,
8686
)

0 commit comments

Comments
 (0)