Bug 1064674 - mochitest for non-spec set(Local|Remote)Description wo/callbacks. r=jesup, r=drno

This commit is contained in:
Jan-Ivar Bruaroey 2014-09-08 23:36:47 -04:00
Родитель 740f45d249
Коммит f2cfaf243a
3 изменённых файлов: 114 добавлений и 15 удалений

Просмотреть файл

@ -106,6 +106,8 @@ skip-if = toolkit == 'gonk' # b2g(Bug 960442, video support for WebRTC is disabl
skip-if = toolkit == 'gonk' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
[test_peerConnection_replaceTrack.html]
skip-if = toolkit == 'gonk' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
[test_peerConnection_syncSetDescription.html]
skip-if = toolkit == 'gonk' # b2g(Bug 960442, video support for WebRTC is disabled on b2g)
[test_peerConnection_setLocalAnswerInHaveLocalOffer.html]
skip-if = toolkit == 'gonk' # b2g (Bug 1059867)
[test_peerConnection_setLocalAnswerInStable.html]

Просмотреть файл

@ -1534,7 +1534,7 @@ function PeerConnectionWrapper(label, configuration, h264) {
this.onAddStreamFired = false;
this.addStreamCallbacks = {};
this.remoteDescriptionSet = false;
this.holdIceCandidates = true;
this.endOfTrickleIce = false;
this.localRequiresTrickleIce = false;
this.remoteRequiresTrickleIce = false;
@ -1851,10 +1851,15 @@ PeerConnectionWrapper.prototype = {
*/
setLocalDescription : function PCW_setLocalDescription(desc, onSuccess) {
var self = this;
this._pc.setLocalDescription(desc, function () {
info(self + ": Successfully set the local description");
onSuccess();
}, generateErrorCallback());
if (onSuccess) {
this._pc.setLocalDescription(desc, function () {
info(self + ": Successfully set the local description");
onSuccess();
}, generateErrorCallback());
} else {
this._pc.setLocalDescription(desc);
}
},
/**
@ -1886,17 +1891,15 @@ PeerConnectionWrapper.prototype = {
*/
setRemoteDescription : function PCW_setRemoteDescription(desc, onSuccess) {
var self = this;
if (!onSuccess) {
this._pc.setRemoteDescription(desc);
this.addStoredIceCandidates();
return;
}
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 = [];
}
self.addStoredIceCandidates();
onSuccess();
}, generateErrorCallback());
},
@ -1957,13 +1960,27 @@ PeerConnectionWrapper.prototype = {
info("Received ICE candidate for closed PeerConnection - discarding");
return;
}
if (self.remoteDescriptionSet) {
if (!self.holdIceCandidates) {
self.addIceCandidate(candidate);
} else {
self._ice_candidates_to_add.push(candidate);
}
},
addStoredIceCandidates : function PCW_addStoredIceCandidates() {
var self = this;
self.holdIceCandidates = false;
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 = [];
}
},
/**
* Adds an ICE candidate and automatically handles the failure case.
*

Просмотреть файл

@ -0,0 +1,80 @@
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"></script>
<script type="application/javascript" src="mediaStreamPlayback.js"></script>
<script type="application/javascript" src="pc.js"></script>
<script type="application/javascript" src="templates.js"></script>
<script type="application/javascript" src="turnConfig.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript;version=1.8">
createHTML({
bug: "1063971",
title: "Legacy sync setDescription calls",
visible: true
});
// Test setDescription without callbacks, which many webrtc examples still do
var pc1_local =
[[
'PC_LOCAL_SET_LOCAL_DESCRIPTION_SYNC',
function (test) {
test.pcLocal.onsignalingstatechange = function() {};
test.pcLocal.setLocalDescription(test.originalOffer);
test.next();
}
]];
var pc2_remote =
[[
'PC_REMOTE_SET_REMOTE_DESCRIPTION_SYNC',
function (test) {
test.pcRemote.onsignalingstatechange = function() {};
test.pcRemote.setRemoteDescription(test._local_offer);
test.next();
}
]];
var pc2_local =
[[
'PC_REMOTE_SET_LOCAL_DESCRIPTION_SYNC',
function (test) {
test.pcRemote.onsignalingstatechange = function() {};
test.pcRemote.setLocalDescription(test.originalAnswer);
test.next();
}
]];
var pc1_remote =
[[
'PC_LOCAL_SET_REMOTE_DESCRIPTION_SYNC',
function (test) {
test.pcLocal.onsignalingstatechange = function() {};
test.pcLocal.setRemoteDescription(test._remote_answer);
test.next();
}
]];
runNetworkTest(function () {
function replace(test, name, command) {
test.chain.insertAfter(name, command);
test.chain.remove(name);
}
var test = new PeerConnectionTest();
test.setMediaConstraints([{video: true}], [{video: true}]);
replace(test, "PC_LOCAL_SET_LOCAL_DESCRIPTION", pc1_local);
replace(test, "PC_REMOTE_SET_REMOTE_DESCRIPTION", pc2_remote);
replace(test, "PC_REMOTE_SET_LOCAL_DESCRIPTION", pc2_local);
replace(test, "PC_LOCAL_SET_REMOTE_DESCRIPTION", pc1_remote);
test.run();
});
</script>
</pre>
</body>
</html>