Bug 1263312 - Update most tests to skip RTCSessionDescription construction. r=drno
authorJan-Ivar Bruaroey <jib@mozilla.com>
Wed, 09 Nov 2016 10:14:40 -0500
changeset 325575 ce72565dbefdc9256277f482c7bd7b0b8a2f44dd
parent 325574 ede4f590709f6312f4198e645bc660771f9be0e3
child 325576 a86c91c947de4cecdd884479d1c30398c0acfaac
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersdrno
bugs1263312
milestone53.0a1
Bug 1263312 - Update most tests to skip RTCSessionDescription construction. r=drno MozReview-Commit-ID: KOzT2av1bLj
dom/media/tests/mochitest/identity/test_fingerprints.html
dom/media/tests/mochitest/pc.js
dom/media/tests/mochitest/test_peerConnection_errorCallbacks.html
dom/media/tests/mochitest/test_peerConnection_localReofferRollback.html
dom/media/tests/mochitest/test_peerConnection_localRollback.html
dom/media/tests/mochitest/test_peerConnection_remoteReofferRollback.html
dom/media/tests/mochitest/test_peerConnection_remoteRollback.html
dom/media/tests/mochitest/test_peerConnection_restartIceLocalAndRemoteRollback.html
dom/media/tests/mochitest/test_peerConnection_restartIceLocalRollback.html
--- a/dom/media/tests/mochitest/identity/test_fingerprints.html
+++ b/dom/media/tests/mochitest/identity/test_fingerprints.html
@@ -81,18 +81,17 @@ function testMultipleFingerprints() {
     .then(assertion => {
       ok(assertion, 'Should have assertion');
 
       var sdp = offer.sdp.slice(0, match.index) +
           'a=identity:' + assertion + '\n' +
           fingerprintSdp(fingerprints.slice(1)) +
           offer.sdp.slice(match.index);
 
-      var desc = new RTCSessionDescription({ type: 'offer', sdp: sdp });
-      return pcStrict.setRemoteDescription(desc);
+      return pcStrict.setRemoteDescription({ type: 'offer', sdp });
     })
     .then(() => {
       ok(true, 'Modified fingerprints were accepted');
     }, error => {
       var e = SpecialPowers.wrap(error);
       ok(false, 'error in test: ' +
          (e.message ? (e.message + '\n' + e.stack) : e));
     })
--- a/dom/media/tests/mochitest/pc.js
+++ b/dom/media/tests/mochitest/pc.js
@@ -329,17 +329,17 @@ PeerConnectionTest.prototype.createOffer
 };
 
 /**
  * Sets the local description for the specified peer connection instance
  * and automatically handles the failure case.
  *
  * @param {PeerConnectionWrapper} peer
           The peer connection wrapper to run the command on
- * @param {RTCSessionDescription} desc
+ * @param {RTCSessionDescriptionInit} desc
  *        Session description for the local description request
  */
 PeerConnectionTest.prototype.setLocalDescription =
 function(peer, desc, stateExpected) {
   var eventFired = new Promise(resolve => {
     peer.onsignalingstatechange = e => {
       info(peer + ": 'signalingstatechange' event received");
       var state = e.target.signalingState;
@@ -398,17 +398,17 @@ PeerConnectionTest.prototype.setOfferOpt
 };
 
 /**
  * Sets the remote description for the specified peer connection instance
  * and automatically handles the failure case.
  *
  * @param {PeerConnectionWrapper} peer
           The peer connection wrapper to run the command on
- * @param {RTCSessionDescription} desc
+ * @param {RTCSessionDescriptionInit} desc
  *        Session description for the remote description request
  */
 PeerConnectionTest.prototype.setRemoteDescription =
 function(peer, desc, stateExpected) {
   var eventFired = new Promise(resolve => {
     peer.onsignalingstatechange = e => {
       info(peer + ": 'signalingstatechange' event received");
       var state = e.target.signalingState;
@@ -1066,48 +1066,48 @@ PeerConnectionWrapper.prototype = {
       return answer;
     });
   },
 
   /**
    * Sets the local description and automatically handles the failure case.
    *
    * @param {object} desc
-   *        RTCSessionDescription for the local description request
+   *        RTCSessionDescriptionInit for the local description request
    */
   setLocalDescription : function(desc) {
     this.observedNegotiationNeeded = undefined;
     return this._pc.setLocalDescription(desc).then(() => {
       info(this + ": Successfully set the local description");
     });
   },
 
   /**
    * Tries to set the local description and expect failure. Automatically
    * causes the test case to fail if the call succeeds.
    *
    * @param {object} desc
-   *        RTCSessionDescription for the local description request
+   *        RTCSessionDescriptionInit for the local description request
    * @returns {Promise}
    *        A promise that resolves to the expected error
    */
   setLocalDescriptionAndFail : function(desc) {
     return this._pc.setLocalDescription(desc).then(
       generateErrorCallback("setLocalDescription should have failed."),
       err => {
         info(this + ": As expected, failed to set the local description");
         return err;
       });
   },
 
   /**
    * Sets the remote description and automatically handles the failure case.
    *
    * @param {object} desc
-   *        RTCSessionDescription for the remote description request
+   *        RTCSessionDescriptionInit for the remote description request
    */
   setRemoteDescription : function(desc) {
     this.observedNegotiationNeeded = undefined;
     return this._pc.setRemoteDescription(desc).then(() => {
       info(this + ": Successfully set remote description");
       if (desc.type == "rollback") {
         this.holdIceCandidates = new Promise(r => this.releaseIceCandidates = r);
 
@@ -1117,17 +1117,17 @@ PeerConnectionWrapper.prototype = {
     });
   },
 
   /**
    * Tries to set the remote description and expect failure. Automatically
    * causes the test case to fail if the call succeeds.
    *
    * @param {object} desc
-   *        RTCSessionDescription for the remote description request
+   *        RTCSessionDescriptionInit for the remote description request
    * @returns {Promise}
    *        a promise that resolve to the returned error
    */
   setRemoteDescriptionAndFail : function(desc) {
     return this._pc.setRemoteDescription(desc).then(
       generateErrorCallback("setRemoteDescription should have failed."),
       err => {
         info(this + ": As expected, failed to set the remote description");
--- a/dom/media/tests/mochitest/test_peerConnection_errorCallbacks.html
+++ b/dom/media/tests/mochitest/test_peerConnection_errorCallbacks.html
@@ -22,27 +22,25 @@
     return pc.createAnswer()
     .then(generateErrorCallback("createAnswer before offer should fail"),
           validateReason);
   };
 
   function testSetLocalDescriptionError() {
     var pc = new RTCPeerConnection();
     info ("Testing setLocalDescription error");
-    return pc.setLocalDescription(new RTCSessionDescription({ sdp: "Picklechips!",
-                                                                 type: "offer" }))
+    return pc.setLocalDescription({ sdp: "Picklechips!", type: "offer" })
     .then(generateErrorCallback("setLocalDescription with nonsense SDP should fail"),
           validateReason);
   };
 
   function testSetRemoteDescriptionError() {
     var pc = new RTCPeerConnection();
     info ("Testing setRemoteDescription error");
-    return pc.setRemoteDescription(new RTCSessionDescription({ sdp: "Who?",
-                                                                  type: "offer" }))
+    return pc.setRemoteDescription({ sdp: "Who?", type: "offer" })
     .then(generateErrorCallback("setRemoteDescription with nonsense SDP should fail"),
           validateReason);
   };
 
   // No test for createOffer errors -- there's nothing we can do at this
   // level to evoke an error in createOffer.
 
   runNetworkTest(function () {
--- a/dom/media/tests/mochitest/test_peerConnection_localReofferRollback.html
+++ b/dom/media/tests/mochitest/test_peerConnection_localReofferRollback.html
@@ -32,20 +32,19 @@
 
         function PC_REMOTE_CREATE_AND_SET_OFFER(test) {
           return test.createOffer(test.pcRemote).then(offer => {
             return test.setLocalDescription(test.pcRemote, offer, HAVE_LOCAL_OFFER);
           });
         },
 
         function PC_REMOTE_ROLLBACK(test) {
-          return test.setLocalDescription(
-              test.pcRemote,
-              new RTCSessionDescription({ type: "rollback", sdp: ""}),
-              STABLE);
+          return test.setLocalDescription(test.pcRemote,
+                                          { type: "rollback", sdp: "" },
+                                          STABLE);
         },
 
         // Rolling back should shut down gathering
         function PC_REMOTE_WAIT_FOR_END_OF_TRICKLE(test) {
           return test.pcRemote.endOfTrickleIce;
         },
     ]);
     test.setMediaConstraints([{audio: true}], [{audio: true}]);
--- a/dom/media/tests/mochitest/test_peerConnection_localRollback.html
+++ b/dom/media/tests/mochitest/test_peerConnection_localRollback.html
@@ -18,20 +18,19 @@
     test.chain.insertBefore('PC_LOCAL_CREATE_OFFER', [
         function PC_REMOTE_CREATE_AND_SET_OFFER(test) {
           return test.createOffer(test.pcRemote).then(offer => {
             return test.setLocalDescription(test.pcRemote, offer, HAVE_LOCAL_OFFER);
           });
         },
 
         function PC_REMOTE_ROLLBACK(test) {
-          return test.setLocalDescription(
-              test.pcRemote,
-              new RTCSessionDescription({ type: "rollback", sdp: ""}),
-              STABLE);
+          return test.setLocalDescription(test.pcRemote,
+                                          { type: "rollback", sdp: "" },
+                                          STABLE);
         },
 
         // Rolling back should shut down gathering
         function PC_REMOTE_WAIT_FOR_END_OF_TRICKLE(test) {
           return test.pcRemote.endOfTrickleIce;
         },
 
         function PC_REMOTE_SETUP_ICE_HANDLER(test) {
--- a/dom/media/tests/mochitest/test_peerConnection_remoteReofferRollback.html
+++ b/dom/media/tests/mochitest/test_peerConnection_remoteReofferRollback.html
@@ -30,20 +30,18 @@
           if (test.testOptions.steeplechase) {
             test.pcLocal.endOfTrickleIce.then(() => {
               send_message({"type": "end_of_trickle_ice"});
             });
           }
         },
 
         function PC_REMOTE_ROLLBACK(test) {
-          return test.setRemoteDescription(
-              test.pcRemote,
-              new RTCSessionDescription({ type: "rollback" }),
-              STABLE)
+          return test.setRemoteDescription(test.pcRemote, { type: "rollback" },
+                                           STABLE)
             .then(() => test.pcRemote.rollbackRemoteTracksIfNotNegotiated());
         },
 
         function PC_LOCAL_ROLLBACK(test) {
           // We haven't negotiated the new stream yet.
           test.pcLocal.expectNegotiationNeeded();
           return test.setLocalDescription(
               test.pcLocal,
--- a/dom/media/tests/mochitest/test_peerConnection_remoteRollback.html
+++ b/dom/media/tests/mochitest/test_peerConnection_remoteRollback.html
@@ -15,20 +15,18 @@
   runNetworkTest(function (options) {
     test = new PeerConnectionTest(options);
     test.setMediaConstraints([{audio: true}], [{audio: true}]);
     test.chain.removeAfter('PC_REMOTE_CHECK_CAN_TRICKLE_SYNC');
     test.chain.append([
       function PC_REMOTE_ROLLBACK(test) {
         // We still haven't negotiated the tracks
         test.pcRemote.expectNegotiationNeeded();
-        return test.setRemoteDescription(
-          test.pcRemote,
-          new RTCSessionDescription({ type: "rollback" }),
-          STABLE)
+        return test.setRemoteDescription(test.pcRemote, { type: "rollback" },
+                                         STABLE)
           .then(() => test.pcRemote.rollbackRemoteTracksIfNotNegotiated());
       },
 
       function PC_REMOTE_CHECK_CAN_TRICKLE_REVERT_SYNC(test) {
         is(test.pcRemote._pc.canTrickleIceCandidates, null,
            "Remote canTrickleIceCandidates is reverted to null");
       },
 
--- a/dom/media/tests/mochitest/test_peerConnection_restartIceLocalAndRemoteRollback.html
+++ b/dom/media/tests/mochitest/test_peerConnection_restartIceLocalAndRemoteRollback.html
@@ -46,20 +46,18 @@
         function PC_LOCAL_EXPECT_ICE_CONNECTED(test) {
           test.pcLocal.iceCheckingIceRollbackExpected = true;
         },
         function PC_REMOTE_EXPECT_ICE_CONNECTED(test) {
           test.pcRemote.iceCheckingIceRollbackExpected = true;
         },
 
         function PC_REMOTE_ROLLBACK(test) {
-          return test.setRemoteDescription(
-              test.pcRemote,
-              new RTCSessionDescription({ type: "rollback" }),
-              STABLE);
+          return test.setRemoteDescription(test.pcRemote, { type: "rollback" },
+                                           STABLE);
         },
 
         function PC_LOCAL_ROLLBACK(test) {
           // We haven't negotiated the new stream yet.
           test.pcLocal.expectNegotiationNeeded();
           return test.setLocalDescription(
               test.pcLocal,
               new RTCSessionDescription({ type: "rollback", sdp: ""}),
--- a/dom/media/tests/mochitest/test_peerConnection_restartIceLocalRollback.html
+++ b/dom/media/tests/mochitest/test_peerConnection_restartIceLocalRollback.html
@@ -37,21 +37,19 @@
                                             offer,
                                             HAVE_LOCAL_OFFER);
           });
         },
         function PC_LOCAL_EXPECT_ICE_CONNECTED(test) {
           test.pcLocal.iceCheckingIceRollbackExpected = true;
         },
         function PC_LOCAL_ROLLBACK(test) {
-          return test.setLocalDescription(
-              test.pcLocal,
-              new RTCSessionDescription({ type: "rollback",
-                                          sdp: ""}),
-              STABLE);
+          return test.setLocalDescription(test.pcLocal,
+                                          { type: "rollback", sdp: ""},
+                                          STABLE);
         },
         // Rolling back should shut down gathering
         function PC_LOCAL_WAIT_FOR_END_OF_TRICKLE(test) {
           return test.pcLocal.endOfTrickleIce;
         },
         function PC_LOCAL_EXPECT_ICE_CHECKING(test) {
           test.pcLocal.expectIceChecking();
         },