Bug 1531103 - Part 1: Fix flaw in test case where a negotiationneeded event can happen before negotiation does, confusing the test code. r=jib
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 08 Mar 2019 18:51:29 +0000
changeset 521175 cfa16385f4156dbc162ae2fc302d4a0c24e2c9ed
parent 521174 da88c04400934de014f693957d9aa10d79f432aa
child 521176 cce35becf71943cab026b822c2ee6836db21150a
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
bugs1531103
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 1531103 - Part 1: Fix flaw in test case where a negotiationneeded event can happen before negotiation does, confusing the test code. r=jib Differential Revision: https://phabricator.services.mozilla.com/D22036
testing/web-platform/tests/webrtc/RTCPeerConnection-onnegotiationneeded.html
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-onnegotiationneeded.html
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-onnegotiationneeded.html
@@ -182,32 +182,31 @@
   /*
     4.4.1.6.  Set the RTCSessionSessionDescription
       2.2.10. If connection's signaling state is now stable, update the negotiation-needed
               flag. If connection's [[NegotiationNeeded]] slot was true both before and after
               this update, queue a task that runs the following steps:
         2.  If connection's [[NegotiationNeeded]] slot is false, abort these steps.
         3.  Fire a simple event named negotiationneeded at connection.
    */
-  promise_test(t => {
+  promise_test(async t => {
     const pc = new RTCPeerConnection();
 
     t.add_cleanup(() => pc.close());
 
-    return assert_first_promise_fulfill_after_second(
-      awaitNegotiation(pc),
-      generateAudioReceiveOnlyOffer(pc)
-      .then(offer =>
-        pc.setLocalDescription(offer)
-        .then(() => {
-          pc.createDataChannel('test');
-          return generateAnswer(offer);
-        }))
-      .then(answer => pc.setRemoteDescription(answer)),
-      'Expect negotiationneeded promise to resolve after pc has set remote answer and go back to stable state');
+    pc.addTransceiver('audio');
+    const offer = await pc.createOffer();
+    await pc.setLocalDescription(offer);
+    let fired = false;
+    pc.onnegotiationneeded = e => fired = true;
+    pc.createDataChannel('test');
+    const answer = await generateAnswer(offer);
+    await pc.setRemoteDescription(answer);
+    assert_false(fired, "negotiationneeded should not fire until the next iteration of the event loop after returning to stable");
+    await new Promise(resolve => pc.onnegotiationneeded = resolve);
   }, 'negotiationneeded event should fire only after signaling state go back to stable');
 
   /*
     TODO
     4.7.3.  Updating the Negotiation-Needed flag
 
       To update the negotiation-needed flag
       3.  If the result of checking if negotiation is needed is "false",