Skip to content

Commit d889905

Browse files
committed
more
1 parent f2325cc commit d889905

File tree

4 files changed

+42
-38
lines changed

4 files changed

+42
-38
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ private WaitableResult<JsonElement> internalSendMessage(String guid, String meth
150150
if (titleReported) {
151151
metadata.addProperty("internal", true);
152152
} else {
153-
metadata.addProperty("title", title);
154-
// All but first message in a custom-titled API call are considered internal and will be hidden from the inspector.
155-
titleReported = true;
153+
if (title != null) {
154+
metadata.addProperty("title", title);
155+
// All but first message in a custom-titled API call are considered internal and will be hidden from the inspector.
156+
titleReported = true;
157+
}
156158
if (stackTraceCollector != null) {
157159
stack = stackTraceCollector.currentStackTrace();
158160
if (!stack.isEmpty()) {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.microsoft.playwright;
22

3-
import com.microsoft.playwright.Locator.AriaSnapshotOptions;
43
import com.microsoft.playwright.junit.FixtureTest;
54
import com.microsoft.playwright.junit.UsePlaywright;
65
import org.junit.jupiter.api.Test;
@@ -13,8 +12,6 @@
1312

1413
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
1514
import static org.junit.jupiter.api.Assertions.assertEquals;
16-
import static org.junit.jupiter.api.Assertions.assertThrows;
17-
import static org.junit.jupiter.api.Assertions.assertTrue;
1815

1916
@FixtureTest
2017
@UsePlaywright

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@ void shouldBeAbleToGenerateOutline(@TempDir Path tempDir) throws IOException {
6060
assertTrue(outlineSize > noOutlineSize, "Unexpected sizes: " + outlineSize + " noOutline: " + noOutlineSize);
6161
}
6262

63-
@Test
64-
@DisabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")
65-
void shouldThrowInNonChromium() {
66-
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.pdf());
67-
assertTrue(e.getMessage().contains("PDF generation is only supported for Headless Chromium"), e.getMessage());
68-
}
69-
7063

7164
@Test
7265
@DisabledIf(value="com.microsoft.playwright.TestBase#isChromium", disabledReason="skip")

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

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.microsoft.playwright;
1818

1919
import com.google.gson.Gson;
20+
import com.google.gson.annotations.SerializedName;
2021
import com.microsoft.playwright.options.AriaRole;
2122
import com.microsoft.playwright.options.Location;
2223
import com.microsoft.playwright.options.MouseButton;
@@ -202,8 +203,8 @@ void traceGroupGroupEnd(@TempDir Path tempDir) throws Exception {
202203
context.tracing().stop(new Tracing.StopOptions().setPath(traceFile1));
203204

204205
List<TraceEvent> events = parseTraceEvents(traceFile1);
205-
List<String> calls = events.stream().filter(e -> e.title != null).map(e -> e.title).collect(Collectors.toList());
206-
assertEquals(asList("outer group", "Page.navigate", "inner group 1", "Frame.click", "inner group 2", "Page.isVisible"), calls);
206+
List<String> calls = events.stream().filter(e -> e.renderedTitle() != null).map(e -> e.renderedTitle()).collect(Collectors.toList());
207+
assertEquals(asList("outer group", "Frame.goto", "inner group 1", "Frame.click", "inner group 2", "Frame.isVisible"), calls);
207208
}
208209

209210
@Test
@@ -240,30 +241,30 @@ void shouldTraceVariousAPIs(@TempDir Path tempDir) throws Exception {
240241
context.tracing().stop(new Tracing.StopOptions().setPath(traceFile1));
241242

242243
List<TraceEvent> events = parseTraceEvents(traceFile1);
243-
List<String> calls = events.stream().filter(e -> e.title != null).map(e -> e.title)
244+
List<String> calls = events.stream().filter(e -> e.renderedTitle() != null).map(e -> e.renderedTitle())
244245
.collect(Collectors.toList());
245246
assertEquals(asList(
246-
"Clock.install",
247-
"Page.setContent",
247+
"BrowserContext.clockInstall",
248+
"Frame.setContent",
248249
"Frame.click",
249250
"Frame.click",
250-
"Keyboard.type",
251-
"Keyboard.press",
252-
"Keyboard.down",
253-
"Keyboard.insertText",
254-
"Keyboard.up",
255-
"Mouse.move",
256-
"Mouse.down",
257-
"Mouse.move",
258-
"Mouse.wheel",
259-
"Mouse.up",
260-
"Clock.fastForward",
261-
"Clock.fastForward",
262-
"Clock.pauseAt",
263-
"Clock.runFor",
264-
"Clock.setFixedTime",
265-
"Clock.setSystemTime",
266-
"Clock.resume",
251+
"Page.keyboardType",
252+
"Page.keyboardPress",
253+
"Page.keyboardDown",
254+
"Page.keyboardInsertText",
255+
"Page.keyboardUp",
256+
"Page.mouseMove",
257+
"Page.mouseDown",
258+
"Page.mouseMove",
259+
"Page.mouseWheel",
260+
"Page.mouseUp",
261+
"BrowserContext.clockFastForward",
262+
"BrowserContext.clockFastForward",
263+
"BrowserContext.clockPauseAt",
264+
"BrowserContext.clockRunFor",
265+
"BrowserContext.clockSetFixedTime",
266+
"BrowserContext.clockSetSystemTime",
267+
"BrowserContext.clockResume",
267268
"Frame.click"),
268269
calls);
269270
}
@@ -284,20 +285,31 @@ public void shouldNotRecordNetworkActions(@TempDir Path tempDir) throws IOExcept
284285
context.tracing().stop(new Tracing.StopOptions().setPath(traceFile1));
285286

286287
List<TraceEvent> events = parseTraceEvents(traceFile1);
287-
List<String> calls = events.stream().filter(e -> e.title != null).map(e -> e.title)
288+
List<String> calls = events.stream().filter(e -> e.renderedTitle() != null).map(e -> e.renderedTitle())
288289
.collect(Collectors.toList());
289-
assertEquals(asList("Page.navigate"), calls);
290+
assertEquals(asList("Frame.goto"), calls);
290291
}
291292

292293
private static class TraceEvent {
293294
String type;
294295
String name;
295-
String apiName;
296296
String title;
297+
@SerializedName("class")
298+
String clazz;
297299
String method;
298300
Double startTime;
299301
Double endTime;
300302
String callId;
303+
304+
String renderedTitle() {
305+
if (title != null) {
306+
return title;
307+
}
308+
if (clazz != null && method != null) {
309+
return clazz + "." + method;
310+
}
311+
return null;
312+
}
301313
}
302314

303315
private static List<TraceEvent> parseTraceEvents(Path traceFile) throws IOException {

0 commit comments

Comments
 (0)