From 34de0337b970c70f28ec81eaf0be08613d1d4cbc Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 4 Oct 2021 12:02:58 +0200 Subject: [PATCH] chore: roll to Playwright 1.16.0-next-1633339886000 --- README.md | 2 +- playwright/_impl/_browser_context.py | 11 +++++++++-- playwright/_impl/_helper.py | 8 +++++--- playwright/_impl/_page.py | 11 +++++++++-- setup.py | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3c0a612e3..f0f7cedff 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 96.0.4655.0 | ✅ | ✅ | ✅ | +| Chromium 96.0.4659.0 | ✅ | ✅ | ✅ | | WebKit 15.0 | ✅ | ✅ | ✅ | | Firefox 92.0 | ✅ | ✅ | ✅ | diff --git a/playwright/_impl/_browser_context.py b/playwright/_impl/_browser_context.py index 0668c9894..884ad6eba 100644 --- a/playwright/_impl/_browser_context.py +++ b/playwright/_impl/_browser_context.py @@ -149,13 +149,20 @@ def _on_page(self, page: Page) -> None: page._opener.emit(Page.Events.Popup, page) def _on_route(self, route: Route, request: Request) -> None: + handled = False for handler_entry in self._routes: if handler_entry.matches(request.url): result = handler_entry.handle(route, request) if inspect.iscoroutine(result): asyncio.create_task(result) - return - asyncio.create_task(route.continue_()) + handled = True + break + if not handled: + asyncio.create_task(route.continue_()) + else: + self._routes = list( + filter(lambda route: route.expired() is False, self._routes) + ) def _on_binding(self, binding_call: BindingCall) -> None: func = self._bindings.get(binding_call._initializer["name"]) diff --git a/playwright/_impl/_helper.py b/playwright/_impl/_helper.py index f5b03e7ee..282b4472f 100644 --- a/playwright/_impl/_helper.py +++ b/playwright/_impl/_helper.py @@ -213,13 +213,15 @@ def __init__( self._times = times self._handled_count = 0 + def expired(self) -> bool: + return self._times is not None and self._handled_count >= self._times + def matches(self, request_url: str) -> bool: - if self._times and self._handled_count >= self._times: - return False return self.matcher.matches(request_url) def handle(self, route: "Route", request: "Request") -> Union[Coroutine, Any]: - self._handled_count += 1 + if self._times: + self._handled_count += 1 return cast( Callable[["Route", "Request"], Union[Coroutine, Any]], self.handler )(route, request) diff --git a/playwright/_impl/_page.py b/playwright/_impl/_page.py index 88a3f5c5a..b07e5733e 100644 --- a/playwright/_impl/_page.py +++ b/playwright/_impl/_page.py @@ -212,13 +212,20 @@ def _on_frame_detached(self, frame: Frame) -> None: self.emit(Page.Events.FrameDetached, frame) def _on_route(self, route: Route, request: Request) -> None: + handled = False for handler_entry in self._routes: if handler_entry.matches(request.url): result = handler_entry.handle(route, request) if inspect.iscoroutine(result): asyncio.create_task(result) - return - self._browser_context._on_route(route, request) + handled = True + break + if not handled: + self._browser_context._on_route(route, request) + else: + self._routes = list( + filter(lambda route: route.expired() is False, self._routes) + ) def _on_binding(self, binding_call: "BindingCall") -> None: func = self._bindings.get(binding_call._initializer["name"]) diff --git a/setup.py b/setup.py index d7c380434..d8b07473d 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ InWheel = None from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand -driver_version = "1.16.0-next-1632960932000" +driver_version = "1.16.0-next-1633339886000" def extractall(zip: zipfile.ZipFile, path: str) -> None: