Skip to content

Commit

Permalink
chore: roll Playwright to 1.20 (#1206)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Mar 15, 2022
1 parent 9ad1147 commit 417a5b0
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 67 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
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 -->101.0.4915.0<!-- GEN:stop --> ||||
| Chromium <!-- GEN:chromium-version -->101.0.4929.0<!-- GEN:stop --> ||||
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->96.0.1<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->97.0.1<!-- GEN:stop --> ||||

## Documentation

Expand Down
2 changes: 2 additions & 0 deletions playwright/_impl/_browser_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ async def connect(
if timeout is None:
timeout = 30000

headers = {**(headers if headers else {}), "x-playwright-browser": self.name}

transport = WebSocketTransport(
self._connection._loop, ws_endpoint, headers, slow_mo
)
Expand Down
2 changes: 1 addition & 1 deletion playwright/_impl/_element_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async def screenshot(
path: Union[str, Path] = None,
quality: int = None,
omitBackground: bool = None,
disableAnimations: bool = None,
animations: Literal["disabled"] = None,
mask: List["Locator"] = None,
) -> bytes:
params = locals_to_params(locals())
Expand Down
2 changes: 1 addition & 1 deletion playwright/_impl/_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ async def screenshot(
path: Union[str, pathlib.Path] = None,
quality: int = None,
omitBackground: bool = None,
disableAnimations: bool = None,
animations: Literal["disabled"] = None,
mask: List["Locator"] = None,
) -> bytes:
params = locals_to_params(locals())
Expand Down
2 changes: 1 addition & 1 deletion playwright/_impl/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ async def screenshot(
omitBackground: bool = None,
fullPage: bool = None,
clip: FloatRect = None,
disableAnimations: bool = None,
animations: Literal["disabled"] = None,
mask: List["Locator"] = None,
) -> bytes:
params = locals_to_params(locals())
Expand Down
37 changes: 21 additions & 16 deletions playwright/async_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -2537,7 +2537,7 @@ async def screenshot(
path: typing.Union[str, pathlib.Path] = None,
quality: int = None,
omit_background: bool = None,
disable_animations: bool = None,
animations: Literal["disabled"] = None,
mask: typing.List["Locator"] = None
) -> bytes:
"""ElementHandle.screenshot
Expand All @@ -2563,9 +2563,11 @@ async def screenshot(
omit_background : Union[bool, NoneType]
Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
Defaults to `false`.
disable_animations : Union[bool, NoneType]
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
their duration:
animations : Union["disabled", NoneType]
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
depending on their duration:
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
- infinite animations are canceled to initial state, and then played over after the screenshot.
mask : Union[List[Locator], NoneType]
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
`#FF00FF` that completely covers its bounding box.
Expand All @@ -2584,7 +2586,7 @@ async def screenshot(
path=path,
quality=quality,
omitBackground=omit_background,
disableAnimations=disable_animations,
animations=animations,
mask=mapping.to_impl(mask),
),
)
Expand Down Expand Up @@ -8054,7 +8056,7 @@ async def screenshot(
omit_background: bool = None,
full_page: bool = None,
clip: FloatRect = None,
disable_animations: bool = None,
animations: Literal["disabled"] = None,
mask: typing.List["Locator"] = None
) -> bytes:
"""Page.screenshot
Expand Down Expand Up @@ -8082,9 +8084,11 @@ async def screenshot(
`false`.
clip : Union[{x: float, y: float, width: float, height: float}, NoneType]
An object which specifies clipping of the resulting image. Should have the following fields:
disable_animations : Union[bool, NoneType]
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
their duration:
animations : Union["disabled", NoneType]
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
depending on their duration:
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
- infinite animations are canceled to initial state, and then played over after the screenshot.
mask : Union[List[Locator], NoneType]
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
`#FF00FF` that completely covers its bounding box.
Expand All @@ -8105,7 +8109,7 @@ async def screenshot(
omitBackground=omit_background,
fullPage=full_page,
clip=clip,
disableAnimations=disable_animations,
animations=animations,
mask=mapping.to_impl(mask),
),
)
Expand Down Expand Up @@ -10431,7 +10435,6 @@ async def grant_permissions(
- `'midi'`
- `'midi-sysex'` (system-exclusive midi)
- `'notifications'`
- `'push'`
- `'camera'`
- `'microphone'`
- `'background-sync'`
Expand Down Expand Up @@ -13342,7 +13345,7 @@ async def screenshot(
path: typing.Union[str, pathlib.Path] = None,
quality: int = None,
omit_background: bool = None,
disable_animations: bool = None,
animations: Literal["disabled"] = None,
mask: typing.List["Locator"] = None
) -> bytes:
"""Locator.screenshot
Expand All @@ -13368,9 +13371,11 @@ async def screenshot(
omit_background : Union[bool, NoneType]
Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
Defaults to `false`.
disable_animations : Union[bool, NoneType]
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
their duration:
animations : Union["disabled", NoneType]
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
depending on their duration:
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
- infinite animations are canceled to initial state, and then played over after the screenshot.
mask : Union[List[Locator], NoneType]
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
`#FF00FF` that completely covers its bounding box.
Expand All @@ -13389,7 +13394,7 @@ async def screenshot(
path=path,
quality=quality,
omitBackground=omit_background,
disableAnimations=disable_animations,
animations=animations,
mask=mapping.to_impl(mask),
),
)
Expand Down
37 changes: 21 additions & 16 deletions playwright/sync_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -2486,7 +2486,7 @@ def screenshot(
path: typing.Union[str, pathlib.Path] = None,
quality: int = None,
omit_background: bool = None,
disable_animations: bool = None,
animations: Literal["disabled"] = None,
mask: typing.List["Locator"] = None
) -> bytes:
"""ElementHandle.screenshot
Expand All @@ -2512,9 +2512,11 @@ def screenshot(
omit_background : Union[bool, NoneType]
Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
Defaults to `false`.
disable_animations : Union[bool, NoneType]
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
their duration:
animations : Union["disabled", NoneType]
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
depending on their duration:
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
- infinite animations are canceled to initial state, and then played over after the screenshot.
mask : Union[List[Locator], NoneType]
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
`#FF00FF` that completely covers its bounding box.
Expand All @@ -2533,7 +2535,7 @@ def screenshot(
path=path,
quality=quality,
omitBackground=omit_background,
disableAnimations=disable_animations,
animations=animations,
mask=mapping.to_impl(mask),
),
)
Expand Down Expand Up @@ -7865,7 +7867,7 @@ def screenshot(
omit_background: bool = None,
full_page: bool = None,
clip: FloatRect = None,
disable_animations: bool = None,
animations: Literal["disabled"] = None,
mask: typing.List["Locator"] = None
) -> bytes:
"""Page.screenshot
Expand Down Expand Up @@ -7893,9 +7895,11 @@ def screenshot(
`false`.
clip : Union[{x: float, y: float, width: float, height: float}, NoneType]
An object which specifies clipping of the resulting image. Should have the following fields:
disable_animations : Union[bool, NoneType]
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
their duration:
animations : Union["disabled", NoneType]
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
depending on their duration:
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
- infinite animations are canceled to initial state, and then played over after the screenshot.
mask : Union[List[Locator], NoneType]
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
`#FF00FF` that completely covers its bounding box.
Expand All @@ -7916,7 +7920,7 @@ def screenshot(
omitBackground=omit_background,
fullPage=full_page,
clip=clip,
disableAnimations=disable_animations,
animations=animations,
mask=mapping.to_impl(mask),
),
)
Expand Down Expand Up @@ -10187,7 +10191,6 @@ def grant_permissions(
- `'midi'`
- `'midi-sysex'` (system-exclusive midi)
- `'notifications'`
- `'push'`
- `'camera'`
- `'microphone'`
- `'background-sync'`
Expand Down Expand Up @@ -13062,7 +13065,7 @@ def screenshot(
path: typing.Union[str, pathlib.Path] = None,
quality: int = None,
omit_background: bool = None,
disable_animations: bool = None,
animations: Literal["disabled"] = None,
mask: typing.List["Locator"] = None
) -> bytes:
"""Locator.screenshot
Expand All @@ -13088,9 +13091,11 @@ def screenshot(
omit_background : Union[bool, NoneType]
Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
Defaults to `false`.
disable_animations : Union[bool, NoneType]
When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
their duration:
animations : Union["disabled", NoneType]
When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
depending on their duration:
- finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
- infinite animations are canceled to initial state, and then played over after the screenshot.
mask : Union[List[Locator], NoneType]
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
`#FF00FF` that completely covers its bounding box.
Expand All @@ -13109,7 +13114,7 @@ def screenshot(
path=path,
quality=quality,
omitBackground=omit_background,
disableAnimations=disable_animations,
animations=animations,
mask=mapping.to_impl(mask),
),
)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
InWheel = None
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand

driver_version = "1.20.0-alpha-1646324243000"
driver_version = "1.20.0"


def extractall(zip: zipfile.ZipFile, path: str) -> None:
Expand Down
24 changes: 21 additions & 3 deletions tests/async/test_browsercontext_add_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async def test_should_default_to_setting_secure_cookie_for_https_websites(


async def test_should_be_able_to_set_unsecure_cookie_for_http_website(
context, page, server, is_firefox
context, page, server
):
await page.goto(server.EMPTY_PAGE)
HTTP_URL = "http://example.com"
Expand Down Expand Up @@ -354,7 +354,9 @@ async def test_should_set_cookies_for_a_frame(context, page, server):
assert await page.frames[1].evaluate("document.cookie") == "frame-cookie=value"


async def test_should_not_block_third_party_cookies(context, page, server):
async def test_should_not_block_third_party_cookies(
context, page, server, is_chromium, is_firefox
):
await page.goto(server.EMPTY_PAGE)
await page.evaluate(
"""src => {
Expand All @@ -370,5 +372,21 @@ async def test_should_not_block_third_party_cookies(context, page, server):
)
await page.frames[1].evaluate("document.cookie = 'username=John Doe'")
await page.wait_for_timeout(2000)
allows_third_party = is_firefox
cookies = await context.cookies(server.CROSS_PROCESS_PREFIX + "/grid.html")
assert cookies == []

if allows_third_party:
assert cookies == [
{
"domain": "127.0.0.1",
"expires": -1,
"httpOnly": False,
"name": "username",
"path": "/",
"sameSite": "Lax" if is_chromium else "None",
"secure": False,
"value": "John Doe",
}
]
else:
assert cookies == []
18 changes: 7 additions & 11 deletions tests/async/test_browsercontext_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def test_should_return_no_cookies_in_pristine_browser_context(context):
assert await context.cookies() == []


async def test_should_get_a_cookie(context, page, server, is_chromium, is_firefox):
async def test_should_get_a_cookie(context, page, server, is_chromium):
await page.goto(server.EMPTY_PAGE)
document_cookie = await page.evaluate(
"""() => {
Expand All @@ -39,14 +39,12 @@ async def test_should_get_a_cookie(context, page, server, is_chromium, is_firefo
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "Lax" if (is_chromium or is_firefox) else "None",
"sameSite": "Lax" if is_chromium else "None",
}
]


async def test_should_get_a_non_session_cookie(
context, page, server, is_chromium, is_firefox
):
async def test_should_get_a_non_session_cookie(context, page, server, is_chromium):
await page.goto(server.EMPTY_PAGE)
# @see https://en.wikipedia.org/wiki/Year_2038_problem
date = int(datetime.datetime(2038, 1, 1).timestamp() * 1000)
Expand All @@ -68,7 +66,7 @@ async def test_should_get_a_non_session_cookie(
"expires": date / 1000,
"httpOnly": False,
"secure": False,
"sameSite": "Lax" if (is_chromium or is_firefox) else "None",
"sameSite": "Lax" if is_chromium else "None",
}
]

Expand Down Expand Up @@ -126,9 +124,7 @@ async def test_should_properly_report_lax_sameSite_cookie(
assert cookies[0]["sameSite"] == "Lax"


async def test_should_get_multiple_cookies(
context, page, server, is_chromium, is_firefox
):
async def test_should_get_multiple_cookies(context, page, server, is_chromium):
await page.goto(server.EMPTY_PAGE)
document_cookie = await page.evaluate(
"""() => {
Expand All @@ -149,7 +145,7 @@ async def test_should_get_multiple_cookies(
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "Lax" if (is_chromium or is_firefox) else "None",
"sameSite": "Lax" if is_chromium else "None",
},
{
"name": "username",
Expand All @@ -159,7 +155,7 @@ async def test_should_get_multiple_cookies(
"expires": -1,
"httpOnly": False,
"secure": False,
"sameSite": "Lax" if (is_chromium or is_firefox) else "None",
"sameSite": "Lax" if is_chromium else "None",
},
]

Expand Down
Loading

0 comments on commit 417a5b0

Please sign in to comment.