Skip to content

Commit 4916ba2

Browse files
authored
chore: roll driver (#838)
1 parent 94f7269 commit 4916ba2

17 files changed

+165
-60
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
1111

1212
| | Linux | macOS | Windows |
1313
| :--- | :---: | :---: | :---: |
14-
| Chromium <!-- GEN:chromium-version -->101.0.4915.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
14+
| Chromium <!-- GEN:chromium-version -->101.0.4929.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1515
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> ||||
16-
| Firefox <!-- GEN:firefox-version -->96.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
16+
| Firefox <!-- GEN:firefox-version -->97.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1717

1818
Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/java/docs/next/intro/#system-requirements) for details.
1919

playwright/src/main/java/com/microsoft/playwright/ElementHandle.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,14 @@ public PressOptions setTimeout(double timeout) {
570570
}
571571
class ScreenshotOptions {
572572
/**
573-
* When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
574-
* their duration:
573+
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
574+
* depending on their duration:
575+
* <ul>
576+
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
577+
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
578+
* </ul>
575579
*/
576-
public Boolean disableAnimations;
580+
public ScreenshotAnimations animations;
577581
/**
578582
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
579583
* {@code #FF00FF} that completely covers its bounding box.
@@ -606,11 +610,15 @@ class ScreenshotOptions {
606610
public ScreenshotType type;
607611

608612
/**
609-
* When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
610-
* their duration:
613+
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
614+
* depending on their duration:
615+
* <ul>
616+
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
617+
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
618+
* </ul>
611619
*/
612-
public ScreenshotOptions setDisableAnimations(boolean disableAnimations) {
613-
this.disableAnimations = disableAnimations;
620+
public ScreenshotOptions setAnimations(ScreenshotAnimations animations) {
621+
this.animations = animations;
614622
return this;
615623
}
616624
/**

playwright/src/main/java/com/microsoft/playwright/Locator.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -950,10 +950,14 @@ public PressOptions setTimeout(double timeout) {
950950
}
951951
class ScreenshotOptions {
952952
/**
953-
* When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
954-
* their duration:
953+
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
954+
* depending on their duration:
955+
* <ul>
956+
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
957+
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
958+
* </ul>
955959
*/
956-
public Boolean disableAnimations;
960+
public ScreenshotAnimations animations;
957961
/**
958962
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlayed with a pink box
959963
* {@code #FF00FF} that completely covers its bounding box.
@@ -986,11 +990,15 @@ class ScreenshotOptions {
986990
public ScreenshotType type;
987991

988992
/**
989-
* When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
990-
* their duration:
993+
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
994+
* depending on their duration:
995+
* <ul>
996+
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
997+
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
998+
* </ul>
991999
*/
992-
public ScreenshotOptions setDisableAnimations(boolean disableAnimations) {
993-
this.disableAnimations = disableAnimations;
1000+
public ScreenshotOptions setAnimations(ScreenshotAnimations animations) {
1001+
this.animations = animations;
9941002
return this;
9951003
}
9961004
/**

playwright/src/main/java/com/microsoft/playwright/Page.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,14 +1977,18 @@ public RouteOptions setTimes(int times) {
19771977
}
19781978
class ScreenshotOptions {
19791979
/**
1980-
* An object which specifies clipping of the resulting image. Should have the following fields:
1980+
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
1981+
* depending on their duration:
1982+
* <ul>
1983+
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
1984+
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
1985+
* </ul>
19811986
*/
1982-
public Clip clip;
1987+
public ScreenshotAnimations animations;
19831988
/**
1984-
* When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
1985-
* their duration:
1989+
* An object which specifies clipping of the resulting image. Should have the following fields:
19861990
*/
1987-
public Boolean disableAnimations;
1991+
public Clip clip;
19881992
/**
19891993
* When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
19901994
* {@code false}.
@@ -2021,6 +2025,18 @@ class ScreenshotOptions {
20212025
*/
20222026
public ScreenshotType type;
20232027

2028+
/**
2029+
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment
2030+
* depending on their duration:
2031+
* <ul>
2032+
* <li> finite animations are fast-forwarded to completion, so they'll fire {@code transitionend} event.</li>
2033+
* <li> infinite animations are canceled to initial state, and then played over after the screenshot.</li>
2034+
* </ul>
2035+
*/
2036+
public ScreenshotOptions setAnimations(ScreenshotAnimations animations) {
2037+
this.animations = animations;
2038+
return this;
2039+
}
20242040
/**
20252041
* An object which specifies clipping of the resulting image. Should have the following fields:
20262042
*/
@@ -2034,14 +2050,6 @@ public ScreenshotOptions setClip(Clip clip) {
20342050
this.clip = clip;
20352051
return this;
20362052
}
2037-
/**
2038-
* When true, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on
2039-
* their duration:
2040-
*/
2041-
public ScreenshotOptions setDisableAnimations(boolean disableAnimations) {
2042-
this.disableAnimations = disableAnimations;
2043-
return this;
2044-
}
20452053
/**
20462054
* When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
20472055
* {@code false}.

playwright/src/main/java/com/microsoft/playwright/impl/Serialization.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Serialization {
4040
.registerTypeAdapter(Media.class, new ToLowerCaseSerializer<Media>())
4141
.registerTypeAdapter(ForcedColors.class, new ToLowerCaseSerializer<ForcedColors>())
4242
.registerTypeAdapter(ReducedMotion.class, new ToLowerCaseAndDashSerializer<ReducedMotion>())
43+
.registerTypeAdapter(ScreenshotAnimations.class, new ToLowerCaseSerializer<ScreenshotAnimations>())
4344
.registerTypeAdapter(ScreenshotType.class, new ToLowerCaseSerializer<ScreenshotType>())
4445
.registerTypeAdapter(MouseButton.class, new ToLowerCaseSerializer<MouseButton>())
4546
.registerTypeAdapter(LoadState.class, new ToLowerCaseSerializer<LoadState>())
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.microsoft.playwright.options;
18+
19+
public enum ScreenshotAnimations {
20+
DISABLED
21+
}

playwright/src/test/java/com/microsoft/playwright/TestBrowserContextAddCookies.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,21 @@ void shouldNotBlockThirdPartyCookies() {
346346
"}", server.CROSS_PROCESS_PREFIX + "/grid.html");
347347
page.frames().get(1).evaluate("document.cookie = 'username=John Doe'");
348348
page.waitForTimeout(2000);
349+
boolean allowsThirdParty = isFirefox();
349350
List<Cookie> cookies = context.cookies(server.CROSS_PROCESS_PREFIX + "/grid.html");
350-
assertEquals(0, cookies.size());
351+
if (allowsThirdParty) {
352+
assertJsonEquals("[{\n" +
353+
" 'domain': '127.0.0.1',\n" +
354+
" 'expires': -1,\n" +
355+
" 'httpOnly': false,\n" +
356+
" 'name': 'username',\n" +
357+
" 'path': '/',\n" +
358+
" 'sameSite': 'NONE',\n" +
359+
" 'secure': false,\n" +
360+
" 'value': 'John Doe'\n" +
361+
"}]", cookies);
362+
} else {
363+
assertEquals(0, cookies.size());
364+
}
351365
}
352366
}

playwright/src/test/java/com/microsoft/playwright/TestBrowserContextCookies.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void shouldGetACookie() {
5050
" expires: -1,\n" +
5151
" httpOnly: false,\n" +
5252
" secure: false,\n" +
53-
" sameSite: '" + (isChromium() || isFirefox() ? "LAX" : "NONE") +"'\n" +
53+
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
5454
" }]", cookies);
5555
}
5656

@@ -74,7 +74,7 @@ void shouldGetANonSessionCookie() {
7474
assertEquals(timestamp, cookie.expires);
7575
assertEquals(false, cookie.httpOnly);
7676
assertEquals(false, cookie.secure);
77-
if (isChromium() || isFirefox()) {
77+
if (isChromium()) {
7878
assertEquals(SameSiteAttribute.LAX, cookie.sameSite);
7979
} else {
8080
assertEquals(SameSiteAttribute.NONE, cookie.sameSite);
@@ -146,7 +146,7 @@ void shouldGetMultipleCookies() {
146146
" expires: -1,\n" +
147147
" httpOnly: false,\n" +
148148
" secure: false,\n" +
149-
" sameSite: '" + (isChromium() || isFirefox() ? "LAX" : "NONE") +"'\n" +
149+
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
150150
" },\n" +
151151
" {\n" +
152152
" name: 'username',\n" +
@@ -156,7 +156,7 @@ void shouldGetMultipleCookies() {
156156
" expires: -1,\n" +
157157
" httpOnly: false,\n" +
158158
" secure: false,\n" +
159-
" sameSite: '" + (isChromium() || isFirefox() ? "LAX" : "NONE") +"'\n" +
159+
" sameSite: '" + (isChromium() ? "LAX" : "NONE") +"'\n" +
160160
" }\n" +
161161
"]", cookies);
162162
}

playwright/src/test/java/com/microsoft/playwright/TestBrowserContextNetworkEvents.java

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.microsoft.playwright;
1818

19+
import com.sun.net.httpserver.Filter;
1920
import org.junit.jupiter.api.Test;
2021

2122
import java.util.ArrayList;
@@ -33,10 +34,19 @@ void BrowserContextEventsRequest() {
3334
page.setContent("<a target=_blank rel=noopener href='/one-style.html'>yo</a>");
3435
Page page1 = context.waitForPage(() -> page.click("a"));
3536
page1.waitForLoadState();
36-
assertEquals(asList(
37-
server.EMPTY_PAGE,
38-
server.PREFIX + "/one-style.html",
39-
server.PREFIX + "/one-style.css"), requests);
37+
// In firefox one-style.css is requested multiple times.
38+
if (isFirefox()) {
39+
assertEquals(asList(
40+
server.EMPTY_PAGE,
41+
server.PREFIX + "/one-style.html",
42+
server.PREFIX + "/one-style.css",
43+
server.PREFIX + "/one-style.css"), requests);
44+
} else {
45+
assertEquals(asList(
46+
server.EMPTY_PAGE,
47+
server.PREFIX + "/one-style.html",
48+
server.PREFIX + "/one-style.css"), requests);
49+
}
4050
}
4151

4252
@Test
@@ -47,10 +57,19 @@ void BrowserContextEventsResponse() {
4757
page.setContent("<a target=_blank rel=noopener href='/one-style.html'>yo</a>");
4858
Page page1 = context.waitForPage(() -> page.click("a"));
4959
page1.waitForLoadState();
50-
assertEquals(asList(
51-
server.EMPTY_PAGE,
52-
server.PREFIX + "/one-style.html",
53-
server.PREFIX + "/one-style.css"), responses);
60+
// In firefox one-style.css is requested multiple times.
61+
if (isFirefox()) {
62+
assertEquals(asList(
63+
server.EMPTY_PAGE,
64+
server.PREFIX + "/one-style.html",
65+
server.PREFIX + "/one-style.css",
66+
server.PREFIX + "/one-style.css"), responses);
67+
} else {
68+
assertEquals(asList(
69+
server.EMPTY_PAGE,
70+
server.PREFIX + "/one-style.html",
71+
server.PREFIX + "/one-style.css"), responses);
72+
}
5473
}
5574

5675
@Test
@@ -59,7 +78,12 @@ void BrowserContextEventsRequestFailed() {
5978
List<Request> failedRequests = new ArrayList<>();
6079
context.onRequestFailed(request -> failedRequests.add(request));
6180
page.navigate(server.PREFIX + "/one-style.html");
62-
assertEquals(1, failedRequests.size());
81+
// In firefox one-style.css is requested multiple times.
82+
if (isFirefox()) {
83+
assertTrue(failedRequests.size() > 0);
84+
} else {
85+
assertEquals(1, failedRequests.size());
86+
}
6387
assertTrue(failedRequests.get(0).url().contains("one-style.css"));
6488
assertNull(failedRequests.get(0).response());
6589
assertEquals("stylesheet", failedRequests.get(0).resourceType());

playwright/src/test/java/com/microsoft/playwright/TestBrowserContextRoute.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ void shouldSupportTheTimesParameterWithRouteMatching() {
140140

141141
@Test
142142
void shouldOverwritePostBodyWithEmptyString() throws ExecutionException, InterruptedException {
143+
boolean[] routeHandled = {false};
143144
context.route("**/empty.html", route -> {
144145
route.resume(new Route.ResumeOptions().setPostData(""));
146+
routeHandled[0] = true;
145147
});
146148

147149
Future<Server.Request> req = server.futureRequest("/empty.html");
@@ -153,7 +155,9 @@ void shouldOverwritePostBodyWithEmptyString() throws ExecutionException, Interru
153155
" });\n" +
154156
" })()\n" +
155157
" </script>");
156-
158+
while (!routeHandled[0]) {
159+
page.waitForTimeout(100);
160+
}
157161
byte[] body = req.get().postBody;
158162
assertEquals(0, body.length);
159163
}

0 commit comments

Comments
 (0)