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

https://github.com/microsoft/playwright/issues/12353
This commit is contained in:
Max Schmitt 2023-02-02 19:04:26 +01:00 committed by GitHub
parent 3e4d22d04a
commit b803128a81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
});