From 7630317a552731a69be7f99753873f83466dab96 Mon Sep 17 00:00:00 2001 From: youennf Date: Thu, 1 Oct 2020 20:38:32 +0200 Subject: [PATCH] Add RTCDataChannel-binaryType.html from PR13499 (#16043) Co-authored-by: Dominique Hazael-Massieux --- webrtc/RTCDataChannel-binaryType.window.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 webrtc/RTCDataChannel-binaryType.window.js diff --git a/webrtc/RTCDataChannel-binaryType.window.js b/webrtc/RTCDataChannel-binaryType.window.js new file mode 100644 index 00000000000000..2f1b24887801d3 --- /dev/null +++ b/webrtc/RTCDataChannel-binaryType.window.js @@ -0,0 +1,27 @@ +'use strict'; + +const validBinaryTypes = ['blob', 'arraybuffer']; +const invalidBinaryTypes = ['jellyfish', 'arraybuffer ', '', null, undefined]; + +for (const binaryType of validBinaryTypes) { + test((t) => { + const pc = new RTCPeerConnection(); + t.add_cleanup(() => pc.close()); + const dc = pc.createDataChannel('test-binary-type'); + + dc.binaryType = binaryType; + assert_equals(dc.binaryType, binaryType, `dc.binaryType should be '${binaryType}'`); + }, `Setting binaryType to '${binaryType}' should succeed`); +} + +for (const binaryType of invalidBinaryTypes) { + test((t) => { + const pc = new RTCPeerConnection(); + t.add_cleanup(() => pc.close()); + const dc = pc.createDataChannel('test-binary-type'); + + assert_throws('SyntaxError', () => { + dc.binaryType = binaryType; + }); + }, `Setting invalid binaryType '${binaryType}' should throw SyntaxError`); +}