MCPcopy
hub / github.com/microsoft/playwright-python / _on_route

Method _on_route

playwright/_impl/_page.py:294–325  ·  view source on GitHub ↗
(self, route: Route)

Source from the content-addressed store, hash-verified

292 self._browser_context.emit("framedetached", frame)
293
294 async def _on_route(self, route: Route) -> None:
295 route._context = self.context
296 route_handlers = self._routes.copy()
297 for route_handler in route_handlers:
298 # If the page was closed we stall all requests right away.
299 if self._close_was_called or self.context._closing_or_closed:
300 return
301 if not route_handler.matches(route.request.url):
302 continue
303 if route_handler not in self._routes:
304 continue
305 if route_handler.will_expire:
306 self._routes.remove(route_handler)
307 try:
308 handled = await route_handler.handle(route)
309 finally:
310 if len(self._routes) == 0:
311
312 async def _update_interceptor_patterns_ignore_exceptions() -> None:
313 try:
314 await self._update_interception_patterns()
315 except Error:
316 pass
317
318 asyncio.create_task(
319 self._connection.wrap_api_call(
320 _update_interceptor_patterns_ignore_exceptions, True
321 )
322 )
323 if handled:
324 return
325 await self._browser_context._on_route(route)
326
327 async def _on_web_socket_route(self, web_socket_route: WebSocketRoute) -> None:
328 route_handler = next(

Callers 1

__init__Method · 0.95

Calls 4

copyMethod · 0.80
wrap_api_callMethod · 0.80
matchesMethod · 0.45
handleMethod · 0.45

Tested by

no test coverage detected