Skip to content

Commit

Permalink
Switch default for RTCDataChannel.binaryType to arraybuffer (#43601)
Browse files Browse the repository at this point in the history
  • Loading branch information
dontcallmedom authored Dec 11, 2023
1 parent 75adc3b commit 12f0d5e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion webrtc/RTCDataChannel-binaryType.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test((t) => {
t.add_cleanup(() => pc.close());
const dc = pc.createDataChannel('test-binary-type');

assert_equals(dc.binaryType, "blob", `dc.binaryType should be 'blob'`);
assert_equals(dc.binaryType, "arraybuffer", `dc.binaryType should be 'arraybuffer'`);
}, `Default binaryType value`);

for (const binaryType of validBinaryTypes) {
Expand Down
12 changes: 3 additions & 9 deletions webrtc/RTCDataChannel-send.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,24 +261,18 @@
promise_test(t => {
return createDataChannelPair(t, options)
.then(([channel1, channel2]) => {
assert_equals(channel2.binaryType, 'blob',
'Expect initial binaryType value to be blob');
assert_equals(channel2.binaryType, 'arraybuffer',
'Expect initial binaryType value to be arraybuffer');

channel1.send(helloBuffer);
return awaitMessage(channel2);
})
.then(messageBlob => {
assert_true(messageBlob instanceof Blob,
'Expect received messageBlob to be a Blob');

return blobToArrayBuffer(messageBlob);
}).then(messageBuffer => {
assert_true(messageBuffer instanceof ArrayBuffer,
'Expect messageBuffer to be an ArrayBuffer');

assert_equals_typed_array(messageBuffer, helloBuffer.buffer);
});
}, `${mode} binaryType should receive message as Blob by default`);
}, `${mode} binaryType should receive message as ArrayBuffer by default`);

// Test sending 3 messages: helloBuffer, unicodeString, helloBlob
async_test(t => {
Expand Down
4 changes: 2 additions & 2 deletions webrtc/RTCPeerConnection-createDataChannel.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
assert_equals(dc.readyState, 'connecting');
assert_equals(dc.bufferedAmount, 0);
assert_equals(dc.bufferedAmountLowThreshold, 0);
assert_equals(dc.binaryType, 'blob');
assert_equals(dc.binaryType, 'arraybuffer');
}, 'createDataChannel attribute default values');

test(t => {
Expand All @@ -166,7 +166,7 @@
assert_equals(dc.readyState, 'connecting');
assert_equals(dc.bufferedAmount, 0);
assert_equals(dc.bufferedAmountLowThreshold, 0);
assert_equals(dc.binaryType, 'blob');
assert_equals(dc.binaryType, 'arraybuffer');

const dc2 = pc.createDataChannel('test2', {
ordered: false,
Expand Down

0 comments on commit 12f0d5e

Please sign in to comment.