Skip to content

Commit 9c220cd

Browse files
authored
test: update web socket tests to properly dispatch ws messages (#1683)
1 parent ab443d1 commit 9c220cd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ public void shouldWorkWithBinaryTypeBlob(String mock, Page page) throws Exceptio
148148
page.evaluate("window.log"));
149149
Future<String> messagePromise = webSocketServer.waitForMessage();
150150
page.evaluate("() => window.ws.send(new Blob([new Uint8Array(['h'.charCodeAt(0), 'i'.charCodeAt(0)])]))");
151-
// Without this the blob message is not sent in pass-through!
152-
assertEquals(1, page.evaluate("window.ws.readyState"));
151+
// Dispatch messages until web socket route is received.
152+
page.waitForCondition(() -> messagePromise.isDone());
153153
assertEquals("hi", messagePromise.get());
154154
}
155155

@@ -171,8 +171,8 @@ public void shouldWorkWithBinaryTypeArrayBuffer(String mock, Page page) throws E
171171
page.evaluate("window.log"));
172172
Future<String> messagePromise = webSocketServer.waitForMessage();
173173
page.evaluate("() => window.ws.send(new Blob([new Uint8Array(['h'.charCodeAt(0), 'i'.charCodeAt(0)])]))");
174-
// Without this the blob message is not sent in pass-through!
175-
assertEquals(1, page.evaluate("window.ws.readyState"));
174+
// Dispatch messages until web socket route is received.
175+
page.waitForCondition(() -> messagePromise.isDone());
176176
assertEquals("hi", messagePromise.get());
177177
}
178178

0 commit comments

Comments
 (0)