Bug 1531143 - Part 1: Rewrite this test-case to be valid, more readable, and test a little more than it did. r=jib
authorByron Campen [:bwc] <docfaraday@gmail.com>
Wed, 06 Mar 2019 16:49:27 +0000
changeset 520837 d4ac1f44cb9baf79627fb703142b5aaaf85acea6
parent 520836 636611b6dfee1f0caa6374fc3b331b19ea8cc2de
child 520838 a1358865bc47de8389ed09c16c5f205980601d12
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1531143
milestone67.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 1531143 - Part 1: Rewrite this test-case to be valid, more readable, and test a little more than it did. r=jib Differential Revision: https://phabricator.services.mozilla.com/D21950
testing/web-platform/tests/webrtc/RTCPeerConnection-setLocalDescription.html
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-setLocalDescription.html
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-setLocalDescription.html
@@ -67,39 +67,65 @@
           assert_session_desc_similar(pc.localDescription, offer2);
           assert_session_desc_similar(pc.currentLocalDescription, offer1);
           assert_session_desc_similar(pc.pendingLocalDescription, offer2);
 
           assert_array_equals(states, ['have-local-offer', 'stable', 'have-local-offer']);
         })));
   }, 'Calling createOffer() and setLocalDescription() again after one round of local-offer/remote-answer should succeed');
 
-  promise_test(t => {
-    const pc = new RTCPeerConnection();
-    t.add_cleanup(() => pc.close());
+  promise_test(async t => {
+    const pc1 = new RTCPeerConnection();
+    t.add_cleanup(() => pc1.close());
+
+    const pc2 = new RTCPeerConnection();
+    t.add_cleanup(() => pc2.close());
 
     const states = [];
-    pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
+    pc1.addEventListener('signalingstatechange', () => states.push(pc1.signalingState));
+
+    assert_equals(pc1.localDescription, null);
+    assert_equals(pc1.currentLocalDescription, null);
+    assert_equals(pc1.pendingLocalDescription, null);
+
+    pc1.createDataChannel('test');
+    const offer = await pc1.createOffer();
+
+    assert_equals(pc1.localDescription, null);
+    assert_equals(pc1.currentLocalDescription, null);
+    assert_equals(pc1.pendingLocalDescription, null);
+
+    await pc1.setLocalDescription(offer);
+
+    assert_session_desc_similar(pc1.localDescription, offer);
+    assert_equals(pc1.currentLocalDescription, null);
+    assert_session_desc_similar(pc1.pendingLocalDescription, offer);
 
-    return generateDataChannelOffer(pc)
-    .then(offer => pc.setRemoteDescription(offer))
-    .then(() => pc.createAnswer())
-    .then(answer =>
-      pc.setLocalDescription(answer)
-      .then(() => generateVideoReceiveOnlyOffer(pc))
-      .then(offer =>
-        pc.setLocalDescription(offer)
-        .then(() => {
-          assert_equals(pc.signalingState, 'have-local-offer');
-          assert_session_desc_similar(pc.localDescription, offer);
-          assert_session_desc_similar(pc.currentLocalDescription, answer);
-          assert_session_desc_similar(pc.pendingLocalDescription, offer);
+    await pc2.setRemoteDescription(offer);
+    const answer = await pc2.createAnswer();
+    await pc2.setLocalDescription(answer);
+    await pc1.setRemoteDescription(answer);
+
+    assert_equals(pc1.signalingState, 'stable');
+    assert_session_desc_similar(pc1.localDescription, offer);
+    assert_session_desc_similar(pc1.currentLocalDescription, offer);
+    assert_equals(pc1.pendingLocalDescription, null);
 
-          assert_array_equals(states, ['have-remote-offer', 'stable', 'have-local-offer']);
-        })));
+    const stream = await getNoiseStream({audio:true});
+    pc2.addTrack(stream.getTracks()[0], stream);
+
+    const reoffer = await pc2.createOffer();
+    await pc2.setLocalDescription(reoffer);
+    await pc1.setRemoteDescription(reoffer);
+    const reanswer = await pc1.createAnswer();
+    await pc1.setLocalDescription(reanswer);
+
+    assert_session_desc_similar(pc1.localDescription, reanswer);
+    assert_session_desc_similar(pc1.currentLocalDescription, reanswer);
+    assert_equals(pc1.pendingLocalDescription, null);
   }, 'Switching role from answerer to offerer after going back to stable state should succeed');
 
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     const offer = await pc.createOffer();
     let eventSequence = '';
     const signalingstatechangeResolver = new Resolver();
     pc.onsignalingstatechange = () => {