Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: roll to Playwright 1.26.0-beta-1663620933000 #1555

Merged
merged 4 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -4,9 +4,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->105.0.5195.19<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Chromium <!-- GEN:chromium-version -->106.0.5249.30<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| WebKit <!-- GEN:webkit-version -->16.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->103.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->104.0<!-- GEN:stop --> | ✅ | ✅ | ✅ |

## Documentation

Expand Down
24 changes: 18 additions & 6 deletions playwright/_impl/_assertions.py
Expand Up @@ -458,22 +458,26 @@ async def not_to_be_disabled(

async def to_be_editable(
self,
editable: bool = None,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idiomatically, this should be:

Suggested change
editable: bool = None,
editable: bool = True,

but the our generation/rolling will yell with:

Parameter type mismatch in LocatorAssertions.to_be_enabled(enabled=): documented as Union[bool, None], code has bool

Unless others feel strongly, this will be left as is. (Slightly non-idiomatic Python.)

timeout: float = None,
) -> None:
__tracebackhide__ = True
if editable is None:
editable = True
await self._expect_impl(
"to.be.editable",
"to.be.editable" if editable else "to.be.readonly",
FrameExpectOptions(timeout=timeout),
None,
"Locator expected to be editable",
)

async def not_to_be_editable(
self,
editable: bool = None,
timeout: float = None,
) -> None:
__tracebackhide__ = True
await self._not.to_be_editable(timeout)
await self._not.to_be_editable(editable, timeout)

async def to_be_empty(
self,
Expand All @@ -496,22 +500,26 @@ async def not_to_be_empty(

async def to_be_enabled(
self,
enabled: bool = None,
timeout: float = None,
) -> None:
__tracebackhide__ = True
if enabled is None:
enabled = True
await self._expect_impl(
"to.be.enabled",
"to.be.enabled" if enabled else "to.be.disabled",
FrameExpectOptions(timeout=timeout),
None,
"Locator expected to be enabled",
)

async def not_to_be_enabled(
self,
enabled: bool = None,
timeout: float = None,
) -> None:
__tracebackhide__ = True
await self._not.to_be_enabled(timeout)
await self._not.to_be_enabled(enabled, timeout)

async def to_be_hidden(
self,
Expand All @@ -534,22 +542,26 @@ async def not_to_be_hidden(

async def to_be_visible(
self,
visible: bool = None,
timeout: float = None,
) -> None:
__tracebackhide__ = True
if visible is None:
visible = True
await self._expect_impl(
"to.be.visible",
"to.be.visible" if visible else "to.be.hidden",
FrameExpectOptions(timeout=timeout),
None,
"Locator expected to be visible",
)

async def not_to_be_visible(
self,
visible: bool = None,
timeout: float = None,
) -> None:
__tracebackhide__ = True
await self._not.to_be_visible(timeout)
await self._not.to_be_visible(visible, timeout)

async def to_be_focused(
self,
Expand Down
7 changes: 3 additions & 4 deletions playwright/_impl/_browser_context.py
Expand Up @@ -114,7 +114,6 @@ def __init__(
lambda params: asyncio.create_task(
self._on_route(
from_channel(params.get("route")),
from_channel(params.get("request")),
)
),
)
Expand Down Expand Up @@ -174,15 +173,15 @@ def _on_page(self, page: Page) -> None:
if page._opener and not page._opener.is_closed():
page._opener.emit(Page.Events.Popup, page)

async def _on_route(self, route: Route, request: Request) -> None:
async def _on_route(self, route: Route) -> None:
route_handlers = self._routes.copy()
for route_handler in route_handlers:
if not route_handler.matches(request.url):
if not route_handler.matches(route.request.url):
continue
if route_handler.will_expire:
self._routes.remove(route_handler)
try:
handled = await route_handler.handle(route, request)
handled = await route_handler.handle(route)
finally:
if len(self._routes) == 0:
asyncio.create_task(self._disable_interception())
Expand Down
17 changes: 17 additions & 0 deletions playwright/_impl/_fetch.py
Expand Up @@ -102,6 +102,7 @@ async def delete(
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
maxRedirects: int = None,
) -> "APIResponse":
return await self.fetch(
url,
Expand All @@ -114,6 +115,7 @@ async def delete(
timeout=timeout,
failOnStatusCode=failOnStatusCode,
ignoreHTTPSErrors=ignoreHTTPSErrors,
maxRedirects=maxRedirects,
)

async def head(
Expand All @@ -124,6 +126,7 @@ async def head(
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
maxRedirects: int = None,
) -> "APIResponse":
return await self.fetch(
url,
Expand All @@ -133,6 +136,7 @@ async def head(
timeout=timeout,
failOnStatusCode=failOnStatusCode,
ignoreHTTPSErrors=ignoreHTTPSErrors,
maxRedirects=maxRedirects,
)

async def get(
Expand All @@ -143,6 +147,7 @@ async def get(
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
maxRedirects: int = None,
) -> "APIResponse":
return await self.fetch(
url,
Expand All @@ -152,6 +157,7 @@ async def get(
timeout=timeout,
failOnStatusCode=failOnStatusCode,
ignoreHTTPSErrors=ignoreHTTPSErrors,
maxRedirects=maxRedirects,
)

async def patch(
Expand All @@ -165,6 +171,7 @@ async def patch(
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
maxRedirects: int = None,
) -> "APIResponse":
return await self.fetch(
url,
Expand All @@ -177,6 +184,7 @@ async def patch(
timeout=timeout,
failOnStatusCode=failOnStatusCode,
ignoreHTTPSErrors=ignoreHTTPSErrors,
maxRedirects=maxRedirects,
)

async def put(
Expand All @@ -190,6 +198,7 @@ async def put(
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
maxRedirects: int = None,
) -> "APIResponse":
return await self.fetch(
url,
Expand All @@ -202,6 +211,7 @@ async def put(
timeout=timeout,
failOnStatusCode=failOnStatusCode,
ignoreHTTPSErrors=ignoreHTTPSErrors,
maxRedirects=maxRedirects,
)

async def post(
Expand All @@ -215,6 +225,7 @@ async def post(
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
maxRedirects: int = None,
) -> "APIResponse":
return await self.fetch(
url,
Expand All @@ -227,6 +238,7 @@ async def post(
timeout=timeout,
failOnStatusCode=failOnStatusCode,
ignoreHTTPSErrors=ignoreHTTPSErrors,
maxRedirects=maxRedirects,
)

async def fetch(
Expand All @@ -241,6 +253,7 @@ async def fetch(
timeout: float = None,
failOnStatusCode: bool = None,
ignoreHTTPSErrors: bool = None,
maxRedirects: int = None,
) -> "APIResponse":
request = (
cast(network.Request, to_impl(urlOrRequest))
Expand All @@ -253,6 +266,9 @@ async def fetch(
assert (
(1 if data else 0) + (1 if form else 0) + (1 if multipart else 0)
) <= 1, "Only one of 'data', 'form' or 'multipart' can be specified"
assert (
maxRedirects is None or maxRedirects >= 0
), "'max_redirects' must be greater than or equal to '0'"
url = request.url if request else urlOrRequest
method = method or (request.method if request else "GET")
# Cannot call allHeaders() here as the request may be paused inside route handler.
Expand Down Expand Up @@ -319,6 +335,7 @@ def filter_none(input: Dict) -> Dict:
"timeout": timeout,
"failOnStatusCode": failOnStatusCode,
"ignoreHTTPSErrors": ignoreHTTPSErrors,
"maxRedirects": maxRedirects,
}
),
)
Expand Down
4 changes: 2 additions & 2 deletions playwright/_impl/_helper.py
Expand Up @@ -271,15 +271,15 @@ def __init__(
def matches(self, request_url: str) -> bool:
return self.matcher.matches(request_url)

async def handle(self, route: "Route", request: "Request") -> bool:
async def handle(self, route: "Route") -> bool:
handled_future = route._start_handling()
handler_task = []

def impl() -> None:
self._handled_count += 1
result = cast(
Callable[["Route", "Request"], Union[Coroutine, Any]], self.handler
)(route, request)
)(route, route.request)
if inspect.iscoroutine(result):
handler_task.append(asyncio.create_task(result))

Expand Down
12 changes: 5 additions & 7 deletions playwright/_impl/_page.py
Expand Up @@ -193,9 +193,7 @@ def __init__(
self._channel.on(
"route",
lambda params: asyncio.create_task(
self._on_route(
from_channel(params["route"]), from_channel(params["request"])
)
self._on_route(from_channel(params["route"]))
),
)
self._channel.on("video", lambda params: self._on_video(params))
Expand Down Expand Up @@ -235,21 +233,21 @@ def _on_frame_detached(self, frame: Frame) -> None:
frame._detached = True
self.emit(Page.Events.FrameDetached, frame)

async def _on_route(self, route: Route, request: Request) -> None:
async def _on_route(self, route: Route) -> None:
route_handlers = self._routes.copy()
for route_handler in route_handlers:
if not route_handler.matches(request.url):
if not route_handler.matches(route.request.url):
continue
if route_handler.will_expire:
self._routes.remove(route_handler)
try:
handled = await route_handler.handle(route, request)
handled = await route_handler.handle(route)
finally:
if len(self._routes) == 0:
asyncio.create_task(self._disable_interception())
if handled:
return
await self._browser_context._on_route(route, request)
await self._browser_context._on_route(route)

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