Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/js/modules/k6/websockets/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ func (w *webSocket) send(msg sobek.Value) {
common.Throw(rt,
fmt.Errorf("got error while trying to export ArrayBufferView to bytes: %w", err))
}
w.bufferedAmount += len(b)
w.writeQueueCh <- message{
mtype: websocket.BinaryMessage,
data: b,
Expand Down
7 changes: 5 additions & 2 deletions internal/js/modules/k6/websockets/websockets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,16 @@ func TestBinaryType_ArrayBuffer_issue_5226(t *testing.T) {
ws.binaryType = "arraybuffer"
ws.addEventListener("open", () => {
const sent = new Uint8Array(1024)
ws.send(sent.subarray(0, 1))
ws.send(sent.subarray(0, 10))
if (ws.bufferedAmount != 10) {
throw "Expected 10 bufferedAmount got "+ ws.bufferedAmount
}
ws.onmessage = (e) => {
if (!(e.data instanceof ArrayBuffer)) {
throw new Error("Wrong event.data type; expected: ArrayBuffer, got: "+ typeof e.data);
}

if (e.data.byteLength != 1) {
if (e.data.byteLength != 10) {
throw new Error("The data received isn't equal to the data sent " + e.data.byteLength);
}

Expand Down