Skip to content

Commit cc5579c

Browse files
authored
chore(roll): roll Playwright to 1.28.0-alpha-nov-11-2022 (microsoft#1642)
1 parent bb8fce9 commit cc5579c

20 files changed

+57
-436
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 -->108.0.5359.22<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->108.0.5359.29<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->16.0<!-- GEN:stop --> ||||
99
| Firefox <!-- GEN:firefox-version -->106.0<!-- GEN:stop --> ||||
1010

playwright/_impl/_browser_context.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ def __init__(
163163
self.once(
164164
self.Events.Close, lambda context: self._closed_future.set_result(True)
165165
)
166+
self._set_event_to_subscription_mapping(
167+
{
168+
BrowserContext.Events.Request: "request",
169+
BrowserContext.Events.Response: "response",
170+
BrowserContext.Events.RequestFinished: "requestFinished",
171+
BrowserContext.Events.RequestFailed: "requestFailed",
172+
}
173+
)
166174

167175
def __repr__(self) -> str:
168176
return f"<BrowserContext browser={self.browser}>"

playwright/_impl/_connection.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def __init__(
119119
if self._parent:
120120
self._parent._objects[guid] = self
121121

122+
self._event_to_subscription_mapping: Dict[str, str] = {}
123+
122124
def _dispose(self) -> None:
123125
# Clean up from parent and connection.
124126
if self._parent:
@@ -135,6 +137,26 @@ def _adopt(self, child: "ChannelOwner") -> None:
135137
self._objects[child._guid] = child
136138
child._parent = self
137139

140+
def _set_event_to_subscription_mapping(self, mapping: Dict[str, str]) -> None:
141+
self._event_to_subscription_mapping = mapping
142+
143+
def _update_subscription(self, event: str, enabled: bool) -> None:
144+
protocol_event = self._event_to_subscription_mapping.get(event)
145+
if protocol_event:
146+
self._channel.send_no_reply(
147+
"updateSubscription", {"event": protocol_event, "enabled": enabled}
148+
)
149+
150+
def _add_event_handler(self, event: str, k: Any, v: Any) -> None:
151+
if not self.listeners(event):
152+
self._update_subscription(event, True)
153+
super()._add_event_handler(event, k, v)
154+
155+
def remove_listener(self, event: str, f: Any) -> None:
156+
super().remove_listener(event, f)
157+
if not self.listeners(event):
158+
self._update_subscription(event, False)
159+
138160

139161
class ProtocolCallback:
140162
def __init__(self, loop: asyncio.AbstractEventLoop) -> None:

playwright/_impl/_element_handle.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,6 @@ async def type(
218218
) -> None:
219219
await self._channel.send("type", locals_to_params(locals()))
220220

221-
async def clear(
222-
self,
223-
timeout: float = None,
224-
noWaitAfter: bool = None,
225-
force: bool = None,
226-
) -> None:
227-
await self.fill("", **locals_to_params(locals()))
228-
229221
async def press(
230222
self,
231223
key: str,

playwright/_impl/_frame.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -794,22 +794,5 @@ async def set_checked(
794794
trial=trial,
795795
)
796796

797-
async def clear(
798-
self,
799-
selector: str,
800-
timeout: float = None,
801-
noWaitAfter: bool = None,
802-
force: bool = None,
803-
strict: bool = None,
804-
) -> None:
805-
await self.fill(
806-
selector,
807-
"",
808-
timeout=timeout,
809-
noWaitAfter=noWaitAfter,
810-
force=force,
811-
strict=strict,
812-
)
813-
814797
async def _highlight(self, selector: str) -> None:
815798
await self._channel.send("highlight", {"selector": selector})

playwright/_impl/_page.py

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,16 @@ def __init__(
221221
else None,
222222
)
223223

224+
self._set_event_to_subscription_mapping(
225+
{
226+
Page.Events.Request: "request",
227+
Page.Events.Response: "response",
228+
Page.Events.RequestFinished: "requestFinished",
229+
Page.Events.RequestFailed: "requestFailed",
230+
Page.Events.FileChooser: "fileChooser",
231+
}
232+
)
233+
224234
def __repr__(self) -> str:
225235
return f"<Page url={self.url!r}>"
226236

@@ -294,20 +304,6 @@ def _on_video(self, params: Any) -> None:
294304
artifact = from_channel(params["artifact"])
295305
cast(Video, self.video)._artifact_ready(artifact)
296306

297-
def _add_event_handler(self, event: str, k: Any, v: Any) -> None:
298-
if event == Page.Events.FileChooser and len(self.listeners(event)) == 0:
299-
self._channel.send_no_reply(
300-
"setFileChooserInterceptedNoReply", {"intercepted": True}
301-
)
302-
super()._add_event_handler(event, k, v)
303-
304-
def remove_listener(self, event: str, f: Any) -> None:
305-
super().remove_listener(event, f)
306-
if event == Page.Events.FileChooser and len(self.listeners(event)) == 0:
307-
self._channel.send_no_reply(
308-
"setFileChooserInterceptedNoReply", {"intercepted": False}
309-
)
310-
311307
@property
312308
def context(self) -> "BrowserContext":
313309
return self._browser_context
@@ -545,12 +541,14 @@ async def go_forward(
545541

546542
async def emulate_media(
547543
self,
548-
media: Literal["print", "screen"] = None,
544+
media: Literal["null", "print", "screen"] = None,
549545
colorScheme: ColorScheme = None,
550546
reducedMotion: ReducedMotion = None,
551547
forcedColors: ForcedColors = None,
552548
) -> None:
553549
params = locals_to_params(locals())
550+
if "media" in params:
551+
params["media"] = "no-override" if params["media"] == "null" else media
554552
if "colorScheme" in params:
555553
params["colorScheme"] = (
556554
"no-override" if params["colorScheme"] == "null" else colorScheme
@@ -741,23 +739,6 @@ async def fill(
741739
) -> None:
742740
return await self._main_frame.fill(**locals_to_params(locals()))
743741

744-
async def clear(
745-
self,
746-
selector: str,
747-
timeout: float = None,
748-
noWaitAfter: bool = None,
749-
force: bool = None,
750-
strict: bool = None,
751-
) -> None:
752-
await self.fill(
753-
selector,
754-
"",
755-
timeout=timeout,
756-
noWaitAfter=noWaitAfter,
757-
force=force,
758-
strict=strict,
759-
)
760-
761742
def locator(
762743
self,
763744
selector: str,

playwright/async_api/_generated.py

Lines changed: 3 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,42 +2228,6 @@ async def type(
22282228
)
22292229
)
22302230

2231-
async def clear(
2232-
self,
2233-
*,
2234-
timeout: typing.Optional[float] = None,
2235-
no_wait_after: typing.Optional[bool] = None,
2236-
force: typing.Optional[bool] = None
2237-
) -> None:
2238-
"""ElementHandle.clear
2239-
2240-
This method waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the element, clears it and triggers an
2241-
`input` event after clearing.
2242-
2243-
If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
2244-
However, if the element is inside the `<label>` element that has an associated
2245-
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be cleared
2246-
instead.
2247-
2248-
Parameters
2249-
----------
2250-
timeout : Union[float, None]
2251-
Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
2252-
using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods.
2253-
no_wait_after : Union[bool, None]
2254-
Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
2255-
opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
2256-
inaccessible pages. Defaults to `false`.
2257-
force : Union[bool, None]
2258-
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
2259-
"""
2260-
2261-
return mapping.from_maybe_impl(
2262-
await self._impl_obj.clear(
2263-
timeout=timeout, noWaitAfter=no_wait_after, force=force
2264-
)
2265-
)
2266-
22672231
async def press(
22682232
self,
22692233
key: str,
@@ -5575,54 +5539,6 @@ async def set_checked(
55755539
)
55765540
)
55775541

5578-
async def clear(
5579-
self,
5580-
selector: str,
5581-
*,
5582-
timeout: typing.Optional[float] = None,
5583-
no_wait_after: typing.Optional[bool] = None,
5584-
force: typing.Optional[bool] = None,
5585-
strict: typing.Optional[bool] = None
5586-
) -> None:
5587-
"""Frame.clear
5588-
5589-
This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the
5590-
element, clears it and triggers an `input` event after clearing.
5591-
5592-
If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
5593-
However, if the element is inside the `<label>` element that has an associated
5594-
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be cleared
5595-
instead.
5596-
5597-
Parameters
5598-
----------
5599-
selector : str
5600-
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See
5601-
[working with selectors](../selectors.md) for more details.
5602-
timeout : Union[float, None]
5603-
Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
5604-
using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods.
5605-
no_wait_after : Union[bool, None]
5606-
Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
5607-
opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
5608-
inaccessible pages. Defaults to `false`.
5609-
force : Union[bool, None]
5610-
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
5611-
strict : Union[bool, None]
5612-
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
5613-
element, the call throws an exception.
5614-
"""
5615-
5616-
return mapping.from_maybe_impl(
5617-
await self._impl_obj.clear(
5618-
selector=selector,
5619-
timeout=timeout,
5620-
noWaitAfter=no_wait_after,
5621-
force=force,
5622-
strict=strict,
5623-
)
5624-
)
5625-
56265542

56275543
mapping.register(FrameImpl, Frame)
56285544

@@ -8499,7 +8415,7 @@ async def go_forward(
84998415
async def emulate_media(
85008416
self,
85018417
*,
8502-
media: typing.Optional[Literal["print", "screen"]] = None,
8418+
media: typing.Optional[Literal["null", "print", "screen"]] = None,
85038419
color_scheme: typing.Optional[
85048420
Literal["dark", "light", "no-preference", "null"]
85058421
] = None,
@@ -8544,8 +8460,8 @@ async def emulate_media(
85448460

85458461
Parameters
85468462
----------
8547-
media : Union["print", "screen", None]
8548-
Changes the CSS media type of the page. The only allowed values are `'screen'`, `'print'` and `null`. Passing `null`
8463+
media : Union["null", "print", "screen", None]
8464+
Changes the CSS media type of the page. The only allowed values are `'Screen'`, `'Print'` and `'Null'`. Passing `'Null'`
85498465
disables CSS media emulation.
85508466
color_scheme : Union["dark", "light", "no-preference", "null", None]
85518467
Emulates `'prefers-colors-scheme'` media feature, supported values are `'light'`, `'dark'`, `'no-preference'`. Passing
@@ -9204,55 +9120,6 @@ async def fill(
92049120
)
92059121
)
92069122

9207-
async def clear(
9208-
self,
9209-
selector: str,
9210-
*,
9211-
timeout: typing.Optional[float] = None,
9212-
no_wait_after: typing.Optional[bool] = None,
9213-
force: typing.Optional[bool] = None,
9214-
strict: typing.Optional[bool] = None
9215-
) -> None:
9216-
"""Page.clear
9217-
9218-
This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/python/docs/actionability) checks, focuses the
9219-
element, clears it and triggers an `input` event after clearing. Note that you can pass an empty string to clear the
9220-
input field.
9221-
9222-
If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
9223-
However, if the element is inside the `<label>` element that has an associated
9224-
[control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be cleared
9225-
instead.
9226-
9227-
Parameters
9228-
----------
9229-
selector : str
9230-
A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See
9231-
[working with selectors](../selectors.md) for more details.
9232-
timeout : Union[float, None]
9233-
Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
9234-
using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods.
9235-
no_wait_after : Union[bool, None]
9236-
Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
9237-
opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
9238-
inaccessible pages. Defaults to `false`.
9239-
force : Union[bool, None]
9240-
Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
9241-
strict : Union[bool, None]
9242-
When true, the call requires selector to resolve to a single element. If given selector resolves to more than one
9243-
element, the call throws an exception.
9244-
"""
9245-
9246-
return mapping.from_maybe_impl(
9247-
await self._impl_obj.clear(
9248-
selector=selector,
9249-
timeout=timeout,
9250-
noWaitAfter=no_wait_after,
9251-
force=force,
9252-
strict=strict,
9253-
)
9254-
)
9255-
92569123
def locator(
92579124
self,
92589125
selector: str,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy