Bug 1531904 - Part 4: Fix some test-cases, and add some others. r=jib
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 16 Apr 2019 16:38:47 +0000
changeset 469709 85cc0827d8d3
parent 469708 3e57d6dc64b2
child 469710 2d54ea3f6208
push id35879
push usernerli@mozilla.com
push dateTue, 16 Apr 2019 22:01:48 +0000
treeherdermozilla-central@12a60898fdc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1531904
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1531904 - Part 4: Fix some test-cases, and add some others. r=jib Differential Revision: https://phabricator.services.mozilla.com/D26774
testing/web-platform/tests/webrtc/RTCPeerConnection-createDataChannel.html
testing/web-platform/tests/webrtc/RTCPeerConnection-ondatachannel.html
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-createDataChannel.html
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-createDataChannel.html
@@ -253,40 +253,56 @@ for (const [description, protocol, expec
 /*
   6.2.  RTCDataChannel
     createDataChannel
       11. Let channel have an [[Negotiated]] internal slot initialized to option's
           negotiated member.
  */
 test(() => {
   const pc = new RTCPeerConnection;
-  const channel = pc.createDataChannel('', { negotiated: true });
+  const channel = pc.createDataChannel('', { negotiated: true, id: 1 });
   assert_equals(channel.negotiated, true);
 }, 'createDataChannel with negotiated true should succeed');
 
 
 /*
   6.2.  RTCDataChannel
     createDataChannel
       10. If id is equal to 65535, which is greater than the maximum allowed ID
           of 65534 but still qualifies as an unsigned short, throw a TypeError.
  */
+for (const id of [0, 1, 65534, 65535]) {
+  test(() => {
+    const pc = new RTCPeerConnection();
+    const channel = pc.createDataChannel('', { id });
+    assert_equals(channel.id, null);
+  }, `createDataChannel with id ${id} and negotiated not set should succeed, but not set the channel's id`);
+}
+
 for (const id of [0, 1, 65534]) {
   test(() => {
     const pc = new RTCPeerConnection();
-    const channel = pc.createDataChannel('', { id });
+    const channel = pc.createDataChannel('', { id, negotiated: true });
     assert_equals(channel.id, id);
-  }, `createDataChannel with id ${id} should succeed`);
+  }, `createDataChannel with id ${id} and negotiated true should succeed, and set the channel's id`);
+}
+
+for (const id of [-1, 65536]) {
+  test(() => {
+    const pc = new RTCPeerConnection();
+    assert_throws(new TypeError(), () => pc.createDataChannel('', { id }));
+  }, `createDataChannel with id ${id} and negotiated not set should throw TypeError`);
 }
 
 for (const id of [-1, 65535, 65536]) {
   test(() => {
     const pc = new RTCPeerConnection();
-    assert_throws(new TypeError(), () => pc.createDataChannel('', { id }));
-  }, `createDataChannel with id ${id} should throw TypeError`);
+    assert_throws(new TypeError(), () => pc.createDataChannel('',
+      { id, negotiated: true }));
+  }, `createDataChannel with id ${id} and negotiated true should throw TypeError`);
 }
 
 /*
   6.2.  RTCDataChannel
     createDataChannel
       12. Let channel have an [[DataChannelPriority]] internal slot initialized
           to option's priority member.
 
@@ -327,19 +343,28 @@ test(() => {
     pc.createDataChannel('', {
       protocol: ' '.repeat(65536),
       negotiated: false
     }));
 }, 'createDataChannel with negotiated false and long protocol should throw TypeError');
 
 test(() => {
   const pc = new RTCPeerConnection();
+  assert_throws(new TypeError(), () =>
+    pc.createDataChannel('', {
+      negotiated: true
+    }));
+}, 'createDataChannel with negotiated true and no id should fail with TypeError');
+
+test(() => {
+  const pc = new RTCPeerConnection();
   const label = ' '.repeat(65536)
 
   const channel = pc.createDataChannel('', {
+    id: 1,
     label,
     protocol: ' '.repeat(65536),
     negotiated: true
   });
 
   assert_equals(channel.label, label);
 }, 'createDataChannel with negotiated true and long label and long protocol should succeed');
 
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-ondatachannel.html
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-ondatachannel.html
@@ -153,16 +153,17 @@
     t.add_cleanup(() => localPc.close());
     const remotePc = new RTCPeerConnection();
 
     t.add_cleanup(() => remotePc.close());
 
     const onDataChannel = t.unreached_func('datachannel event should not be fired');
 
     localPc.createDataChannel('test', {
+      id: 1,
       negotiated: true
     });
 
     remotePc.addEventListener('datachannel', onDataChannel);
     exchangeIceCandidates(localPc, remotePc);
     doSignalingHandshake(localPc, remotePc);
 
     t.step_timeout(t.step_func_done(), 200);