From a7d27d27f6c019fa820694ba6cfe47b66d717cf2 Mon Sep 17 00:00:00 2001 From: "microsoft-playwright-automation[bot]" <203992400+microsoft-playwright-automation[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 09:59:28 +0000 Subject: [PATCH] chore: roll Playwright to 1.66.0-next (b4d016aadc) --- DRIVER_VERSION | 2 +- README.md | 2 +- playwright/_impl/_protocol.py | 2 - playwright/_impl/browser_type.py | 12 ---- playwright/_impl/protocol/validator.py | 16 ----- playwright/_impl/protocol_channels.py | 19 ------ playwright/_impl/protocol_types.py | 4 -- playwright/_impl/worker.py | 13 +--- .../library/chromium/test_connect_over_cdp.py | 6 +- tests/async/library/test_emulation_focus.py | 3 + tests/async/library/test_tracing.py | 61 +++++++++++++++++++ tests/async/library/test_web_socket.py | 2 +- tests/async/page/test_page_evaluate.py | 22 ------- tests/async/page/test_page_screenshot.py | 2 +- .../library/chromium/test_connect_over_cdp.py | 6 +- tests/sync/library/test_emulation_focus.py | 3 + tests/sync/library/test_tracing.py | 61 +++++++++++++++++++ tests/sync/library/test_web_socket.py | 2 +- tests/sync/page/test_page_evaluate.py | 22 ------- tests/sync/page/test_page_screenshot.py | 2 +- tests/upstream_not_ported.txt | 1 - tests/upstream_registry.md | 4 +- 22 files changed, 146 insertions(+), 121 deletions(-) diff --git a/DRIVER_VERSION b/DRIVER_VERSION index 997f4dfc8..87d690711 100644 --- a/DRIVER_VERSION +++ b/DRIVER_VERSION @@ -1 +1 @@ -8534271f0413bae6a455b7cf43b2637391bc614b +b4d016aadc5cbd2b898a284307975fe73e05483d diff --git a/README.md b/README.md index baf2e4d5f..96c15b0ea 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 158.0.8127.18 | ✅ | ✅ | ✅ | +| Chromium 159.0.8154.6 | ✅ | ✅ | ✅ | | WebKit 27.2 | ✅ | ✅ | ✅ | | Firefox 159.0 | ✅ | ✅ | ✅ | diff --git a/playwright/_impl/_protocol.py b/playwright/_impl/_protocol.py index 10503a598..0e1e48dbf 100644 --- a/playwright/_impl/_protocol.py +++ b/playwright/_impl/_protocol.py @@ -1305,7 +1305,6 @@ "artifactsDir": "string?", "transport": "binary?", }, - "connectToWorker": {"endpoint": "string"}, }, "Disposable": {"dispose": {}}, "Electron": { @@ -2328,7 +2327,6 @@ }, }, "Worker": { - "disconnect": {"reason": "string?"}, "evaluateExpression": { "expression": "string", "isFunction": "boolean?", diff --git a/playwright/_impl/browser_type.py b/playwright/_impl/browser_type.py index 1e32773b5..722ef431f 100644 --- a/playwright/_impl/browser_type.py +++ b/playwright/_impl/browser_type.py @@ -62,7 +62,6 @@ from playwright._impl.errors import Error from playwright._impl.isomorphic.headers import headers_object_to_array from playwright._impl.timeout_settings import TimeoutSettings -from playwright._impl.worker import Worker if TYPE_CHECKING: # pragma: no cover from playwright._impl import protocol_types as channels @@ -434,17 +433,6 @@ async def _browser_from_connect_result( ) return browser - async def _connect_to_worker( - self, endpoint: str, timeout: Optional[float] - ) -> Worker: - if self.name != "chromium": - raise Error("Connecting to workers is only supported in Chromium.") - result = await self._channel.connectToWorker( - endpoint=endpoint, - timeout=TimeoutSettings().timeout(timeout), - ) - return Worker.from_(result["worker"]) - # Python only: the members of the Python API that upstream does not have. def __repr__(self) -> str: diff --git a/playwright/_impl/protocol/validator.py b/playwright/_impl/protocol/validator.py index 9fa10c900..1e6dcb6f2 100644 --- a/playwright/_impl/protocol/validator.py +++ b/playwright/_impl/protocol/validator.py @@ -1753,16 +1753,6 @@ "defaultContext": t_optional(t_channel(["BrowserContext"])), } ) -scheme["BrowserTypeConnectToWorkerParams"] = t_object( - { - "endpoint": t_string, - } -) -scheme["BrowserTypeConnectToWorkerResult"] = t_object( - { - "worker": t_channel(["Worker"]), - } -) scheme["Metadata"] = t_object( { "location": t_optional( @@ -4885,12 +4875,6 @@ } ) scheme["WorkerCloseEvent"] = t_optional(t_object({})) -scheme["WorkerDisconnectParams"] = t_object( - { - "reason": t_optional(t_string), - } -) -scheme["WorkerDisconnectResult"] = t_optional(t_object({})) scheme["WorkerEvaluateExpressionParams"] = t_object( { "expression": t_string, diff --git a/playwright/_impl/protocol_channels.py b/playwright/_impl/protocol_channels.py index 8de46b6c6..75fb58dc9 100644 --- a/playwright/_impl/protocol_channels.py +++ b/playwright/_impl/protocol_channels.py @@ -1906,18 +1906,6 @@ def connectOverCDP( }, ) - def connectToWorker( - self, - endpoint: str, - timeout: float = 0, - ) -> Awaitable[channels.BrowserTypeConnectToWorkerResult]: - return self._call( - "connectToWorker", - {"endpoint": endpoint}, - timeout, - lambda result: {"worker": result["worker"]}, - ) - class DisposableChannel(Channel): def dispose( @@ -5552,13 +5540,6 @@ def harExport( class WorkerChannel(Channel): - def disconnect( - self, - reason: Optional[str], - timeout: float = 0, - ) -> Awaitable[None]: - return self._call("disconnect", {"reason": reason}, timeout, None) - def evaluateExpression( self, expression: str, diff --git a/playwright/_impl/protocol_types.py b/playwright/_impl/protocol_types.py index 54053e0ad..f1884c7ed 100644 --- a/playwright/_impl/protocol_types.py +++ b/playwright/_impl/protocol_types.py @@ -833,10 +833,6 @@ class BrowserTypeConnectOverCDPResult(TypedDict): defaultContext: Optional[BrowserContextChannel] -class BrowserTypeConnectToWorkerResult(TypedDict): - worker: WorkerChannel - - class MetadataLocation(TypedDict): file: str line: NotRequired[int] diff --git a/playwright/_impl/worker.py b/playwright/_impl/worker.py index 2b13a909d..2095c11ce 100644 --- a/playwright/_impl/worker.py +++ b/playwright/_impl/worker.py @@ -25,7 +25,7 @@ from playwright._impl.channel_owner import ChannelOwner, api_call, from_channel from playwright._impl.console_message import ConsoleMessage -from playwright._impl.errors import TargetClosedError, is_target_closed_error +from playwright._impl.errors import TargetClosedError from playwright._impl.event_context_manager import EventContextManagerImpl from playwright._impl.events import Events from playwright._impl.isomorphic.manual_promise import LongStandingScope @@ -70,7 +70,6 @@ def __init__( Events.Worker.Console: "console", } ) - # Note: we only receive console events here for workers from "chromium._connectToWorker". self._channel.onConsole( lambda event: self.emit( Events.Worker.Console, ConsoleMessage(event, None, self, self) @@ -164,16 +163,6 @@ async def result() -> Any: return result() - async def _disconnect(self, reason: Optional[str]) -> None: - # Python: options is the reason parameter. - self._close_reason = reason - try: - await self._channel.disconnect(reason=reason, timeout=NO_TIMEOUT) - except Exception as e: - if is_target_closed_error(e): - return - raise - # Python only: the members of the Python API that upstream does not have. def expect_event( diff --git a/tests/async/library/chromium/test_connect_over_cdp.py b/tests/async/library/chromium/test_connect_over_cdp.py index 97e1d1a42..def0911e5 100644 --- a/tests/async/library/chromium/test_connect_over_cdp.py +++ b/tests/async/library/chromium/test_connect_over_cdp.py @@ -330,9 +330,13 @@ async def test_CD_007_should_write_traces_to_provided_artifacts_dir_on_connect_o await context.tracing.start(name="cdp-trace", snapshots=True, screenshots=True) page = await context.new_page() await page.set_content("") + # The trace file of a discarded chunk is removed, check it before the chunk stops. + deadline = asyncio.get_running_loop().time() + 5 + while not (artifacts_dir / "cdp-trace.trace").exists(): + assert asyncio.get_running_loop().time() < deadline + await asyncio.sleep(0.1) await context.tracing.stop_chunk() - assert (artifacts_dir / "cdp-trace.trace").exists() assert (artifacts_dir / "cdp-trace.network").exists() assert (artifacts_dir / "resources").exists() diff --git a/tests/async/library/test_emulation_focus.py b/tests/async/library/test_emulation_focus.py index 8d6601fa8..0f02d4c68 100644 --- a/tests/async/library/test_emulation_focus.py +++ b/tests/async/library/test_emulation_focus.py @@ -303,7 +303,10 @@ async def test_EM_024_should_trigger_hover_state_concurrently( async def test_EM_028_should_keep_mouse_drag_when_interacting_with_another_page_context( context_factory: Callable[..., Awaitable[BrowserContext]], + headless: bool, ) -> None: + if not headless: + pytest.skip("Stray mouse events mess up the test") page1 = await (await context_factory()).new_page() page2 = await (await context_factory()).new_page() for page in [page1, page2]: diff --git a/tests/async/library/test_tracing.py b/tests/async/library/test_tracing.py index 4801a9669..eef01bb65 100644 --- a/tests/async/library/test_tracing.py +++ b/tests/async/library/test_tracing.py @@ -532,6 +532,67 @@ async def test_TR_013_should_respect_traces_dir_and_name( assert (traces_dir / "name2.trace").exists() is True assert (traces_dir / "name2.network").exists() is True + await context.tracing.start( + name="discarded", + screenshots=True, + snapshots=True, + screen_snapshots=True, + aria_snapshots=True, + ) + await page.goto(server.PREFIX + "/har.html") + # A stylesheet changed through CSSOM is saved as a snapshot resource. + await page.evaluate( + "() => document.styleSheets[0].insertRule('.discarded-rule { color: red }')" + ) + await page.click("body") + + def snapshot_resources() -> List[str]: + return sorted( + file.name + for file in (traces_dir / "resources").iterdir() + if ".discarded-rule" in file.read_text(errors="replace") + ) + + for directory in ["screencast", "screenshots", "aria"]: + + def has_files() -> None: + assert len(list((traces_dir / directory).iterdir())) > 0 + + await to_pass(page, has_files) + + def has_snapshot_resource() -> None: + assert len(snapshot_resources()) == 1 + + await to_pass(page, has_snapshot_resource) + network_resources = sorted( + file.name + for file in (traces_dir / "resources").iterdir() + if file.name not in snapshot_resources() + ) + await context.tracing.stop_chunk() + + # Discarded files are removed in the background. + def trace_removed() -> None: + assert not (traces_dir / "discarded.trace").exists() + + await to_pass(page, trace_removed) + for directory in ["screencast", "screenshots", "aria"]: + + def is_empty() -> None: + assert list((traces_dir / directory).iterdir()) == [] + + await to_pass(page, is_empty) + + def only_network_resources() -> None: + assert ( + sorted(file.name for file in (traces_dir / "resources").iterdir()) + == network_resources + ) + + await to_pass(page, only_network_resources) + assert (traces_dir / "discarded.network").exists() is True + await context.tracing.stop() + await browser.close() def resource_names(resources: Dict[str, bytes]) -> List[str]: diff --git a/tests/async/library/test_web_socket.py b/tests/async/library/test_web_socket.py index b07929bd7..c3b5d2aa5 100644 --- a/tests/async/library/test_web_socket.py +++ b/tests/async/library/test_web_socket.py @@ -411,7 +411,7 @@ def child(req: TestServerRequest) -> None: server.set_route("/parent", parent) server.set_route("/child", child) - for _ in range(100): + for _ in range(20): await page.goto(server.PREFIX + "/parent") assert len(page.frames) == 2 assert await page.evaluate("() => 1 + 1") == 2 diff --git a/tests/async/page/test_page_evaluate.py b/tests/async/page/test_page_evaluate.py index 05e09e786..4f3f37602 100644 --- a/tests/async/page/test_page_evaluate.py +++ b/tests/async/page/test_page_evaluate.py @@ -16,7 +16,6 @@ import asyncio import datetime -import json import math import os import re @@ -325,33 +324,12 @@ async def test_EV_031_should_include_a_non_error_rejection_value_in_the_error_me assert "null" in exc_info.value.message -@pytest.mark.xfail( - reason="python: protocol validation exceeds the recursion limit for a 200-level evaluation argument", - strict=True, -) async def test_EV_032_should_return_complex_objects(page: Page) -> None: object = {"foo": "bar!"} result = await page.evaluate("a => a", object) assert result is not object assert result == object - argument: Any = 0 - # Chromium rejects protocol arguments at 60 levels, WebKit at 200. - for _ in range(200): - argument = {"children": [argument]} - assert await page.evaluate( - "value => JSON.stringify(value).length", argument - ) == len(json.dumps(argument, separators=(",", ":"))) - - # An argument that is too deep rejects and does not hang. - for _ in range(800): - argument = {"children": [argument]} - with pytest.raises(Error) as exc_info: - await page.evaluate("value => JSON.stringify(value).length", argument) - assert re.search( - "Maximum call stack size exceeded|too much recursion", exc_info.value.message - ) - async def test_EV_033_should_return_na_n(page: Page) -> None: result = await page.evaluate("() => NaN") diff --git a/tests/async/page/test_page_screenshot.py b/tests/async/page/test_page_screenshot.py index f2b26f45f..679a74911 100644 --- a/tests/async/page/test_page_screenshot.py +++ b/tests/async/page/test_page_screenshot.py @@ -539,7 +539,7 @@ async def test_SS_095_page_screenshot_should_capture_webgl_canvas_after_its_draw "WebGL is not available on Intel macOS - https://bugs.webkit.org/show_bug.cgi?id=278277" ) - await page.set_viewport_size({"width": 200, "height": 200}) + await page.set_viewport_size({"width": 300, "height": 300}) await page.set_content( '
' ) diff --git a/tests/sync/library/chromium/test_connect_over_cdp.py b/tests/sync/library/chromium/test_connect_over_cdp.py index 8712e74e7..4c2e3f1f5 100644 --- a/tests/sync/library/chromium/test_connect_over_cdp.py +++ b/tests/sync/library/chromium/test_connect_over_cdp.py @@ -347,9 +347,13 @@ def test_CD_007_should_write_traces_to_provided_artifacts_dir_on_connect_over_cd context.tracing.start(name="cdp-trace", snapshots=True, screenshots=True) page = context.new_page() page.set_content("") + # The trace file of a discarded chunk is removed, check it before the chunk stops. + deadline = time.monotonic() + 5 + while not (artifacts_dir / "cdp-trace.trace").exists(): + assert time.monotonic() < deadline + time.sleep(0.1) context.tracing.stop_chunk() - assert (artifacts_dir / "cdp-trace.trace").exists() assert (artifacts_dir / "cdp-trace.network").exists() assert (artifacts_dir / "resources").exists() diff --git a/tests/sync/library/test_emulation_focus.py b/tests/sync/library/test_emulation_focus.py index ae4095f72..8a1371ac9 100644 --- a/tests/sync/library/test_emulation_focus.py +++ b/tests/sync/library/test_emulation_focus.py @@ -302,7 +302,10 @@ def test_EM_024_should_trigger_hover_state_concurrently( def test_EM_028_should_keep_mouse_drag_when_interacting_with_another_page_context( context_factory: Callable[..., BrowserContext], + headless: bool, ) -> None: + if not headless: + pytest.skip("Stray mouse events mess up the test") page1 = context_factory().new_page() page2 = context_factory().new_page() for page in [page1, page2]: diff --git a/tests/sync/library/test_tracing.py b/tests/sync/library/test_tracing.py index 8027c3caf..eee2d8346 100644 --- a/tests/sync/library/test_tracing.py +++ b/tests/sync/library/test_tracing.py @@ -544,6 +544,67 @@ def test_TR_013_should_respect_traces_dir_and_name( assert (traces_dir / "name2.trace").exists() is True assert (traces_dir / "name2.network").exists() is True + context.tracing.start( + name="discarded", + screenshots=True, + snapshots=True, + screen_snapshots=True, + aria_snapshots=True, + ) + page.goto(server.PREFIX + "/har.html") + # A stylesheet changed through CSSOM is saved as a snapshot resource. + page.evaluate( + "() => document.styleSheets[0].insertRule('.discarded-rule { color: red }')" + ) + page.click("body") + + def snapshot_resources() -> List[str]: + return sorted( + file.name + for file in (traces_dir / "resources").iterdir() + if ".discarded-rule" in file.read_text(errors="replace") + ) + + for directory in ["screencast", "screenshots", "aria"]: + + def has_files() -> None: + assert len(list((traces_dir / directory).iterdir())) > 0 + + to_pass(page, has_files) + + def has_snapshot_resource() -> None: + assert len(snapshot_resources()) == 1 + + to_pass(page, has_snapshot_resource) + network_resources = sorted( + file.name + for file in (traces_dir / "resources").iterdir() + if file.name not in snapshot_resources() + ) + context.tracing.stop_chunk() + + # Discarded files are removed in the background. + def trace_removed() -> None: + assert not (traces_dir / "discarded.trace").exists() + + to_pass(page, trace_removed) + for directory in ["screencast", "screenshots", "aria"]: + + def is_empty() -> None: + assert list((traces_dir / directory).iterdir()) == [] + + to_pass(page, is_empty) + + def only_network_resources() -> None: + assert ( + sorted(file.name for file in (traces_dir / "resources").iterdir()) + == network_resources + ) + + to_pass(page, only_network_resources) + assert (traces_dir / "discarded.network").exists() is True + context.tracing.stop() + browser.close() def resource_names(resources: Dict[str, bytes]) -> List[str]: diff --git a/tests/sync/library/test_web_socket.py b/tests/sync/library/test_web_socket.py index 47eeda439..4f41e5c3a 100644 --- a/tests/sync/library/test_web_socket.py +++ b/tests/sync/library/test_web_socket.py @@ -416,7 +416,7 @@ def child(req: TestServerRequest) -> None: server.set_route("/parent", parent) server.set_route("/child", child) - for _ in range(100): + for _ in range(20): page.goto(server.PREFIX + "/parent") assert len(page.frames) == 2 assert page.evaluate("() => 1 + 1") == 2 diff --git a/tests/sync/page/test_page_evaluate.py b/tests/sync/page/test_page_evaluate.py index 1fa0b890a..0f564ce95 100644 --- a/tests/sync/page/test_page_evaluate.py +++ b/tests/sync/page/test_page_evaluate.py @@ -15,7 +15,6 @@ """Port of tests/page/page-evaluate.spec.ts.""" import datetime -import json import math import os import re @@ -328,33 +327,12 @@ def test_EV_031_should_include_a_non_error_rejection_value_in_the_error_message( assert "null" in exc_info.value.message -@pytest.mark.xfail( - reason="python: protocol validation exceeds the recursion limit for a 200-level evaluation argument", - strict=True, -) def test_EV_032_should_return_complex_objects(page: Page) -> None: object = {"foo": "bar!"} result = page.evaluate("a => a", object) assert result is not object assert result == object - argument: Any = 0 - # Chromium rejects protocol arguments at 60 levels, WebKit at 200. - for _ in range(200): - argument = {"children": [argument]} - assert page.evaluate("value => JSON.stringify(value).length", argument) == len( - json.dumps(argument, separators=(",", ":")) - ) - - # An argument that is too deep rejects and does not hang. - for _ in range(800): - argument = {"children": [argument]} - with pytest.raises(Error) as exc_info: - page.evaluate("value => JSON.stringify(value).length", argument) - assert re.search( - "Maximum call stack size exceeded|too much recursion", exc_info.value.message - ) - def test_EV_033_should_return_na_n(page: Page) -> None: result = page.evaluate("() => NaN") diff --git a/tests/sync/page/test_page_screenshot.py b/tests/sync/page/test_page_screenshot.py index a0c23e06f..156a854c9 100644 --- a/tests/sync/page/test_page_screenshot.py +++ b/tests/sync/page/test_page_screenshot.py @@ -539,7 +539,7 @@ def test_SS_095_page_screenshot_should_capture_webgl_canvas_after_its_drawing_bu "WebGL is not available on Intel macOS - https://bugs.webkit.org/show_bug.cgi?id=278277" ) - page.set_viewport_size({"width": 200, "height": 200}) + page.set_viewport_size({"width": 300, "height": 300}) page.set_content( '
' ) diff --git a/tests/upstream_not_ported.txt b/tests/upstream_not_ported.txt index e36fb9f45..bdf755e1f 100644 --- a/tests/upstream_not_ported.txt +++ b/tests/upstream_not_ported.txt @@ -85,7 +85,6 @@ CD-005 toImpl(cdpBrowser).options.artifactsDir is a server internal; the Py CD-030 toImpl(cdpBrowser)._isBrowserCollocatedWithServer is a server internal; the Python client can not reach it. CD-032 toImpl(frame).evaluateExpression() in the utility world is a server internal; the Python client can not reach it. CD-036 connectOverCDP(transport) takes a server ConnectionTransport object (WebSocketTransport), which only the in-process Node.js client can pass. -library/chromium/connect-to-worker browserType._connectToWorker() is a private method of the Node.js client; the Python client has no such API. # library/chromium/session CD-041 page.coverage (startJSCoverage/stopJSCoverage) is JavaScript-only; it is not in the Python API. # library/debugger diff --git a/tests/upstream_registry.md b/tests/upstream_registry.md index ee847431c..2f2c6fa90 100644 --- a/tests/upstream_registry.md +++ b/tests/upstream_registry.md @@ -49,7 +49,7 @@ subsystem, add a row to the Subsystems table. Then update this file: | `CM` | Console messages | `page/page-event-console` | | `CN` | Channels | `library/channels` | | `CO` | Cookies | `library/{browsercontext-cookies, browsercontext-add-cookies, browsercontext-clearcookies, browsercontext-cookies-third-party}` | -| `CR` | Chromium | `library/chromium/{chromium, launcher, extensions, bfcache, connect-to-worker, disable-web-security}` | +| `CR` | Chromium | `library/chromium/{chromium, launcher, extensions, bfcache, disable-web-security}` | | `CS` | CSP | `library/browsercontext-csp` | | `CV` | Coverage | `library/chromium/{js-coverage, css-coverage}`
`library/coverage` | | `DB` | Debug | `library/{debugger, debug-controller}` | @@ -1502,8 +1502,6 @@ subsystem, add a row to the Subsystems table. Then update this file: | `CR-040` | `library/chromium/extensions.spec.ts` | MV3 › should report console messages from content script | | `CR-041` | `library/chromium/extensions.spec.ts` | MV3 › should use custom userAgent in service worker fetch requests | | `CR-042` | `library/chromium/bfcache.spec.ts` | bindings should work after restoring from bfcache | -| `CR-043` | `library/chromium/connect-to-worker.spec.ts` | should connect, evaluate, receive console and disconnect | -| `CR-044` | `library/chromium/connect-to-worker.spec.ts` | should receive close when node process exits | | `CR-045` | `library/chromium/disable-web-security.spec.ts` | test utility world in popup w/ --disable-web-security | | `CR-046` | `library/chromium/disable-web-security.spec.ts` | test init script w/ --disable-web-security |