Bug 1087629 - Add two new test cases for ICE connection states. r=ekr
authorJuan Becerra <jbecerra@mozilla.com>
Thu, 18 Jun 2015 16:07:01 -0700
changeset 250144 42f7a05958f4902ab4b4e14eb56a88f2b37ebdae
parent 250143 1959e594ac43fd94bc15eca23acc34b3c2a044be
child 250145 80005aa6f8e193faa05e5d9442dcba89c4695ca6
push id28947
push usercbook@mozilla.com
push dateThu, 25 Jun 2015 09:10:19 +0000
treeherdermozilla-central@0b2f5e8b7be5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersekr
bugs1087629
milestone41.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 1087629 - Add two new test cases for ICE connection states. r=ekr
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/templates.js
dom/media/tests/mochitest/test_peerConnection_closeDuringIce.html
dom/media/tests/mochitest/test_peerConnection_iceFailure.html
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -90,17 +90,20 @@ skip-if = buildapp == 'b2g' || buildapp 
 [test_peerConnection_capturedVideo.html]
 tags=capturestream
 skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
 [test_peerConnection_captureStream_canvas_2d.html]
 skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
 [test_peerConnection_captureStream_canvas_webgl.html]
 skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
 [test_peerConnection_close.html]
+[test_peerConnection_closeDuringIce.html]
 [test_peerConnection_errorCallbacks.html]
+[test_peerConnection_iceFailure.html]
+skip-if = toolkit == 'gonk' || buildapp == 'mulet' # Disabling because of test failures on B2G emulator
 [test_peerConnection_forwarding_basicAudioVideoCombined.html]
 skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
 [test_peerConnection_noTrickleAnswer.html]
 skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
 [test_peerConnection_noTrickleOffer.html]
 skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
 [test_peerConnection_noTrickleOfferAnswer.html]
 skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
--- a/dom/media/tests/mochitest/templates.js
+++ b/dom/media/tests/mochitest/templates.js
@@ -400,17 +400,17 @@ var commandsPeerConnectionOfferAnswer = 
     return test.getSignalingMessage("answer").then(message => {
       ok("answer" in message, "Got an answer message");
       test._remote_answer = new mozRTCSessionDescription(message.answer);
       test._answer_constraints = message.answer_constraints;
     });
   },
 
   function PC_LOCAL_SET_REMOTE_DESCRIPTION(test) {
-    test.setRemoteDescription(test.pcLocal, test._remote_answer, STABLE)
+    return test.setRemoteDescription(test.pcLocal, test._remote_answer, STABLE)
       .then(() => {
         is(test.pcLocal.signalingState, STABLE,
            "signalingState after local setRemoteDescription is 'stable'");
       });
   },
   function PC_REMOTE_SANE_LOCAL_SDP(test) {
     test.pcRemote.verifySdp(test._remote_answer, "answer",
                             test._offer_constraints, test._offer_options,
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_closeDuringIce.html
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+  createHTML({
+    bug: "1087629",
+    title: "Close PCs during ICE connectivity check"
+  });
+
+// Test closeDuringIce to simulate problems during peer connections
+
+
+function PC_LOCAL_SETUP_NULL_ICE_HANDLER(test) {
+  test.pcLocal.setupIceCandidateHandler(test, function() {}, function () {});
+}
+function PC_REMOTE_SETUP_NULL_ICE_HANDLER(test) {
+  test.pcRemote.setupIceCandidateHandler(test, function() {}, function () {});
+}
+function PC_REMOTE_ADD_FAKE_ICE_CANDIDATE(test) {
+  var cand = new mozRTCIceCandidate({"candidate":"candidate:0 1 UDP 2130379007 192.0.2.1 12345 typ host","sdpMid":"","sdpMLineIndex":0});
+  test.pcRemote.storeOrAddIceCandidate(cand);
+  info(test.pcRemote + " Stored fake candidate: " + JSON.stringify(cand));
+}
+function PC_LOCAL_ADD_FAKE_ICE_CANDIDATE(test) {
+  var cand = new mozRTCIceCandidate({"candidate":"candidate:0 1 UDP 2130379007 192.0.2.2 56789 typ host","sdpMid":"","sdpMLineIndex":0});
+    test.pcLocal.storeOrAddIceCandidate(cand);
+  info(test.pcLocal + " Stored fake candidate: " + JSON.stringify(cand));
+}
+function PC_LOCAL_CLOSE_DURING_ICE(test) {
+  return test.pcLocal.iceChecking.then(() => {
+    test.pcLocal.onsignalingstatechange = function () {};
+    test.pcLocal.close();
+    });
+}
+function PC_REMOTE_CLOSE_DURING_ICE(test) {
+  return test.pcRemote.iceChecking.then(() => {
+    test.pcRemote.onsignalingstatechange = function () {};
+    test.pcRemote.close();
+    });
+}
+function PC_LOCAL_WAIT_FOR_ICE_CHECKING(test) {
+  var resolveIceChecking;
+  test.pcLocal.iceChecking = new Promise(r => resolveIceChecking = r);
+  test.pcLocal.ice_connection_callbacks.checkIceStatus = () => {
+	if (test.pcLocal._pc.iceConnectionState === "checking") {
+	  resolveIceChecking();
+	}
+  }
+}
+function PC_REMOTE_WAIT_FOR_ICE_CHECKING(test) {
+  var resolveIceChecking;
+  test.pcRemote.iceChecking = new Promise(r => resolveIceChecking = r);
+  test.pcRemote.ice_connection_callbacks.checkIceStatus = () => {
+	if (test.pcRemote._pc.iceConnectionState === "checking") {
+	  resolveIceChecking();
+	}
+  }
+}
+
+runNetworkTest(() => {
+  var test = new PeerConnectionTest();
+  test.setMediaConstraints([{audio: true}], [{audio: true}]);
+  test.chain.replace("PC_LOCAL_SETUP_ICE_HANDLER", PC_LOCAL_SETUP_NULL_ICE_HANDLER);
+  test.chain.replace("PC_REMOTE_SETUP_ICE_HANDLER", PC_REMOTE_SETUP_NULL_ICE_HANDLER);
+  test.chain.insertAfter("PC_REMOTE_SETUP_NULL_ICE_HANDLER", PC_LOCAL_WAIT_FOR_ICE_CHECKING);
+  test.chain.insertAfter("PC_LOCAL_WAIT_FOR_ICE_CHECKING", PC_REMOTE_WAIT_FOR_ICE_CHECKING);
+  test.chain.removeAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION");
+  test.chain.append([PC_REMOTE_ADD_FAKE_ICE_CANDIDATE, PC_LOCAL_ADD_FAKE_ICE_CANDIDATE,
+	PC_LOCAL_CLOSE_DURING_ICE, PC_REMOTE_CLOSE_DURING_ICE]);
+  test.run();
+});
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_iceFailure.html
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+  createHTML({
+    bug: "1087629",
+    title: "Wait for ICE failure"
+  });
+
+// Test iceFailure
+
+function PC_LOCAL_SETUP_NULL_ICE_HANDLER(test) {
+  test.pcLocal.setupIceCandidateHandler(test, function() {}, function () {});
+}
+function PC_REMOTE_SETUP_NULL_ICE_HANDLER(test) {
+  test.pcRemote.setupIceCandidateHandler(test, function() {}, function () {});
+}
+function PC_REMOTE_ADD_FAKE_ICE_CANDIDATE(test) {
+  var cand = new mozRTCIceCandidate({"candidate":"candidate:0 1 UDP 2130379007 192.0.2.1 12345 typ host","sdpMid":"","sdpMLineIndex":0});
+  test.pcRemote.storeOrAddIceCandidate(cand);
+  info(test.pcRemote + " Stored fake candidate: " + JSON.stringify(cand));
+}
+function PC_LOCAL_ADD_FAKE_ICE_CANDIDATE(test) {
+  var cand = new mozRTCIceCandidate({"candidate":"candidate:0 1 UDP 2130379007 192.0.2.2 56789 typ host","sdpMid":"","sdpMLineIndex":0});
+    test.pcLocal.storeOrAddIceCandidate(cand);
+  info(test.pcLocal + " Stored fake candidate: " + JSON.stringify(cand));
+}
+function PC_LOCAL_WAIT_FOR_ICE_FAILURE(test) {
+  return test.pcLocal.iceFailed.then(() => {
+    ok(true, this.pcLocal + " Ice Failure Reached.");
+	});
+}
+function PC_REMOTE_WAIT_FOR_ICE_FAILURE(test) {
+  return test.pcRemote.iceFailed.then(() => {
+    ok(true, this.pcRemote + " Ice Failure Reached.");
+    });
+}
+function PC_LOCAL_WAIT_FOR_ICE_FAILED(test) {
+  var resolveIceFailed;
+  test.pcLocal.iceFailed = new Promise(r => resolveIceFailed = r);
+  test.pcLocal.ice_connection_callbacks.checkIceStatus = () => {
+	if (test.pcLocal._pc.iceConnectionState === "failed") {
+	  resolveIceFailed();
+	}
+  }
+}
+function PC_REMOTE_WAIT_FOR_ICE_FAILED(test) {
+  var resolveIceFailed;
+  test.pcRemote.iceFailed = new Promise(r => resolveIceFailed = r);
+  test.pcRemote.ice_connection_callbacks.checkIceStatus = () => {
+	if (test.pcRemote._pc.iceConnectionState === "failed") {
+	  resolveIceFailed();
+	}
+  }
+}
+
+runNetworkTest(() => {
+  SpecialPowers.pushPrefEnv({
+    'set': [
+      ['media.peerconnection.ice.stun_client_maximum_transmits', 3],
+      ['media.peerconnection.ice.trickle_grace_period', 3000],
+    ]
+  }, function() {
+    var test = new PeerConnectionTest();
+    test.setMediaConstraints([{audio: true}], [{audio: true}]);
+    test.chain.replace("PC_LOCAL_SETUP_ICE_HANDLER", PC_LOCAL_SETUP_NULL_ICE_HANDLER);
+    test.chain.replace("PC_REMOTE_SETUP_ICE_HANDLER", PC_REMOTE_SETUP_NULL_ICE_HANDLER);
+    test.chain.insertAfter("PC_REMOTE_SETUP_NULL_ICE_HANDLER", PC_LOCAL_WAIT_FOR_ICE_FAILED);
+    test.chain.insertAfter("PC_LOCAL_WAIT_FOR_ICE_FAILED", PC_REMOTE_WAIT_FOR_ICE_FAILED);
+    test.chain.removeAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION");
+    test.chain.append([PC_REMOTE_ADD_FAKE_ICE_CANDIDATE, PC_LOCAL_ADD_FAKE_ICE_CANDIDATE,
+	PC_LOCAL_WAIT_FOR_ICE_FAILURE, PC_REMOTE_WAIT_FOR_ICE_FAILURE]);
+    test.run();
+  });
+});
+</script>
+</pre>
+</body>
+</html>