fix(ext/websocket): don't throw exception when sending to closed socket (#26932)
[The WebSocket specification for the `send`
function](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send)
says:
> The browser will throw an exception if you call `send()` when the
connection is in the `CONNECTING` state. If you call `send()` when the
connection is in the `CLOSING` or `CLOSED` states, the browser will
silently discard the data.
and:
> ### Exceptions
>
> `InvalidStateError`
[`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException)
>
> Thrown if
[`WebSocket.readyState`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState)
is `CONNECTING`.
This pull request fixes the current behavior to match the specification.
Also, I believe it fixes #17586.