From 4a1bb1aa7fd6d82ce639f2b9f4f91b545fe30986 Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Fri, 10 May 2024 20:53:36 +0900 Subject: [PATCH 1/4] websocket: don't clone buffer --- lib/web/websocket/websocket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/websocket/websocket.js b/lib/web/websocket/websocket.js index 97e86c3801e..32ec97e68db 100644 --- a/lib/web/websocket/websocket.js +++ b/lib/web/websocket/websocket.js @@ -287,7 +287,7 @@ class WebSocket extends EventTarget { // not throw an exception must increase the bufferedAmount attribute // by the length of data’s buffer in bytes. - const ab = new FastBuffer(data, data.byteOffset, data.byteLength) + const ab = new FastBuffer(data.buffer, data.byteOffset, data.byteLength) const frame = new WebsocketFrameSend(ab) const buffer = frame.createFrame(opcodes.BINARY) From c57af9a2c61ffa87e48c5307983cd4b28c0357c0 Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Fri, 10 May 2024 20:57:56 +0900 Subject: [PATCH 2/4] Apply suggestions from code review --- lib/web/websocket/websocket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/websocket/websocket.js b/lib/web/websocket/websocket.js index 32ec97e68db..83a443df71e 100644 --- a/lib/web/websocket/websocket.js +++ b/lib/web/websocket/websocket.js @@ -287,7 +287,7 @@ class WebSocket extends EventTarget { // not throw an exception must increase the bufferedAmount attribute // by the length of data’s buffer in bytes. - const ab = new FastBuffer(data.buffer, data.byteOffset, data.byteLength) + const ab = new FastBuffer(data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength), 0, data.byteLength) const frame = new WebsocketFrameSend(ab) const buffer = frame.createFrame(opcodes.BINARY) From 94f971ef35bc892fbc2299a3958a9b02520988cf Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Fri, 10 May 2024 21:09:21 +0900 Subject: [PATCH 3/4] fixup --- test/wpt/status/websockets.status.json | 36 -------------------------- 1 file changed, 36 deletions(-) diff --git a/test/wpt/status/websockets.status.json b/test/wpt/status/websockets.status.json index edd27727820..dd36014861b 100644 --- a/test/wpt/status/websockets.status.json +++ b/test/wpt/status/websockets.status.json @@ -16,42 +16,6 @@ } } }, - "Send-binary-arraybufferview-float32.any.js": { - "note": "TODO(@KhafraDev): investigate failure", - "fail": [ - "Send binary data on a WebSocket - ArrayBufferView - Float32Array - Connection should be closed" - ] - }, - "Send-binary-arraybufferview-float64.any.js": { - "note": "TODO(@KhafraDev): investigate failure", - "fail": [ - "Send binary data on a WebSocket - ArrayBufferView - Float64Array - Connection should be closed" - ] - }, - "Send-binary-arraybufferview-int16-offset.any.js": { - "note": "TODO(@KhafraDev): investigate failure", - "fail": [ - "Send binary data on a WebSocket - ArrayBufferView - Int16Array with offset - Connection should be closed" - ] - }, - "Send-binary-arraybufferview-int32.any.js": { - "note": "TODO(@KhafraDev): investigate failure", - "fail": [ - "Send binary data on a WebSocket - ArrayBufferView - Int32Array - Connection should be closed" - ] - }, - "Send-binary-arraybufferview-uint16-offset-length.any.js": { - "note": "TODO(@KhafraDev): investigate failure", - "fail": [ - "Send binary data on a WebSocket - ArrayBufferView - Uint16Array with offset and length - Connection should be closed" - ] - }, - "Send-binary-arraybufferview-uint32-offset.any.js": { - "note": "TODO(@KhafraDev): investigate failure", - "fail": [ - "Send binary data on a WebSocket - ArrayBufferView - Uint32Array with offset - Connection should be closed" - ] - }, "Create-on-worker-shutdown.any.js": { "skip": true, "//": "Node.js workers are different from web workers & don't work with blob: urls" From e62bc887deba5e646a912ebd3b54a61b844540c4 Mon Sep 17 00:00:00 2001 From: tsctx <91457664+tsctx@users.noreply.github.com> Date: Fri, 10 May 2024 21:13:03 +0900 Subject: [PATCH 4/4] Apply suggestions from code review --- lib/web/websocket/websocket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/websocket/websocket.js b/lib/web/websocket/websocket.js index 83a443df71e..32ec97e68db 100644 --- a/lib/web/websocket/websocket.js +++ b/lib/web/websocket/websocket.js @@ -287,7 +287,7 @@ class WebSocket extends EventTarget { // not throw an exception must increase the bufferedAmount attribute // by the length of data’s buffer in bytes. - const ab = new FastBuffer(data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength), 0, data.byteLength) + const ab = new FastBuffer(data.buffer, data.byteOffset, data.byteLength) const frame = new WebsocketFrameSend(ab) const buffer = frame.createFrame(opcodes.BINARY)