mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Bug 1041832: add support for trickle ICE to mochitests r=bwc
This commit is contained in:
parent
1d43b484b0
commit
e6dfad56b3
@ -83,8 +83,8 @@ function theTest() {
|
||||
[
|
||||
"OFFERS_AND_ANSWERS_INCLUDE_IDENTITY",
|
||||
function(test) {
|
||||
ok(test.pcLocal._last_offer.sdp.contains("a=identity"), "a=identity is in the offer SDP");
|
||||
ok(test.pcRemote._last_answer.sdp.contains("a=identity"), "a=identity is in the answer SDP");
|
||||
ok(test.originalOffer.sdp.contains("a=identity"), "a=identity is in the offer SDP");
|
||||
ok(test.originalAnswer.sdp.contains("a=identity"), "a=identity is in the answer SDP");
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
|
@ -70,8 +70,8 @@ runNetworkTest(function () {
|
||||
[
|
||||
'ONLY_REMOTE_SDP_INCLUDES_IDENTITY_ASSERTION',
|
||||
function(test) {
|
||||
ok(!test.pcLocal._last_offer.sdp.contains('a=identity'), 'a=identity not contained in the offer SDP');
|
||||
ok(test.pcRemote._last_answer.sdp.contains('a=identity'), 'a=identity is contained in the answer SDP');
|
||||
ok(!test.originalOffer.sdp.contains('a=identity'), 'a=identity not contained in the offer SDP');
|
||||
ok(test.originalAnswer.sdp.contains('a=identity'), 'a=identity is contained in the answer SDP');
|
||||
test.next();
|
||||
}
|
||||
]
|
||||
|
@ -672,7 +672,11 @@ PeerConnectionTest.prototype.setStepTimeout = function(ms) {
|
||||
*/
|
||||
PeerConnectionTest.prototype.createAnswer =
|
||||
function PCT_createAnswer(peer, onSuccess) {
|
||||
var self = this;
|
||||
|
||||
peer.createAnswer(function (answer) {
|
||||
// make a copy so this does not get updated with ICE candidates
|
||||
self.originalAnswer = new mozRTCSessionDescription(JSON.parse(JSON.stringify(answer)));
|
||||
onSuccess(answer);
|
||||
});
|
||||
};
|
||||
@ -688,7 +692,11 @@ function PCT_createAnswer(peer, onSuccess) {
|
||||
*/
|
||||
PeerConnectionTest.prototype.createOffer =
|
||||
function PCT_createOffer(peer, onSuccess) {
|
||||
var self = this;
|
||||
|
||||
peer.createOffer(function (offer) {
|
||||
// make a copy so this does not get updated with ICE candidates
|
||||
self.originalOffer = new mozRTCSessionDescription(JSON.parse(JSON.stringify(offer)));
|
||||
onSuccess(offer);
|
||||
});
|
||||
};
|
||||
@ -828,6 +836,37 @@ PeerConnectionTest.prototype.teardown = function PCT_teardown() {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Routes ice candidates from one PCW to the other PCW
|
||||
*/
|
||||
PeerConnectionTest.prototype.iceCandidateHandler = function
|
||||
PCT_iceCandidateHandler(caller, candidate) {
|
||||
var self = this;
|
||||
|
||||
info("Received: " + JSON.stringify(candidate) + " from " + caller);
|
||||
|
||||
var target = null;
|
||||
if (caller.contains("pcLocal")) {
|
||||
if (self.pcRemote) {
|
||||
target = self.pcRemote;
|
||||
}
|
||||
} else if (caller.contains("pcRemote")) {
|
||||
if (self.pcLocal) {
|
||||
target = self.pcLocal;
|
||||
}
|
||||
} else {
|
||||
ok(false, "received event from unknown caller: " + caller);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target) {
|
||||
target.storeOrAddIceCandidate(candidate);
|
||||
} else {
|
||||
info("sending ice candidate to signaling server");
|
||||
send_message({"ice_candidate": candidate});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This class handles tests for data channels.
|
||||
*
|
||||
@ -1103,6 +1142,12 @@ DataChannelTest.prototype = Object.create(PeerConnectionTest.prototype, {
|
||||
}
|
||||
},
|
||||
|
||||
createOffer : {
|
||||
value : function DCT_createOffer(peer, onSuccess) {
|
||||
PeerConnectionTest.prototype.createOffer.call(this, peer, onSuccess);
|
||||
}
|
||||
},
|
||||
|
||||
setLocalDescription : {
|
||||
/**
|
||||
* Sets the local description for the specified peer connection instance
|
||||
@ -1372,6 +1417,11 @@ function PeerConnectionWrapper(label, configuration, h264) {
|
||||
this.onAddStreamFired = false;
|
||||
this.addStreamCallbacks = {};
|
||||
|
||||
this.remoteDescriptionSet = false;
|
||||
this.endOfTrickleIce = false;
|
||||
this.localRequiresTrickleIce = false;
|
||||
this.remoteRequiresTrickleIce = false;
|
||||
|
||||
this.h264 = typeof h264 !== "undefined" ? true : false;
|
||||
|
||||
info("Creating " + this);
|
||||
@ -1648,7 +1698,8 @@ PeerConnectionWrapper.prototype = {
|
||||
|
||||
this._pc.createOffer(function (offer) {
|
||||
info("Got offer: " + JSON.stringify(offer));
|
||||
self._last_offer = offer;
|
||||
// note: this might get updated through ICE gathering
|
||||
self._latest_offer = offer;
|
||||
if (self.h264) {
|
||||
isnot(offer.sdp.search("H264/90000"), -1, "H.264 should be present in the SDP offer");
|
||||
offer.sdp = removeVP8(offer.sdp);
|
||||
@ -1720,6 +1771,15 @@ PeerConnectionWrapper.prototype = {
|
||||
var self = this;
|
||||
this._pc.setRemoteDescription(desc, function () {
|
||||
info(self + ": Successfully set remote description");
|
||||
self.remoteDescriptionSet = true;
|
||||
if ((self._ice_candidates_to_add) &&
|
||||
(self._ice_candidates_to_add.length > 0)) {
|
||||
info("adding stored ice candidates");
|
||||
for (var i = 0; i < self._ice_candidates_to_add.length; i++) {
|
||||
self.addIceCandidate(self._ice_candidates_to_add[i]);
|
||||
}
|
||||
self._ice_candidates_to_add = [];
|
||||
}
|
||||
onSuccess();
|
||||
}, generateErrorCallback());
|
||||
},
|
||||
@ -1765,6 +1825,24 @@ PeerConnectionWrapper.prototype = {
|
||||
self.signalingStateCallbacks.logSignalingStatus = _logSignalingState;
|
||||
},
|
||||
|
||||
/**
|
||||
* Either adds a given ICE candidate right away or stores it to be added
|
||||
* later, depending on the state of the PeerConnection.
|
||||
*
|
||||
* @param {object} candidate
|
||||
* The mozRTCIceCandidate to be added or stored
|
||||
*/
|
||||
storeOrAddIceCandidate : function PCW_storeOrAddIceCandidate(candidate) {
|
||||
var self = this;
|
||||
|
||||
self._remote_ice_candidates.push(candidate);
|
||||
if (self.remoteDescriptionSet) {
|
||||
self.addIceCandidate(candidate);
|
||||
} else {
|
||||
self._ice_candidates_to_add.push(candidate);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds an ICE candidate and automatically handles the failure case.
|
||||
*
|
||||
@ -1776,9 +1854,12 @@ PeerConnectionWrapper.prototype = {
|
||||
addIceCandidate : function PCW_addIceCandidate(candidate, onSuccess) {
|
||||
var self = this;
|
||||
|
||||
info(self + ": adding ICE candidate " + JSON.stringify(candidate));
|
||||
this._pc.addIceCandidate(candidate, function () {
|
||||
info(self + ": Successfully added an ICE candidate");
|
||||
onSuccess();
|
||||
if (onSuccess) {
|
||||
onSuccess();
|
||||
}
|
||||
}, generateErrorCallback());
|
||||
},
|
||||
|
||||
@ -1808,7 +1889,7 @@ PeerConnectionWrapper.prototype = {
|
||||
* @returns {boolean} True if the connection state is "connected", otherwise false.
|
||||
*/
|
||||
isIceConnected : function PCW_isIceConnected() {
|
||||
info("iceConnectionState: " + this.iceConnectionState);
|
||||
info(this + ": iceConnectionState = " + this.iceConnectionState);
|
||||
return this.iceConnectionState === "connected";
|
||||
},
|
||||
|
||||
@ -1892,6 +1973,43 @@ PeerConnectionWrapper.prototype = {
|
||||
self.ice_connection_callbacks.waitForIceConnected = iceConnectedChanged;
|
||||
},
|
||||
|
||||
/**
|
||||
* Setup a onicecandidate handler
|
||||
*
|
||||
* @param {object} test
|
||||
* A PeerConnectionTest object to which the ice candidates gets
|
||||
* forwarded.
|
||||
*/
|
||||
setupIceCandidateHandler : function PCW_setupIceCandidateHandler(test) {
|
||||
var self = this;
|
||||
self._local_ice_candidates = [];
|
||||
self._remote_ice_candidates = [];
|
||||
self._ice_candidates_to_add = [];
|
||||
|
||||
function iceCandidateCallback (anEvent) {
|
||||
info(self.label + ": received iceCandidateEvent");
|
||||
if (!anEvent.candidate) {
|
||||
info(self.label + ": received end of trickle ICE event");
|
||||
self.endOfTrickleIce = true;
|
||||
} else {
|
||||
if (self.endOfTrickleIce) {
|
||||
ok(false, "received ICE candidate after end of trickle");
|
||||
}
|
||||
info(self.label + ": iceCandidate = " + JSON.stringify(anEvent.candidate));
|
||||
ok(anEvent.candidate.candidate.length > 0, "ICE candidate contains candidate");
|
||||
// we don't support SDP MID's yet
|
||||
ok(anEvent.candidate.sdpMid.length === 0, "SDP MID has length zero");
|
||||
ok(typeof anEvent.candidate.sdpMLineIndex === 'number', "SDP MLine Index needs to exist");
|
||||
self._local_ice_candidates.push(anEvent.candidate);
|
||||
test.iceCandidateHandler(self.label, anEvent.candidate);
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME: in the steeplecase scenario we need to setup a permanent listener
|
||||
// for ice candidates from the signaling server here
|
||||
self._pc.onicecandidate = iceCandidateCallback;
|
||||
},
|
||||
|
||||
/**
|
||||
* Counts the amount of audio tracks in a given media constraint.
|
||||
*
|
||||
@ -2073,7 +2191,8 @@ PeerConnectionWrapper.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
verifySdp : function PCW_verifySdp(desc, expectedType, constraints, offerOptions) {
|
||||
verifySdp : function PCW_verifySdp(desc, expectedType, constraints,
|
||||
offerOptions, trickleIceCallback) {
|
||||
info("Examining this SessionDescription: " + JSON.stringify(desc));
|
||||
info("constraints: " + JSON.stringify(constraints));
|
||||
info("offerOptions: " + JSON.stringify(offerOptions));
|
||||
@ -2085,8 +2204,13 @@ PeerConnectionWrapper.prototype = {
|
||||
ok(desc.sdp.contains("a=fingerprint"), "ICE fingerprint is present in SDP");
|
||||
//TODO: update this for loopback support bug 1027350
|
||||
ok(!desc.sdp.contains(LOOPBACK_ADDR), "loopback interface is absent from SDP");
|
||||
//TODO: update this for trickle ICE bug 1041832
|
||||
ok(desc.sdp.contains("a=candidate"), "at least one ICE candidate is present in SDP");
|
||||
if (desc.sdp.contains("a=candidate")) {
|
||||
ok(true, "at least one ICE candidate is present in SDP");
|
||||
trickleIceCallback(false);
|
||||
} else {
|
||||
info("No ICE candidate in SDP -> requiring trickle ICE");
|
||||
trickleIceCallback(true);
|
||||
}
|
||||
//TODO: how can we check for absence/presence of m=application?
|
||||
|
||||
//TODO: how to handle media contraints + offer options
|
||||
|
@ -2,12 +2,15 @@
|
||||
* Default list of commands to execute for a PeerConnection test.
|
||||
*/
|
||||
|
||||
var STABLE = "stable";
|
||||
var HAVE_LOCAL_OFFER = "have-local-offer";
|
||||
var HAVE_REMOTE_OFFER = "have-remote-offer";
|
||||
var CLOSED = "closed";
|
||||
const STABLE = "stable";
|
||||
const HAVE_LOCAL_OFFER = "have-local-offer";
|
||||
const HAVE_REMOTE_OFFER = "have-remote-offer";
|
||||
const CLOSED = "closed";
|
||||
|
||||
const ICE_NEW = "new";
|
||||
const GATH_NEW = "new";
|
||||
const GATH_GATH = "gathering";
|
||||
const GATH_COMPLETE = "complete"
|
||||
|
||||
function deltaSeconds(date1, date2) {
|
||||
return (date2.getTime() - date1.getTime())/1000;
|
||||
@ -122,6 +125,20 @@ var commandsPeerConnection = [
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SETUP_ICE_HANDLER',
|
||||
function (test) {
|
||||
test.pcLocal.setupIceCandidateHandler(test);
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SETUP_ICE_HANDLER',
|
||||
function (test) {
|
||||
test.pcRemote.setupIceCandidateHandler(test);
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_CREATE_OFFER',
|
||||
function (test) {
|
||||
@ -129,7 +146,7 @@ var commandsPeerConnection = [
|
||||
is(test.pcLocal.signalingState, STABLE,
|
||||
"Local create offer does not change signaling state");
|
||||
if (!test.pcRemote) {
|
||||
send_message({"offer": test.pcLocal._last_offer,
|
||||
send_message({"offer": test.originalOffer,
|
||||
"offer_constraints": test.pcLocal.constraints,
|
||||
"offer_options": test.pcLocal.offerOptions});
|
||||
test._local_offer = test.pcLocal._last_offer;
|
||||
@ -143,7 +160,7 @@ var commandsPeerConnection = [
|
||||
[
|
||||
'PC_LOCAL_SET_LOCAL_DESCRIPTION',
|
||||
function (test) {
|
||||
test.setLocalDescription(test.pcLocal, test.pcLocal._last_offer, HAVE_LOCAL_OFFER, function () {
|
||||
test.setLocalDescription(test.pcLocal, test.originalOffer, HAVE_LOCAL_OFFER, function () {
|
||||
is(test.pcLocal.signalingState, HAVE_LOCAL_OFFER,
|
||||
"signalingState after local setLocalDescription is 'have-local-offer'");
|
||||
test.next();
|
||||
@ -154,7 +171,7 @@ var commandsPeerConnection = [
|
||||
'PC_REMOTE_GET_OFFER',
|
||||
function (test) {
|
||||
if (test.pcLocal) {
|
||||
test._local_offer = test.pcLocal._last_offer;
|
||||
test._local_offer = test.originalOffer;
|
||||
test._offer_constraints = test.pcLocal.constraints;
|
||||
test._offer_options = test.pcLocal.offerOptions;
|
||||
test.next();
|
||||
@ -182,14 +199,22 @@ var commandsPeerConnection = [
|
||||
[
|
||||
'PC_LOCAL_SANE_LOCAL_SDP',
|
||||
function (test) {
|
||||
test.pcLocal.verifySdp(test.pcLocal.localDescription, "offer", test._offer_constraints, test._offer_options);
|
||||
test.pcLocal.verifySdp(test._local_offer, "offer",
|
||||
test._offer_constraints, test._offer_options,
|
||||
function(trickle) {
|
||||
test.pcLocal.localRequiresTrickleIce = trickle;
|
||||
});
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SANE_REMOTE_SDP',
|
||||
function (test) {
|
||||
test.pcRemote.verifySdp(test.pcRemote.remoteDescription, "offer", test._offer_constraints, test._offer_options);
|
||||
test.pcRemote.verifySdp(test._local_offer, "offer",
|
||||
test._offer_constraints, test._offer_options,
|
||||
function (trickle) {
|
||||
test.pcRemote.remoteRequiresTrickleIce = trickle;
|
||||
});
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
@ -200,7 +225,7 @@ var commandsPeerConnection = [
|
||||
is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER,
|
||||
"Remote createAnswer does not change signaling state");
|
||||
if (!test.pcLocal) {
|
||||
send_message({"answer": test.pcRemote._last_answer,
|
||||
send_message({"answer": test.originalAnswer,
|
||||
"answer_constraints": test.pcRemote.constraints});
|
||||
test._remote_answer = test.pcRemote._last_answer;
|
||||
test._answer_constraints = test.pcRemote.constraints;
|
||||
@ -236,16 +261,16 @@ var commandsPeerConnection = [
|
||||
return resultArray;
|
||||
}
|
||||
|
||||
const offerTriples = _sdpCandidatesIntoArray(test._local_offer.sdp);
|
||||
const offerTriples = _sdpCandidatesIntoArray(test.originalOffer.sdp);
|
||||
info("Offer ICE host candidates: " + JSON.stringify(offerTriples));
|
||||
|
||||
const answerTriples = _sdpCandidatesIntoArray(test.pcRemote._last_answer.sdp);
|
||||
const answerTriples = _sdpCandidatesIntoArray(test.originalAnswer.sdp);
|
||||
info("Answer ICE host candidates: " + JSON.stringify(answerTriples));
|
||||
|
||||
for (var i=0; i< offerTriples.length; i++) {
|
||||
if (answerTriples.indexOf(offerTriples[i]) !== -1) {
|
||||
dump("SDP offer: " + test._local_offer.sdp.replace(/[\r]/g, '') + "\n");
|
||||
dump("SDP answer: " + test.pcRemote._last_answer.sdp.replace(/[\r]/g, '') + "\n");
|
||||
dump("SDP offer: " + test.originalOffer.sdp.replace(/[\r]/g, '') + "\n");
|
||||
dump("SDP answer: " + test.originalAnswer.sdp.replace(/[\r]/g, '') + "\n");
|
||||
ok(false, "This IP:Port " + offerTriples[i] + " appears in SDP offer and answer!");
|
||||
}
|
||||
}
|
||||
@ -256,18 +281,20 @@ var commandsPeerConnection = [
|
||||
[
|
||||
'PC_REMOTE_SET_LOCAL_DESCRIPTION',
|
||||
function (test) {
|
||||
test.setLocalDescription(test.pcRemote, test.pcRemote._last_answer, STABLE, function () {
|
||||
is(test.pcRemote.signalingState, STABLE,
|
||||
"signalingState after remote setLocalDescription is 'stable'");
|
||||
test.next();
|
||||
});
|
||||
test.setLocalDescription(test.pcRemote, test.originalAnswer, STABLE,
|
||||
function () {
|
||||
is(test.pcRemote.signalingState, STABLE,
|
||||
"signalingState after remote setLocalDescription is 'stable'");
|
||||
test.next();
|
||||
}
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_GET_ANSWER',
|
||||
function (test) {
|
||||
if (test.pcRemote) {
|
||||
test._remote_answer = test.pcRemote._last_answer;
|
||||
test._remote_answer = test.originalAnswer;
|
||||
test._answer_constraints = test.pcRemote.constraints;
|
||||
test.next();
|
||||
} else {
|
||||
@ -283,24 +310,34 @@ var commandsPeerConnection = [
|
||||
[
|
||||
'PC_LOCAL_SET_REMOTE_DESCRIPTION',
|
||||
function (test) {
|
||||
test.setRemoteDescription(test.pcLocal, test._remote_answer, STABLE, function () {
|
||||
is(test.pcLocal.signalingState, STABLE,
|
||||
"signalingState after local setRemoteDescription is 'stable'");
|
||||
test.next();
|
||||
});
|
||||
test.setRemoteDescription(test.pcLocal, test._remote_answer, STABLE,
|
||||
function () {
|
||||
is(test.pcLocal.signalingState, STABLE,
|
||||
"signalingState after local setRemoteDescription is 'stable'");
|
||||
test.next();
|
||||
}
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SANE_LOCAL_SDP',
|
||||
function (test) {
|
||||
test.pcRemote.verifySdp(test.pcRemote.localDescription, "answer", test._answer_constraints, test._offer_options);
|
||||
test.pcRemote.verifySdp(test._remote_answer, "answer",
|
||||
test._answer_constraints, test._offer_options,
|
||||
function (trickle) {
|
||||
test.pcRemote.localRequiresTrickleIce = trickle;
|
||||
});
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SANE_REMOTE_SDP',
|
||||
function (test) {
|
||||
test.pcLocal.verifySdp(test.pcLocal.remoteDescription, "answer", test._answer_constraints, test._offer_options);
|
||||
test.pcLocal.verifySdp(test._remote_answer, "answer",
|
||||
test._answer_constraints, test._offer_options,
|
||||
function (trickle) {
|
||||
test.pcLocal.remoteRequiresTrickleIce = trickle;
|
||||
});
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
@ -334,6 +371,18 @@ var commandsPeerConnection = [
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_VERIFY_ICE_GATHERING',
|
||||
function (test) {
|
||||
if (test.pcLocal.localRequiresTrickleIce) {
|
||||
ok(test.pcLocal._local_ice_candidates.length > 0, "Received local trickle ICE candidates");
|
||||
}
|
||||
// a super slow TURN server might make this fail
|
||||
ok(test.pcLocal.endOfTrickleIce, "Received end of ICE gathering candidate");
|
||||
isnot(test.pcLocal._pc.iceGatheringState, GATH_NEW, "ICE gathering state is not 'new'");
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_WAIT_FOR_ICE_CONNECTED',
|
||||
function (test) {
|
||||
@ -364,6 +413,18 @@ var commandsPeerConnection = [
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_VERIFY_ICE_GATHERING',
|
||||
function (test) {
|
||||
if (test.pcRemote.localRequiresTrickleIce) {
|
||||
ok(test.pcRemote._local_ice_candidates.length > 0, "Received local trickle ICE candidates");
|
||||
}
|
||||
// a super slow TURN server might make this fail
|
||||
ok(test.pcRemote.endOfTrickleIce, "Received end of ICE gathering candidate");
|
||||
isnot(test.pcRemote._pc.iceGatheringState, GATH_NEW, "ICE gathering state is not 'new'");
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_CHECK_MEDIA_TRACKS',
|
||||
function (test) {
|
||||
@ -665,6 +726,20 @@ var commandsDataChannel = [
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SETUP_ICE_HANDLER',
|
||||
function (test) {
|
||||
test.pcLocal.setupIceCandidateHandler(test);
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SETUP_ICE_HANDLER',
|
||||
function (test) {
|
||||
test.pcRemote.setupIceCandidateHandler(test);
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_CREATE_DATA_CHANNEL',
|
||||
function (test) {
|
||||
@ -682,13 +757,19 @@ var commandsDataChannel = [
|
||||
[
|
||||
'PC_LOCAL_CREATE_OFFER',
|
||||
function (test) {
|
||||
test.pcLocal.createOffer(function (offer) {
|
||||
test.createOffer(test.pcLocal, function (offer) {
|
||||
is(test.pcLocal.signalingState, STABLE,
|
||||
"Local create offer does not change signaling state");
|
||||
ok(!offer.sdp.contains(LOOPBACK_ADDR),
|
||||
"loopback interface is absent from SDP");
|
||||
ok(offer.sdp.contains("m=application"),
|
||||
"m=application is contained in the SDP");
|
||||
if (!test.pcRemote) {
|
||||
send_message({"offer": test.originalOffer,
|
||||
"offer_constraints": test.pcLocal.constraints,
|
||||
"offer_options": test.pcLocal.offerOptions});
|
||||
test._local_offer = test.pcLocal._last_offer;
|
||||
test._offer_constraints = test.pcLocal.constraints;
|
||||
test._offer_options = test.pcLocal.offerOptions;
|
||||
}
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
@ -696,7 +777,7 @@ var commandsDataChannel = [
|
||||
[
|
||||
'PC_LOCAL_SET_LOCAL_DESCRIPTION',
|
||||
function (test) {
|
||||
test.setLocalDescription(test.pcLocal, test.pcLocal._last_offer, HAVE_LOCAL_OFFER,
|
||||
test.setLocalDescription(test.pcLocal, test.originalOffer, HAVE_LOCAL_OFFER,
|
||||
function () {
|
||||
is(test.pcLocal.signalingState, HAVE_LOCAL_OFFER,
|
||||
"signalingState after local setLocalDescription is 'have-local-offer'");
|
||||
@ -704,10 +785,29 @@ var commandsDataChannel = [
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_GET_OFFER',
|
||||
function (test) {
|
||||
if (test.pcLocal) {
|
||||
test._local_offer = test.originalOffer;
|
||||
test._offer_constraints = test.pcLocal.constraints;
|
||||
test._offer_options = test.pcLocal.offerOptions;
|
||||
test.next();
|
||||
} else {
|
||||
wait_for_message().then(function(message) {
|
||||
ok("offer" in message, "Got an offer message");
|
||||
test._local_offer = new mozRTCSessionDescription(message.offer);
|
||||
test._offer_constraints = message.offer_constraints;
|
||||
test._offer_options = message.offer_options;
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SET_REMOTE_DESCRIPTION',
|
||||
function (test) {
|
||||
test.setRemoteDescription(test.pcRemote, test.pcLocal._last_offer, HAVE_REMOTE_OFFER,
|
||||
test.setRemoteDescription(test.pcRemote, test._local_offer, HAVE_REMOTE_OFFER,
|
||||
function () {
|
||||
is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER,
|
||||
"signalingState after remote setRemoteDescription is 'have-remote-offer'");
|
||||
@ -718,14 +818,22 @@ var commandsDataChannel = [
|
||||
[
|
||||
'PC_LOCAL_SANE_LOCAL_SDP',
|
||||
function (test) {
|
||||
test.pcLocal.verifySdp(test.pcLocal.localDescription, "offer", test.pcLocal.constraints);
|
||||
test.pcLocal.verifySdp(test._local_offer, "offer",
|
||||
test._offer_constraints, test._offer_options,
|
||||
function(trickle) {
|
||||
test.pcLocal.localRequiresTrickleIce = trickle;
|
||||
});
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SANE_REMOTE_SDP',
|
||||
function (test) {
|
||||
test.pcRemote.verifySdp(test.pcRemote.remoteDescription, "offer", test.pcLocal.constraints);
|
||||
test.pcRemote.verifySdp(test._local_offer, "offer",
|
||||
test._offer_constraints, test._offer_options,
|
||||
function (trickle) {
|
||||
test.pcRemote.remoteRequiresTrickleIce = trickle;
|
||||
});
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
@ -734,9 +842,15 @@ var commandsDataChannel = [
|
||||
function (test) {
|
||||
test.createAnswer(test.pcRemote, function (answer) {
|
||||
is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER,
|
||||
"Remote create offer does not change signaling state");
|
||||
ok(!answer.sdp.contains(LOOPBACK_ADDR),
|
||||
"loopback interface is absent in SDP");
|
||||
"Remote createAnswer does not change signaling state");
|
||||
ok(answer.sdp.contains("m=application"),
|
||||
"m=application is contained in the SDP");
|
||||
if (!test.pcLocal) {
|
||||
send_message({"answer": test.originalAnswer,
|
||||
"answer_constraints": test.pcRemote.constraints});
|
||||
test._remote_answer = test.pcRemote._last_answer;
|
||||
test._answer_constraints = test.pcRemote.constraints;
|
||||
}
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
@ -766,37 +880,63 @@ var commandsDataChannel = [
|
||||
[
|
||||
'PC_REMOTE_SET_LOCAL_DESCRIPTION',
|
||||
function (test) {
|
||||
test.setLocalDescription(test.pcRemote, test.pcRemote._last_answer, STABLE,
|
||||
test.setLocalDescription(test.pcRemote, test.originalAnswer, STABLE,
|
||||
function () {
|
||||
is(test.pcRemote.signalingState, STABLE,
|
||||
"signalingState after remote setLocalDescription is 'stable'");
|
||||
"signalingState after remote setLocalDescription is 'stable'");
|
||||
test.next();
|
||||
}
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_GET_ANSWER',
|
||||
function (test) {
|
||||
if (test.pcRemote) {
|
||||
test._remote_answer = test.originalAnswer;
|
||||
test._answer_constraints = test.pcRemote.constraints;
|
||||
test.next();
|
||||
} else {
|
||||
wait_for_message().then(function(message) {
|
||||
ok("answer" in message, "Got an answer message");
|
||||
test._remote_answer = new mozRTCSessionDescription(message.answer);
|
||||
test._answer_constraints = message.answer_constraints;
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SET_REMOTE_DESCRIPTION',
|
||||
function (test) {
|
||||
test.setRemoteDescription(test.pcLocal, test.pcRemote._last_answer, STABLE,
|
||||
test.setRemoteDescription(test.pcLocal, test._remote_answer, STABLE,
|
||||
function () {
|
||||
is(test.pcLocal.signalingState, STABLE,
|
||||
"signalingState after local setRemoteDescription is 'stable'");
|
||||
test.next();
|
||||
});
|
||||
is(test.pcLocal.signalingState, STABLE,
|
||||
"signalingState after local setRemoteDescription is 'stable'");
|
||||
test.next();
|
||||
}
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_SANE_LOCAL_SDP',
|
||||
function (test) {
|
||||
test.pcRemote.verifySdp(test.pcRemote.localDescription, "answer", test.pcRemote.constraints);
|
||||
test.pcRemote.verifySdp(test._remote_answer, "answer",
|
||||
test._answer_constraints, test._offer_options,
|
||||
function (trickle) {
|
||||
test.pcRemote.localRequiresTrickleIce = trickle;
|
||||
});
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_SANE_REMOTE_SDP',
|
||||
function (test) {
|
||||
test.pcLocal.verifySdp(test.pcLocal.remoteDescription, "answer", test.pcRemote.constraints);
|
||||
test.pcLocal.verifySdp(test._remote_answer, "answer",
|
||||
test._answer_constraints, test._offer_options,
|
||||
function (trickle) {
|
||||
test.pcLocal.remoteRequiresTrickleIce = trickle;
|
||||
});
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
@ -830,6 +970,18 @@ var commandsDataChannel = [
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_VERIFY_ICE_GATHERING',
|
||||
function (test) {
|
||||
if (test.pcLocal.localRequiresTrickleIce) {
|
||||
ok(test.pcLocal._local_ice_candidates.length > 0, "Received local trickle ICE candidates");
|
||||
}
|
||||
// a super slow TURN server might make this fail
|
||||
ok(test.pcLocal.endOfTrickleIce, "Received end of ICE gathering candidate");
|
||||
isnot(test.pcLocal._pc.iceGatheringState, GATH_NEW, "ICE gathering state is not 'new'");
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_WAIT_FOR_ICE_CONNECTED',
|
||||
function (test) {
|
||||
@ -860,6 +1012,18 @@ var commandsDataChannel = [
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_REMOTE_VERIFY_ICE_GATHERING',
|
||||
function (test) {
|
||||
if (test.pcRemote.localRequiresTrickleIce) {
|
||||
ok(test.pcRemote._local_ice_candidates.length > 0, "Received local trickle ICE candidates");
|
||||
}
|
||||
// a super slow TURN server might make this fail
|
||||
ok(test.pcRemote.endOfTrickleIce, "Received end of ICE gathering candidate");
|
||||
isnot(test.pcRemote._pc.iceGatheringState, GATH_NEW, "ICE gathering state is not 'new'");
|
||||
test.next();
|
||||
}
|
||||
],
|
||||
[
|
||||
'PC_LOCAL_VERIFY_DATA_CHANNEL_STATE',
|
||||
function (test) {
|
||||
@ -891,7 +1055,7 @@ var commandsDataChannel = [
|
||||
[
|
||||
'PC_LOCAL_CHECK_MEDIA_TRACKS',
|
||||
function (test) {
|
||||
test.pcLocal.checkMediaTracks(test.pcRemote.constraints, function () {
|
||||
test.pcLocal.checkMediaTracks(test._answer_constraints, function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
@ -899,7 +1063,7 @@ var commandsDataChannel = [
|
||||
[
|
||||
'PC_REMOTE_CHECK_MEDIA_TRACKS',
|
||||
function (test) {
|
||||
test.pcRemote.checkMediaTracks(test.pcLocal.constraints, function () {
|
||||
test.pcRemote.checkMediaTracks(test._offer_constraints, function () {
|
||||
test.next();
|
||||
});
|
||||
}
|
||||
|
@ -28,9 +28,9 @@
|
||||
test.chain.append([[
|
||||
"PC_LOCAL_VERIFY_H264_OFFER",
|
||||
function (test) {
|
||||
ok(!test.pcLocal._last_offer.sdp.toLowerCase().contains("profile-level-id=0x42e0"),
|
||||
ok(!test.pcLocal._latest_offer.sdp.toLowerCase().contains("profile-level-id=0x42e0"),
|
||||
"H264 offer does not contain profile-level-id=0x42e0");
|
||||
ok(test.pcLocal._last_offer.sdp.toLowerCase().contains("profile-level-id=42e0"),
|
||||
ok(test.pcLocal._latest_offer.sdp.toLowerCase().contains("profile-level-id=42e0"),
|
||||
"H264 offer contains profile-level-id=42e0");
|
||||
test.next();
|
||||
}
|
||||
|
@ -26,8 +26,8 @@
|
||||
test.chain.append([[
|
||||
"PC_LOCAL_SET_LOCAL_ANSWER",
|
||||
function (test) {
|
||||
test.pcLocal._last_offer.type="answer";
|
||||
test.pcLocal.setLocalDescriptionAndFail(test.pcLocal._last_offer,
|
||||
test.pcLocal._latest_offer.type="answer";
|
||||
test.pcLocal.setLocalDescriptionAndFail(test.pcLocal._latest_offer,
|
||||
function(err) {
|
||||
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
|
||||
test.next();
|
||||
|
@ -26,8 +26,8 @@
|
||||
test.chain.append([[
|
||||
"PC_LOCAL_SET_LOCAL_ANSWER",
|
||||
function (test) {
|
||||
test.pcLocal._last_offer.type="answer";
|
||||
test.pcLocal.setLocalDescriptionAndFail(test.pcLocal._last_offer,
|
||||
test.pcLocal._latest_offer.type="answer";
|
||||
test.pcLocal.setLocalDescriptionAndFail(test.pcLocal._latest_offer,
|
||||
function(err) {
|
||||
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
|
||||
test.next();
|
||||
|
@ -26,7 +26,7 @@
|
||||
test.chain.append([[
|
||||
"PC_REMOTE_SET_LOCAL_OFFER",
|
||||
function (test) {
|
||||
test.pcRemote.setLocalDescriptionAndFail(test.pcLocal._last_offer,
|
||||
test.pcRemote.setLocalDescriptionAndFail(test.pcLocal._latest_offer,
|
||||
function(err) {
|
||||
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
|
||||
test.next();
|
||||
|
@ -26,8 +26,8 @@
|
||||
test.chain.append([[
|
||||
"PC_REMOTE_SET_REMOTE_ANSWER",
|
||||
function (test) {
|
||||
test.pcLocal._last_offer.type="answer";
|
||||
test.pcRemote.setRemoteDescriptionAndFail(test.pcLocal._last_offer,
|
||||
test.pcLocal._latest_offer.type="answer";
|
||||
test.pcRemote.setRemoteDescriptionAndFail(test.pcLocal._latest_offer,
|
||||
function(err) {
|
||||
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
|
||||
test.next();
|
||||
|
@ -26,8 +26,8 @@
|
||||
test.chain.append([[
|
||||
"PC_LOCAL_SET_REMOTE_ANSWER",
|
||||
function (test) {
|
||||
test.pcLocal._last_offer.type="answer";
|
||||
test.pcLocal.setRemoteDescriptionAndFail(test.pcLocal._last_offer,
|
||||
test.pcLocal._latest_offer.type="answer";
|
||||
test.pcLocal.setRemoteDescriptionAndFail(test.pcLocal._latest_offer,
|
||||
function(err) {
|
||||
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
|
||||
test.next();
|
||||
|
@ -26,7 +26,7 @@
|
||||
test.chain.append([[
|
||||
"PC_LOCAL_SET_REMOTE_OFFER",
|
||||
function (test) {
|
||||
test.pcLocal.setRemoteDescriptionAndFail(test.pcLocal._last_offer,
|
||||
test.pcLocal.setRemoteDescriptionAndFail(test.pcLocal._latest_offer,
|
||||
function(err) {
|
||||
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
|
||||
test.next();
|
||||
|
Loading…
Reference in New Issue
Block a user