tests: a goto to a refused port waits for the error page's navigation before the next goto starts

This commit is contained in:
feder-cr committed 2026-11-22 03:51:20 +01:00
1 parent 50f2e53c9c
commit 8e4be5b67d
1 file changed
+10 -3
@@ -56,9 +56,16 @@ class _Page(BaseHTTPRequestHandler):
def _goto_error(page, url):
"""The text of the error a `goto` ends with (the test fails if it ends without one)."""
with pytest.raises(Exception) as ended:
page.goto(url, timeout=30_000)
"""The text of the error a `goto` ends with (the test fails if it ends without one).
A failed `goto` is followed by Firefox's error page, a navigation of its own that commits after the call has
raised (on Windows, late enough to land inside the next `goto`, which then reads as "interrupted by another
navigation to" the refused address). The call is therefore made inside a wait for that navigation's
`framenavigated`: it returns only once the error page has committed and the frame is quiet.
"""
with page.expect_event("framenavigated", timeout=30_000):
with pytest.raises(Exception) as ended:
page.goto(url, timeout=30_000)
return str(ended.value)