Index: third_party/WebKit/LayoutTests/external/wpt/webrtc/RTCPeerConnection-createDataChannel.html |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webrtc/RTCPeerConnection-createDataChannel.html b/third_party/WebKit/LayoutTests/external/wpt/webrtc/RTCPeerConnection-createDataChannel.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9d48a4ba61533163892c938f38c1c4fc8cc7ec22 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/external/wpt/webrtc/RTCPeerConnection-createDataChannel.html |
@@ -0,0 +1,123 @@ |
+<!doctype html> |
+<meta charset=utf-8> |
+<title>RTCPeerConnection createDataChannel method</title> |
+<script src=/resources/testharness.js></script> |
+<script src=/resources/testharnessreport.js></script> |
+<script> |
+'use strict'; |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ assert_equals(pc.createDataChannel.length, 1); |
+ assert_throws(new TypeError, () => pc.createDataChannel()); |
+}, 'createDataChannel required arguments'); |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ pc.close(); |
+ assert_equals(pc.signalingState, 'closed', 'signaling state'); |
+ assert_throws('InvalidStateError', () => pc.createDataChannel('')); |
+}, 'createDataChannel with closed connection'); |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel = pc.createDataChannel(''); |
+ assert_true(channel instanceof RTCDataChannel, 'is RTCDataChannel'); |
+ assert_equals(channel.label, '', 'label'); |
+ assert_equals(channel.ordered, true, 'ordered'); |
+ assert_equals(channel.maxPacketLifeTime, null, 'maxPacketLifeTime'); |
+ assert_equals(channel.maxRetransmits, null, 'maxRetransmits'); |
+ assert_equals(channel.protocol, '', 'protocol'); |
+ assert_equals(channel.negotiated, false, 'negotiated'); |
+ // Initial id value is not defined. |
hbos_chromium
2017/04/19 09:15:33
The id was not specified and as such was generated
foolip
2017/04/20 11:52:03
I filed https://github.com/w3c/webrtc-pc/issues/11
|
+ assert_equals(typeof channel.id, 'number', 'id type'); |
+ assert_equals(channel.priority, 'low', 'priority'); |
+}, 'createDataChannel defaults'); |
+ |
+const labels = [ |
+ ['"foo"', 'foo', 'foo'], |
+ ['null', null, 'null'], |
+ ['undefined', undefined, 'undefined'], |
+ ['lone surrogate', '\uD800', '\uFFFD'], |
+]; |
+for (const [description, label, expected] of labels) { |
+ test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel = pc.createDataChannel(label); |
+ assert_equals(channel.label, expected); |
+ }, 'createDataChannel with label ' + description); |
+} |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel = pc.createDataChannel('', { ordered: false }); |
+ assert_equals(channel.ordered, false); |
+}, 'createDataChannel with ordered false'); |
+ |
+// true as the default value of a boolean is confusing because null is converted |
+// to false while undefined is converted to true. |
hbos_chromium
2017/04/19 09:15:33
(Oh man, I misread this comment not realizing you
foolip
2017/04/20 11:52:03
Sorry to almost have ruined your sanity :)
|
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel1 = pc.createDataChannel('', { ordered: null }); |
+ assert_equals(channel1.ordered, false); |
+ const channel2 = pc.createDataChannel('', { ordered: undefined }); |
+ assert_equals(channel2.ordered, true); |
+}, 'createDataChannel with ordered null/undefined'); |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel = pc.createDataChannel('', { maxPacketLifeTime: 0 }); |
+ assert_equals(channel.maxPacketLifeTime, 0); |
+}, 'createDataChannel with maxPacketLifeTime 0'); |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel = pc.createDataChannel('', { maxRetransmits: 0 }); |
+ assert_equals(channel.maxRetransmits, 0); |
+}, 'createDataChannel with maxRetransmits 0'); |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ assert_throws('SyntaxError', () => pc.createDataChannel('', { |
+ maxPacketLifeTime: 0, |
+ maxRetransmits: 0 |
+ })); |
+}, 'createDataChannel with both maxPacketLifeTime and maxRetransmits'); |
+ |
+const protocols = [ |
+ ['"foo"', 'foo', 'foo'], |
+ ['null', null, 'null'], |
+ ['undefined', undefined, ''], |
+ ['lone surrogate', '\uD800', '\uFFFD'], |
+]; |
+for (const [description, protocol, expected] of protocols) { |
+ test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel = pc.createDataChannel('', { protocol: protocol }); |
+ assert_equals(channel.protocol, expected); |
+ }, 'createDataChannel with protocol ' + description); |
+} |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel = pc.createDataChannel('', { negotiated: true }); |
+ assert_equals(channel.negotiated, true); |
+}, 'createDataChannel with negotiated true'); |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel = pc.createDataChannel('', { id: 65534 }); |
+ assert_equals(channel.id, 65534); |
+}, 'createDataChannel with id 65534'); |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ assert_throws(new TypeError, () => pc.createDataChannel('', { id: 65535 })); |
hbos_chromium
2017/04/19 09:15:33
Can you add a comment saying 65534 is the maximum
foolip
2017/04/20 11:52:03
Ah, will do.
foolip
2017/04/24 07:40:03
Wrote a comment and tested more numbers, now landi
|
+}, 'createDataChannel with id 65535'); |
+ |
+test(() => { |
+ const pc = new RTCPeerConnection; |
+ const channel = pc.createDataChannel('', { priority: "high" }); |
+ assert_equals(channel.priority, "high"); |
+}, 'createDataChannel with priority "high"'); |
+</script> |