diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2023-04-26 07:36:22 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-26 00:36:22 +0200 |
commit | 9b49de46446f3acb3081bfa809652a8a66d54bfb (patch) | |
tree | d8ab2b27927928230d8a7d6ca9b06e6a16c2d068 /cli/tests/unit/websocket_test.ts | |
parent | 97820fe8abb15baabaf6b6eed632514867c7d97d (diff) |
fix(core): Wrap safe collections' argument of primordials (#18750)
Diffstat (limited to 'cli/tests/unit/websocket_test.ts')
-rw-r--r-- | cli/tests/unit/websocket_test.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cli/tests/unit/websocket_test.ts b/cli/tests/unit/websocket_test.ts index 999eede41..795d5ebc1 100644 --- a/cli/tests/unit/websocket_test.ts +++ b/cli/tests/unit/websocket_test.ts @@ -147,3 +147,25 @@ Deno.test({ }; await Promise.all([promise, server]); }); + +Deno.test( + { sanitizeOps: false }, + function websocketConstructorWithPrototypePollusion() { + const originalSymbolIterator = Array.prototype[Symbol.iterator]; + try { + Array.prototype[Symbol.iterator] = () => { + throw Error("unreachable"); + }; + assertThrows(() => { + new WebSocket( + new URL("ws://localhost:4242/"), + // Allow `Symbol.iterator` to be called in WebIDL conversion to `sequence<DOMString>` + // deno-lint-ignore no-explicit-any + ["soap", "soap"].values() as any, + ); + }, DOMException); + } finally { + Array.prototype[Symbol.iterator] = originalSymbolIterator; + } + }, +); |