Skip to content

Commit 9b5e858

Browse files
authored
feat(roll): roll Playwright 1.17.0-next-1635811939000 (microsoft#1003)
1 parent 0a3d7f0 commit 9b5e858

17 files changed

+144
-92
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 -->97.0.4666.0<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->97.0.4681.0<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> ||||
99
| Firefox <!-- GEN:firefox-version -->93.0<!-- GEN:stop --> ||||
1010

playwright/_impl/_artifact.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ def __init__(
2626
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
2727
) -> None:
2828
super().__init__(parent, type, guid, initializer)
29-
self._is_remote = False
3029
self.absolute_path = initializer["absolutePath"]
3130

3231
async def path_after_finished(self) -> Optional[pathlib.Path]:
33-
if self._is_remote:
32+
if self._connection.is_remote:
3433
raise Error(
3534
"Path is not available when using browser_type.connect(). Use save_as() to save a local copy."
3635
)

playwright/_impl/_browser.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ def __init__(
5656
self._browser_type = parent
5757
self._is_connected = True
5858
self._is_closed_or_closing = False
59-
self._is_remote = False
60-
self._is_connected_over_websocket = False
59+
self._should_close_connection_on_close = False
6160

6261
self._contexts: List[BrowserContext] = []
6362
self._channel.on("close", lambda _: self._on_close())
@@ -169,7 +168,7 @@ async def close(self) -> None:
169168
except Exception as e:
170169
if not is_safe_close_error(e):
171170
raise e
172-
if self._is_connected_over_websocket:
171+
if self._should_close_connection_on_close:
173172
await self._connection.stop_async()
174173

175174
@property

playwright/_impl/_browser_context.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,6 @@ async def close(self) -> None:
308308
har = cast(
309309
Artifact, from_channel(await self._channel.send("harExport"))
310310
)
311-
if self.browser and self.browser._is_remote:
312-
har._is_remote = True
313311
await har.save_as(
314312
cast(Dict[str, str], self._options["recordHar"])["path"]
315313
)

playwright/_impl/_browser_type.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ async def connect_over_cdp(
157157
)
158158
response = await self._channel.send_return_as_dict("connectOverCDP", params)
159159
browser = cast(Browser, from_channel(response["browser"]))
160-
browser._is_remote = True
161160

162161
default_context = cast(
163162
Optional[BrowserContext],
@@ -187,6 +186,7 @@ async def connect(
187186
transport,
188187
self._connection._loop,
189188
)
189+
connection.mark_as_remote()
190190
connection._is_sync = self._connection._is_sync
191191
connection._loop.create_task(connection.run())
192192
playwright_future = connection.playwright_future
@@ -205,8 +205,7 @@ async def connect(
205205
pre_launched_browser = playwright._initializer.get("preLaunchedBrowser")
206206
assert pre_launched_browser
207207
browser = cast(Browser, from_channel(pre_launched_browser))
208-
browser._is_remote = True
209-
browser._is_connected_over_websocket = True
208+
browser._should_close_connection_on_close = True
210209

211210
def handle_transport_close() -> None:
212211
for context in browser.contexts:

playwright/_impl/_connection.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ def __init__(
162162
self._loop = loop
163163
self.playwright_future: asyncio.Future["Playwright"] = loop.create_future()
164164
self._error: Optional[BaseException] = None
165+
self.is_remote = False
166+
167+
def mark_as_remote(self) -> None:
168+
self.is_remote = True
165169

166170
async def run_as_sync(self) -> None:
167171
self._is_sync = True

playwright/_impl/_frame.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async def continuation() -> Optional[Response]:
183183
if wait_until not in self._load_states:
184184
t = deadline - monotonic_time()
185185
if t > 0:
186-
await self.wait_for_load_state(state=wait_until, timeout=t)
186+
await self._wait_for_load_state_impl(state=wait_until, timeout=t)
187187
if "newDocument" in event and "request" in event["newDocument"]:
188188
request = from_channel(event["newDocument"]["request"])
189189
return await request.response()
@@ -199,20 +199,29 @@ async def wait_for_url(
199199
) -> None:
200200
matcher = URLMatcher(self._page._browser_context._options.get("baseURL"), url)
201201
if matcher.matches(self.url):
202-
await self.wait_for_load_state(state=wait_until, timeout=timeout)
202+
await self._wait_for_load_state_impl(state=wait_until, timeout=timeout)
203203
return
204204
async with self.expect_navigation(
205205
url=url, wait_until=wait_until, timeout=timeout
206206
):
207207
pass
208208

209209
async def wait_for_load_state(
210+
self,
211+
state: Literal["domcontentloaded", "load", "networkidle"] = None,
212+
timeout: float = None,
213+
) -> None:
214+
return await self._wait_for_load_state_impl(state, timeout)
215+
216+
async def _wait_for_load_state_impl(
210217
self, state: DocumentLoadState = None, timeout: float = None
211218
) -> None:
212219
if not state:
213220
state = "load"
214-
if state not in ("load", "domcontentloaded", "networkidle"):
215-
raise Error("state: expected one of (load|domcontentloaded|networkidle)")
221+
if state not in ("load", "domcontentloaded", "networkidle", "commit"):
222+
raise Error(
223+
"state: expected one of (load|domcontentloaded|networkidle|commit)"
224+
)
216225
if state in self._load_states:
217226
return
218227
wait_helper = self._setup_navigation_wait_helper("wait_for_load_state", timeout)

playwright/_impl/_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
ColorScheme = Literal["dark", "light", "no-preference"]
6060
ForcedColors = Literal["active", "none"]
6161
ReducedMotion = Literal["no-preference", "reduce"]
62-
DocumentLoadState = Literal["domcontentloaded", "load", "networkidle"]
62+
DocumentLoadState = Literal["commit", "domcontentloaded", "load", "networkidle"]
6363
KeyboardModifier = Literal["Alt", "Control", "Meta", "Shift"]
6464
MouseButton = Literal["left", "middle", "right"]
6565

playwright/_impl/_page.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,6 @@ def _on_download(self, params: Any) -> None:
257257
url = params["url"]
258258
suggested_filename = params["suggestedFilename"]
259259
artifact = cast(Artifact, from_channel(params["artifact"]))
260-
if self._browser_context._browser:
261-
artifact._is_remote = self._browser_context._browser._is_remote
262260
self.emit(
263261
Page.Events.Download, Download(self, url, suggested_filename, artifact)
264262
)
@@ -477,7 +475,9 @@ async def reload(
477475
)
478476

479477
async def wait_for_load_state(
480-
self, state: DocumentLoadState = None, timeout: float = None
478+
self,
479+
state: Literal["domcontentloaded", "load", "networkidle"] = None,
480+
timeout: float = None,
481481
) -> None:
482482
return await self._main_frame.wait_for_load_state(**locals_to_params(locals()))
483483

playwright/_impl/_tracing.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,19 @@ async def stop(self, path: Union[pathlib.Path, str] = None) -> None:
4848
await self._channel.send("tracingStop")
4949

5050
async def _do_stop_chunk(self, path: Union[pathlib.Path, str] = None) -> None:
51+
result = await self._channel.send_return_as_dict(
52+
"tracingStopChunk",
53+
{
54+
"save": bool(path),
55+
"skipCompress": False,
56+
},
57+
)
5158
artifact = cast(
5259
Optional[Artifact],
53-
from_nullable_channel(
54-
await self._channel.send(
55-
"tracingStopChunk",
56-
{
57-
"save": bool(path),
58-
},
59-
)
60-
),
60+
from_nullable_channel(result.get("artifact")),
6161
)
6262
if not artifact:
6363
return
64-
if self._context._browser:
65-
artifact._is_remote = self._context._browser._is_remote
6664
if path:
6765
await artifact.save_as(path)
6866
await artifact.delete()

0 commit comments

Comments
 (0)