Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: CloseEvent.wasClean=false when WS server terminates (#20594)

Max Schmittb803128a810e
diff --git a/tests/library/capabilities.spec.ts b/tests/library/capabilities.spec.ts
index 27af793f59..9e3af8a1f6 100644
--- a/tests/library/capabilities.spec.ts
+++ b/tests/library/capabilities.spec.ts
@@ -175,3 +175,16 @@ it('navigator.clipboard should be present', async ({ page, server, browserName,
await page.goto(server.EMPTY_PAGE);
expect(await page.evaluate(() => navigator.clipboard)).toBeTruthy();
});
+
+it('should set CloseEvent.wasClean to false when the server terminates a WebSocket connection', async ({ page, server, browserName, platform }) => {
+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/12353' });
+ it.fixme(browserName === 'webkit' && platform === 'win32');
+ server.onceWebSocketConnection(socket => {
+ socket.terminate();
+ });
+ const wasClean = await page.evaluate(port => new Promise<boolean>(resolve => {
+ const ws = new WebSocket('ws://localhost:' + port + '/ws');
+ ws.addEventListener('close', error => resolve(error.wasClean));
+ }), server.PORT);
+ expect(wasClean).toBe(false);
+});