dom/media/tests/mochitest/test_peerConnection_closeDuringIce.html
author Phil Ringnalda <philringnalda@gmail.com>
Fri, 09 Dec 2016 08:33:55 -0800
changeset 372781 a3fe137d4d47d0d8c897bcb81d6ed1201a5dde89
parent 372779 1814c92e203b853b7cf113711066b22b5ae30a3d
child 372816 ede4f590709f6312f4198e645bc660771f9be0e3
permissions -rw-r--r--
Backed out 6 changesets (bug 1263312) for failures in test_exceptions_from_jsimplemented.html Backed out changeset 17ae85e95667 (bug 1263312) Backed out changeset 1814c92e203b (bug 1263312) Backed out changeset 6b71306765d2 (bug 1263312) Backed out changeset 33449a5d1676 (bug 1263312) Backed out changeset b311b7e439e8 (bug 1263312) Backed out changeset a667af08ffb5 (bug 1263312)

<!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 RTCIceCandidate({"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 RTCIceCandidate({"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>