diff options
author | Benjamin Gruenbaum <benjamingr@gmail.com> | 2020-11-10 05:34:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 14:34:42 +1100 |
commit | 94b68f90697954292f4355cf91e7f75868d8d664 (patch) | |
tree | 82c2c6e70d4ac2af0f24f8821732e24ad6fc256b /cli/tests/websocket_test.ts | |
parent | 0982056ff64368451c38b622de90f62fbade89fd (diff) |
fix(cli/rt): dom handler order in websocket (#8320)
Diffstat (limited to 'cli/tests/websocket_test.ts')
-rw-r--r-- | cli/tests/websocket_test.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cli/tests/websocket_test.ts b/cli/tests/websocket_test.ts index 93fddf446..0a91ac308 100644 --- a/cli/tests/websocket_test.ts +++ b/cli/tests/websocket_test.ts @@ -273,3 +273,23 @@ Deno.test("echo arraybuffer with binaryType arraybuffer", async () => { }; await promise; }); + +Deno.test("Event Handlers order", async () => { + const promise = createResolvable(); + const ws = new WebSocket("ws://localhost:4242"); + const arr: number[] = []; + ws.onerror = (): void => fail(); + ws.addEventListener("message", () => arr.push(1)); + ws.onmessage = () => fail(); + ws.addEventListener("message", () => { + arr.push(3); + ws.close(); + assertEquals(arr, [1, 2, 3]); + }); + ws.onmessage = () => arr.push(2); + ws.onopen = (): void => ws.send("Echo"); + ws.onclose = (): void => { + promise.resolve(); + }; + await promise; +}); |