Skip to content

Commit 00b588d

Browse files
committed
chore: roll driver to 1.60.0-beta-1778180503000
- Plumb viewport size through screencast onFrame callback (#40649). - Generate ScreencastFrame.java from api.json by recursing into function arg Objects carrying langAliases.
1 parent f081667 commit 00b588d

7 files changed

Lines changed: 50 additions & 13 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
1212
| :--- | :---: | :---: | :---: |
1313
| Chromium <!-- GEN:chromium-version -->148.0.7778.96<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1414
| WebKit <!-- GEN:webkit-version -->26.4<!-- GEN:stop --> ||||
15-
| Firefox <!-- GEN:firefox-version -->150.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
15+
| Firefox <!-- GEN:firefox-version -->150.0.2<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1616

1717
## Documentation
1818

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public interface Screencast {
2828
class StartOptions {
2929
/**
30-
* Callback that receives JPEG-encoded frame data.
30+
* Callback that receives JPEG-encoded frame data along with the page viewport size at the time of capture.
3131
*/
3232
public Consumer<ScreencastFrame> onFrame;
3333
/**
@@ -40,7 +40,7 @@ class StartOptions {
4040
public Integer quality;
4141

4242
/**
43-
* Callback that receives JPEG-encoded frame data.
43+
* Callback that receives JPEG-encoded frame data along with the page viewport size at the time of capture.
4444
*/
4545
public StartOptions setOnFrame(Consumer<ScreencastFrame> onFrame) {
4646
this.onFrame = onFrame;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ void handleScreencastFrame(JsonObject params) {
4444
}
4545
String dataBase64 = params.get("data").getAsString();
4646
byte[] data = java.util.Base64.getDecoder().decode(dataBase64);
47-
onFrame.accept(new ScreencastFrame(data));
47+
int viewportWidth = params.get("viewportWidth").getAsInt();
48+
int viewportHeight = params.get("viewportHeight").getAsInt();
49+
onFrame.accept(new ScreencastFrame(data, viewportWidth, viewportHeight));
4850
}
4951

5052
@Override

playwright/src/main/java/com/microsoft/playwright/options/ScreencastFrame.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,23 @@
1616

1717
package com.microsoft.playwright.options;
1818

19-
/**
20-
* A single screencast frame delivered to {@link com.microsoft.playwright.Screencast#start Screencast.start()}'s
21-
* {@code onFrame} callback.
22-
*/
2319
public class ScreencastFrame {
2420
/**
2521
* JPEG-encoded frame data.
2622
*/
2723
public byte[] data;
24+
/**
25+
* Width of the page viewport at the time the frame was captured.
26+
*/
27+
public int viewportWidth;
28+
/**
29+
* Height of the page viewport at the time the frame was captured.
30+
*/
31+
public int viewportHeight;
2832

29-
public ScreencastFrame(byte[] data) {
33+
public ScreencastFrame(byte[] data, int viewportWidth, int viewportHeight) {
3034
this.data = data;
35+
this.viewportWidth = viewportWidth;
36+
this.viewportHeight = viewportHeight;
3137
}
32-
}
38+
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,27 @@ void screencastStartShouldDeliverFramesViaOnFrame() throws Exception {
122122
}
123123
}
124124

125+
@Test
126+
void onFrameShouldReceiveViewportSize() {
127+
BrowserContext context = browser.newContext(new Browser.NewContextOptions().setViewportSize(1000, 400));
128+
Page page = context.newPage();
129+
try {
130+
List<ScreencastFrame> frames = new ArrayList<>();
131+
page.screencast().start(new Screencast.StartOptions().setOnFrame(frames::add));
132+
page.navigate(server.EMPTY_PAGE);
133+
page.evaluate("() => document.body.style.backgroundColor = 'red'");
134+
page.waitForTimeout(500);
135+
page.screencast().stop();
136+
assertFalse(frames.isEmpty(), "expected at least one frame");
137+
for (ScreencastFrame frame : frames) {
138+
assertEquals(1000, frame.viewportWidth);
139+
assertEquals(400, frame.viewportHeight);
140+
}
141+
} finally {
142+
context.close();
143+
}
144+
}
145+
125146
@Test
126147
void screencastStartShouldThrowIfAlreadyStarted() {
127148
BrowserContext context = browser.newContext();

scripts/DRIVER_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.60.0-alpha-1778025033000
1+
1.60.0-beta-1778180503000

tools/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ private void createClassesAndEnums(JsonObject jsonObject) {
326326
}
327327
return;
328328
}
329+
if ("function".equals(jsonObject.get("name").getAsString()) && jsonObject.has("args")) {
330+
for (JsonElement item : jsonObject.getAsJsonArray("args")) {
331+
if (item.isJsonObject() && javaAlias(item.getAsJsonObject()) != null) {
332+
createClassesAndEnums(item.getAsJsonObject());
333+
}
334+
}
335+
return;
336+
}
329337
if ("Object".equals(jsonObject.get("name").getAsString())) {
330338
if (customType != null) {
331339
// Same type maybe referenced as 'Object' in several union values, e.g. Object|Array<Object>
@@ -506,8 +514,8 @@ private String convertBuiltinType(JsonObject jsonType) {
506514
if (customType != null) {
507515
return customType;
508516
}
509-
// Inner Objects (e.g. function arguments) are not visited by createClassesAndEnums,
510-
// so resolve their Java type name from langAliases here.
517+
// Inner Objects without langAliases (e.g. unaliased function arguments) are not visited
518+
// by createClassesAndEnums, so resolve their Java type name from langAliases here.
511519
String alias = javaAlias(jsonType);
512520
if (alias != null) {
513521
return alias;

0 commit comments

Comments
 (0)