From 6beee17bf2565d78139aba1d666ee1bb341e32ec Mon Sep 17 00:00:00 2001 From: "Ross A. Wollman" Date: Tue, 26 Jul 2022 10:51:10 -0700 Subject: [PATCH 1/4] chore: roll Playwright to 1.25.0-alpha-jul-26-2022 --- README.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 33d368e3b..46cf1950f 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 104.0.5112.48 | ✅ | ✅ | ✅ | +| Chromium 104.0.5112.57 | ✅ | ✅ | ✅ | | WebKit 16.0 | ✅ | ✅ | ✅ | | Firefox 102.0 | ✅ | ✅ | ✅ | diff --git a/setup.py b/setup.py index 0e9002a25..81ce914df 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ InWheel = None from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand -driver_version = "1.24.0" +driver_version = "1.25.0-alpha-jul-26-2022" def extractall(zip: zipfile.ZipFile, path: str) -> None: From 7dc09cb28642dc8b1e36d738598bfe94160b815c Mon Sep 17 00:00:00 2001 From: "Ross A. Wollman" Date: Tue, 26 Jul 2022 15:23:39 -0700 Subject: [PATCH 2/4] port re-parenting --- playwright/_impl/_browser_context.py | 4 +--- playwright/_impl/_connection.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/playwright/_impl/_browser_context.py b/playwright/_impl/_browser_context.py index c3cd5ce4d..f06c0b126 100644 --- a/playwright/_impl/_browser_context.py +++ b/playwright/_impl/_browser_context.py @@ -100,9 +100,7 @@ def __init__( self._service_workers: Set[Worker] = set() self._tracing = cast(Tracing, from_channel(initializer["tracing"])) self._har_recorders: Dict[str, HarRecordingMetadata] = {} - self._request: APIRequestContext = from_channel( - initializer["APIRequestContext"] - ) + self._request: APIRequestContext = from_channel(initializer["requestContext"]) self._channel.on( "bindingCall", lambda params: self._on_binding(from_channel(params["binding"])), diff --git a/playwright/_impl/_connection.py b/playwright/_impl/_connection.py index f9790ff1e..7bdf999e9 100644 --- a/playwright/_impl/_connection.py +++ b/playwright/_impl/_connection.py @@ -129,6 +129,11 @@ def _dispose(self) -> None: object._dispose() self._objects.clear() + def _adopt(self, child: "ChannelOwner") -> None: + del cast("ChannelOwner", child._parent)._objects[child._guid] + self._objects[child._guid] = child + child._parent = self + class ProtocolCallback: def __init__(self, loop: asyncio.AbstractEventLoop) -> None: @@ -294,6 +299,19 @@ def dispatch(self, msg: ParsedMessagePayload) -> None: parent, params["type"], params["guid"], params["initializer"] ) return + + object = self._objects.get(guid) + if not object: + raise Exception(f'Cannot find object to "{method}": {guid}') + + if method == "__adopt__": + child_guid = cast(Dict[str, str], params)["guid"] + child = self._objects.get(child_guid) + if not child: + raise Exception(f"Unknown new child: {child_guid}") + object._adopt(child) + return + if method == "__dispose__": self._objects[guid]._dispose() return From 4a2a8ea2913e34770567878fff13bc47900c492a Mon Sep 17 00:00:00 2001 From: "Ross A. Wollman" Date: Tue, 26 Jul 2022 15:46:02 -0700 Subject: [PATCH 3/4] re-baseline test --- tests/async/test_launcher.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/async/test_launcher.py b/tests/async/test_launcher.py index 3ed7b6603..a07fb8de3 100644 --- a/tests/async/test_launcher.py +++ b/tests/async/test_launcher.py @@ -21,7 +21,7 @@ async def test_browser_type_launch_should_reject_all_promises_when_browser_is_closed( - browser_type: BrowserType, launch_arguments + browser_type: BrowserType, launch_arguments, is_chromium ): browser = await browser_type.launch(**launch_arguments) page = await (await browser.new_context()).new_page() @@ -29,7 +29,10 @@ async def test_browser_type_launch_should_reject_all_promises_when_browser_is_cl await page.close() with pytest.raises(Error) as exc: await never_resolves - assert "Target closed" in exc.value.message + if is_chromium: + assert "Target page, context or browser has been closed" in exc.value.message + else: + assert "Target closed" in exc.value.message @pytest.mark.skip_browser("firefox") From f344e30c7535a82ca6b0ef3c1c775f9ffd654832 Mon Sep 17 00:00:00 2001 From: "Ross A. Wollman" Date: Wed, 27 Jul 2022 11:29:57 -0700 Subject: [PATCH 4/4] relax constraint --- tests/async/test_launcher.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/async/test_launcher.py b/tests/async/test_launcher.py index a07fb8de3..a3c0b5721 100644 --- a/tests/async/test_launcher.py +++ b/tests/async/test_launcher.py @@ -21,7 +21,7 @@ async def test_browser_type_launch_should_reject_all_promises_when_browser_is_closed( - browser_type: BrowserType, launch_arguments, is_chromium + browser_type: BrowserType, launch_arguments ): browser = await browser_type.launch(**launch_arguments) page = await (await browser.new_context()).new_page() @@ -29,10 +29,10 @@ async def test_browser_type_launch_should_reject_all_promises_when_browser_is_cl await page.close() with pytest.raises(Error) as exc: await never_resolves - if is_chromium: - assert "Target page, context or browser has been closed" in exc.value.message - else: - assert "Target closed" in exc.value.message + assert ( + "Target closed" in exc.value.message + or "Target page, context or browser has been closed" in exc.value.message + ) @pytest.mark.skip_browser("firefox")