Skip to content

Commit b5c2160

Browse files
authored
chore: roll to 1.58.0 (#1883)
1 parent 63bb008 commit b5c2160

File tree

11 files changed

+69
-75
lines changed

11 files changed

+69
-75
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: playwright-roll
3+
description: Roll Playwright Java to a new version
4+
---
5+
6+
Help the user roll to a new version of Playwright.
7+
ROLLING.md contains general instructions and scripts.
8+
9+
Start with updating the version and generating the API to see the state of things.
10+
Afterwards, work through the list of changes that need to be backported.
11+
You can find a list of pull requests that might need to be taking into account in the issue titled "Backport changes".
12+
Work through them one-by-one and check off the items that you have handled.
13+
Not all of them will be relevant, some might have partially been reverted, etc. - so feel free to check with the upstream release branch.
14+
15+
Rolling includes:
16+
- updating client implementation to match changes in the upstream JS implementation (see ../playwright/packages/playwright-core/src/client)
17+
- adding a couple of new tests to verify new/changed functionality
18+
19+
## Tips & Tricks
20+
- Project checkouts are in the parent directory (`../`).
21+
- When updating checkboxes, store the issue content into /tmp and edit it there, then update the issue based on the file
22+
- use the "gh" cli to interact with GitHub

README.md

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

1111
| | Linux | macOS | Windows |
1212
| :--- | :---: | :---: | :---: |
13-
| Chromium <!-- GEN:chromium-version -->143.0.7499.4<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
13+
| Chromium <!-- GEN:chromium-version -->145.0.7632.6<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1414
| WebKit <!-- GEN:webkit-version -->26.0<!-- GEN:stop --> ||||
15-
| Firefox <!-- GEN:firefox-version -->144.0.2<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
15+
| Firefox <!-- GEN:firefox-version -->146.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1616

1717
## Documentation
1818

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<name>Playwright Client Examples</name>
1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<playwright.version>1.57.0</playwright.version>
13+
<playwright.version>1.58.0</playwright.version>
1414
</properties>
1515
<dependencies>
1616
<dependency>

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

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ class ConnectOverCDPOptions {
128128
* Additional HTTP headers to be sent with connect request. Optional.
129129
*/
130130
public Map<String, String> headers;
131+
/**
132+
* Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely upon
133+
* the file system being the same between Playwright and the Browser.
134+
*/
135+
public Boolean isLocal;
131136
/**
132137
* Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
133138
* Defaults to 0.
@@ -146,6 +151,14 @@ public ConnectOverCDPOptions setHeaders(Map<String, String> headers) {
146151
this.headers = headers;
147152
return this;
148153
}
154+
/**
155+
* Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely upon
156+
* the file system being the same between Playwright and the Browser.
157+
*/
158+
public ConnectOverCDPOptions setIsLocal(boolean isLocal) {
159+
this.isLocal = isLocal;
160+
return this;
161+
}
149162
/**
150163
* Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
151164
* Defaults to 0.
@@ -186,10 +199,6 @@ class LaunchOptions {
186199
* Enable Chromium sandboxing. Defaults to {@code false}.
187200
*/
188201
public Boolean chromiumSandbox;
189-
/**
190-
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
191-
*/
192-
public Boolean devtools;
193202
/**
194203
* If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is
195204
* deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in
@@ -229,8 +238,7 @@ class LaunchOptions {
229238
/**
230239
* Whether to run browser in headless mode. More details for <a
231240
* href="https://developers.google.com/web/updates/2017/04/headless-chrome">Chromium</a> and <a
232-
* href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox</a>. Defaults to {@code true} unless
233-
* the {@code devtools} option is {@code true}.
241+
* href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox</a>. Defaults to {@code true}.
234242
*/
235243
public Boolean headless;
236244
/**
@@ -307,13 +315,6 @@ public LaunchOptions setChromiumSandbox(boolean chromiumSandbox) {
307315
this.chromiumSandbox = chromiumSandbox;
308316
return this;
309317
}
310-
/**
311-
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
312-
*/
313-
public LaunchOptions setDevtools(boolean devtools) {
314-
this.devtools = devtools;
315-
return this;
316-
}
317318
/**
318319
* If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is
319320
* deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in
@@ -374,8 +375,7 @@ public LaunchOptions setHandleSIGTERM(boolean handleSIGTERM) {
374375
/**
375376
* Whether to run browser in headless mode. More details for <a
376377
* href="https://developers.google.com/web/updates/2017/04/headless-chrome">Chromium</a> and <a
377-
* href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox</a>. Defaults to {@code true} unless
378-
* the {@code devtools} option is {@code true}.
378+
* href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox</a>. Defaults to {@code true}.
379379
*/
380380
public LaunchOptions setHeadless(boolean headless) {
381381
this.headless = headless;
@@ -518,10 +518,6 @@ class LaunchPersistentContextOptions {
518518
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
519519
*/
520520
public Double deviceScaleFactor;
521-
/**
522-
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
523-
*/
524-
public Boolean devtools;
525521
/**
526522
* If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is
527523
* deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in
@@ -577,8 +573,7 @@ class LaunchPersistentContextOptions {
577573
/**
578574
* Whether to run browser in headless mode. More details for <a
579575
* href="https://developers.google.com/web/updates/2017/04/headless-chrome">Chromium</a> and <a
580-
* href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox</a>. Defaults to {@code true} unless
581-
* the {@code devtools} option is {@code true}.
576+
* href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox</a>. Defaults to {@code true}.
582577
*/
583578
public Boolean headless;
584579
/**
@@ -856,13 +851,6 @@ public LaunchPersistentContextOptions setDeviceScaleFactor(double deviceScaleFac
856851
this.deviceScaleFactor = deviceScaleFactor;
857852
return this;
858853
}
859-
/**
860-
* @deprecated Use <a href="https://playwright.dev/java/docs/debug">debugging tools</a> instead.
861-
*/
862-
public LaunchPersistentContextOptions setDevtools(boolean devtools) {
863-
this.devtools = devtools;
864-
return this;
865-
}
866854
/**
867855
* If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is
868856
* deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in
@@ -954,8 +942,7 @@ public LaunchPersistentContextOptions setHasTouch(boolean hasTouch) {
954942
/**
955943
* Whether to run browser in headless mode. More details for <a
956944
* href="https://developers.google.com/web/updates/2017/04/headless-chrome">Chromium</a> and <a
957-
* href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox</a>. Defaults to {@code true} unless
958-
* the {@code devtools} option is {@code true}.
945+
* href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox</a>. Defaults to {@code true}.
959946
*/
960947
public LaunchPersistentContextOptions setHeadless(boolean headless) {
961948
this.headless = headless;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,8 +2661,7 @@ default void dblclick() {
26612661
Locator describe(String description);
26622662
/**
26632663
* Returns locator description previously set with {@link com.microsoft.playwright.Locator#describe Locator.describe()}.
2664-
* Returns {@code null} if no custom description has been set. Prefer {@code Locator.toString()} for a human-readable
2665-
* representation, as it uses the description when available.
2664+
* Returns {@code null} if no custom description has been set.
26662665
*
26672666
* <p> <strong>Usage</strong>
26682667
* <pre>{@code

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,10 @@ default void abort() {
370370
* matching handlers won't be invoked. Use {@link com.microsoft.playwright.Route#fallback Route.fallback()} If you want
371371
* next matching handler in the chain to be invoked.
372372
*
373-
* <p> <strong>NOTE:</strong> The {@code Cookie} header cannot be overridden using this method. If a value is provided, it will be ignored, and the
374-
* cookie will be loaded from the browser's cookie store. To set custom cookies, use {@link
375-
* com.microsoft.playwright.BrowserContext#addCookies BrowserContext.addCookies()}.
373+
* <p> <strong>NOTE:</strong> Some request headers are **forbidden** and cannot be overridden (for example, {@code Cookie}, {@code Host}, {@code
374+
* Content-Length} and others, see <a
375+
* href="https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_header">this MDN page</a> for full list). If
376+
* an override is provided for a forbidden header, it will be ignored and the original request header will be used.To set custom cookies, use {@link com.microsoft.playwright.BrowserContext#addCookies BrowserContext.addCookies()}.
376377
*
377378
* @since v1.8
378379
*/
@@ -402,9 +403,10 @@ default void resume() {
402403
* matching handlers won't be invoked. Use {@link com.microsoft.playwright.Route#fallback Route.fallback()} If you want
403404
* next matching handler in the chain to be invoked.
404405
*
405-
* <p> <strong>NOTE:</strong> The {@code Cookie} header cannot be overridden using this method. If a value is provided, it will be ignored, and the
406-
* cookie will be loaded from the browser's cookie store. To set custom cookies, use {@link
407-
* com.microsoft.playwright.BrowserContext#addCookies BrowserContext.addCookies()}.
406+
* <p> <strong>NOTE:</strong> Some request headers are **forbidden** and cannot be overridden (for example, {@code Cookie}, {@code Host}, {@code
407+
* Content-Length} and others, see <a
408+
* href="https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_header">this MDN page</a> for full list). If
409+
* an override is provided for a forbidden header, it will be ignored and the original request header will be used.To set custom cookies, use {@link com.microsoft.playwright.BrowserContext#addCookies BrowserContext.addCookies()}.
408410
*
409411
* @since v1.8
410412
*/

playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ default void containsClass(List<String> expected) {
989989
* <p> Let's see how we can use the assertion:
990990
* <pre>{@code
991991
* // ✓ Contains the right items in the right order
992-
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
992+
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
993993
*
994994
* // ✖ Wrong order
995995
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1034,7 +1034,7 @@ default void containsText(String expected) {
10341034
* <p> Let's see how we can use the assertion:
10351035
* <pre>{@code
10361036
* // ✓ Contains the right items in the right order
1037-
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
1037+
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
10381038
*
10391039
* // ✖ Wrong order
10401040
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1077,7 +1077,7 @@ default void containsText(String expected) {
10771077
* <p> Let's see how we can use the assertion:
10781078
* <pre>{@code
10791079
* // ✓ Contains the right items in the right order
1080-
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
1080+
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
10811081
*
10821082
* // ✖ Wrong order
10831083
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1122,7 +1122,7 @@ default void containsText(Pattern expected) {
11221122
* <p> Let's see how we can use the assertion:
11231123
* <pre>{@code
11241124
* // ✓ Contains the right items in the right order
1125-
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
1125+
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
11261126
*
11271127
* // ✖ Wrong order
11281128
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1165,7 +1165,7 @@ default void containsText(Pattern expected) {
11651165
* <p> Let's see how we can use the assertion:
11661166
* <pre>{@code
11671167
* // ✓ Contains the right items in the right order
1168-
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
1168+
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
11691169
*
11701170
* // ✖ Wrong order
11711171
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1210,7 +1210,7 @@ default void containsText(String[] expected) {
12101210
* <p> Let's see how we can use the assertion:
12111211
* <pre>{@code
12121212
* // ✓ Contains the right items in the right order
1213-
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
1213+
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
12141214
*
12151215
* // ✖ Wrong order
12161216
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1253,7 +1253,7 @@ default void containsText(String[] expected) {
12531253
* <p> Let's see how we can use the assertion:
12541254
* <pre>{@code
12551255
* // ✓ Contains the right items in the right order
1256-
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
1256+
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
12571257
*
12581258
* // ✖ Wrong order
12591259
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1298,7 +1298,7 @@ default void containsText(Pattern[] expected) {
12981298
* <p> Let's see how we can use the assertion:
12991299
* <pre>{@code
13001300
* // ✓ Contains the right items in the right order
1301-
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
1301+
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
13021302
*
13031303
* // ✖ Wrong order
13041304
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,8 @@ void saveAsShouldThrowWhenNoVideoFrames(@TempDir Path videosDir) {
7979
if (!popup.isClosed()) {
8080
popup.waitForClose(() -> {});
8181
}
82-
// WebKit pauses renderer before win.close() and actually writes something.
83-
if (isWebKit()) {
84-
popup.video().saveAs(saveAsPath);
85-
assertTrue(Files.exists(saveAsPath));
86-
} else {
87-
PlaywrightException e = assertThrows(PlaywrightException.class, () -> popup.video().saveAs(saveAsPath));
88-
assertTrue(e.getMessage().contains("Page did not produce any video frames"), e.getMessage());
89-
}
82+
PlaywrightException e = assertThrows(PlaywrightException.class, () -> popup.video().saveAs(saveAsPath));
83+
assertTrue(e.getMessage().contains("Page did not produce any video frames"), e.getMessage());
9084
}
9185
}
9286

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ void shouldFormatNumberUsingContextLocale() {
193193
page.navigate(server.EMPTY_PAGE);
194194
Worker worker = page.waitForWorker(() -> page.evaluate(
195195
"() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))"));
196-
assertEquals("10\u00A0000,2", worker.evaluate("() => (10000.20).toLocaleString()"));
196+
// https://github.com/microsoft/playwright/issues/38919
197+
String expected = isFirefox() ? "10,000.2" : "10\u00A0000,2";
198+
assertEquals(expected, worker.evaluate("() => (10000.20).toLocaleString()"));
197199
context.close();
198200
}
199201

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,12 @@
3737
import static org.junit.jupiter.api.Assertions.assertEquals;
3838

3939
public class Utils {
40-
private static final AtomicInteger nextUnusedPort = new AtomicInteger(9000);
41-
42-
private static boolean available(int port) {
43-
try (ServerSocket ignored = new ServerSocket(port)) {
44-
return true;
45-
} catch (IOException ignored) {
46-
return false;
47-
}
48-
}
49-
5040
public static int nextFreePort() {
51-
for (int i = 0; i < 100; i++) {
52-
int port = nextUnusedPort.getAndIncrement();
53-
if (available(port)) {
54-
return port;
55-
}
41+
try (ServerSocket socket = new ServerSocket(0)) {
42+
return socket.getLocalPort();
43+
} catch (IOException e) {
44+
throw new RuntimeException("Cannot find free port", e);
5645
}
57-
throw new RuntimeException("Cannot find free port: " + nextUnusedPort.get());
5846
}
5947

6048
static void assertJsonEquals(Object expected, Object actual) {

0 commit comments

Comments
 (0)