Skip to content

Commit 287d820

Browse files
authored
chore: roll to Playwright 1.16.0-next-1633339886000 (#932)
1 parent f6ef8a6 commit 287d820

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
44

55
| | Linux | macOS | Windows |
66
| :--- | :---: | :---: | :---: |
7-
| Chromium <!-- GEN:chromium-version -->96.0.4655.0<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->96.0.4659.0<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->15.0<!-- GEN:stop --> ||||
99
| Firefox <!-- GEN:firefox-version -->92.0<!-- GEN:stop --> ||||
1010

playwright/_impl/_browser_context.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,20 @@ def _on_page(self, page: Page) -> None:
149149
page._opener.emit(Page.Events.Popup, page)
150150

151151
def _on_route(self, route: Route, request: Request) -> None:
152+
handled = False
152153
for handler_entry in self._routes:
153154
if handler_entry.matches(request.url):
154155
result = handler_entry.handle(route, request)
155156
if inspect.iscoroutine(result):
156157
asyncio.create_task(result)
157-
return
158-
asyncio.create_task(route.continue_())
158+
handled = True
159+
break
160+
if not handled:
161+
asyncio.create_task(route.continue_())
162+
else:
163+
self._routes = list(
164+
filter(lambda route: route.expired() is False, self._routes)
165+
)
159166

160167
def _on_binding(self, binding_call: BindingCall) -> None:
161168
func = self._bindings.get(binding_call._initializer["name"])

playwright/_impl/_helper.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,15 @@ def __init__(
213213
self._times = times
214214
self._handled_count = 0
215215

216+
def expired(self) -> bool:
217+
return self._times is not None and self._handled_count >= self._times
218+
216219
def matches(self, request_url: str) -> bool:
217-
if self._times and self._handled_count >= self._times:
218-
return False
219220
return self.matcher.matches(request_url)
220221

221222
def handle(self, route: "Route", request: "Request") -> Union[Coroutine, Any]:
222-
self._handled_count += 1
223+
if self._times:
224+
self._handled_count += 1
223225
return cast(
224226
Callable[["Route", "Request"], Union[Coroutine, Any]], self.handler
225227
)(route, request)

playwright/_impl/_page.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,20 @@ def _on_frame_detached(self, frame: Frame) -> None:
212212
self.emit(Page.Events.FrameDetached, frame)
213213

214214
def _on_route(self, route: Route, request: Request) -> None:
215+
handled = False
215216
for handler_entry in self._routes:
216217
if handler_entry.matches(request.url):
217218
result = handler_entry.handle(route, request)
218219
if inspect.iscoroutine(result):
219220
asyncio.create_task(result)
220-
return
221-
self._browser_context._on_route(route, request)
221+
handled = True
222+
break
223+
if not handled:
224+
self._browser_context._on_route(route, request)
225+
else:
226+
self._routes = list(
227+
filter(lambda route: route.expired() is False, self._routes)
228+
)
222229

223230
def _on_binding(self, binding_call: "BindingCall") -> None:
224231
func = self._bindings.get(binding_call._initializer["name"])

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
InWheel = None
2929
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand
3030

31-
driver_version = "1.16.0-next-1632960932000"
31+
driver_version = "1.16.0-next-1633339886000"
3232

3333

3434
def extractall(zip: zipfile.ZipFile, path: str) -> None:

0 commit comments

Comments
 (0)