Skip to content

Commit cf233da

Browse files
pavelfeldmanclaude
andcommitted
fix(tests): bound CDP connect timeout, drop https for storage-state probe
Two unrelated Windows-only failures on PR #3051: 1. test_connect_over_cdp_passing_header_works hung on Windows + Python 3.12/3.13: connect_over_cdp had no explicit timeout, the bogus ws://127.0.0.1/ws endpoint never speaks CDP, and the IOCP scheduler on 3.12+ kept the await past the 90s pytest timeout. Pass timeout=5000 so the Error rises promptly. Upstream's parallel TS test does the same with timeout: 100; 5000 leaves headroom for slow runners. 2. test_set_storage_state_should_apply_state_to_existing_context hung on Stable Edge (Windows) only. The two https://www.example.com navigations took the network path before page.route intercepted. Use http://example.com instead — same origin semantics for the localStorage assertion, no TLS setup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3392e01 commit cf233da

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

tests/async/test_browsercontext_storage_state.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,16 @@ async def test_should_round_trip_through_the_file(
136136
async def test_set_storage_state_should_apply_state_to_existing_context(
137137
browser: Browser,
138138
) -> None:
139+
# http (not https) avoids TLS setup on Edge stable on Windows where the
140+
# network path is taken before route intercept short-circuits.
141+
origin = "http://example.com"
139142
src = await browser.new_context()
140143
src_page = await src.new_page()
141144
await src_page.route(
142145
"**/*",
143146
lambda route: asyncio.create_task(route.fulfill(body="<html></html>")),
144147
)
145-
await src_page.goto("https://www.example.com")
148+
await src_page.goto(origin)
146149
await src_page.evaluate('() => localStorage.setItem("k", "v")')
147150
state = await src.storage_state()
148151
await src.close()
@@ -154,7 +157,7 @@ async def test_set_storage_state_should_apply_state_to_existing_context(
154157
lambda route: asyncio.create_task(route.fulfill(body="<html></html>")),
155158
)
156159
await dst.set_storage_state(state)
157-
await dst_page.goto("https://www.example.com")
160+
await dst_page.goto(origin)
158161
assert await dst_page.evaluate('() => localStorage.getItem("k")') == "v"
159162
await dst.close()
160163

tests/async/test_browsertype_connect_cdp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ async def test_connect_over_cdp_passing_header_works(
9696
request = asyncio.create_task(server.wait_for_request("/ws"))
9797
with pytest.raises(Error):
9898
await browser_type.connect_over_cdp(
99-
f"ws://127.0.0.1:{server.PORT}/ws", headers={"foo": "bar"}
99+
f"ws://127.0.0.1:{server.PORT}/ws",
100+
headers={"foo": "bar"},
101+
timeout=5000,
100102
)
101103
assert (await request).getHeader("foo") == "bar"
102104

0 commit comments

Comments
 (0)