Backed out changeset 8ec73e6aa7d3 (bug 784519) on a CLOSED TREE

This commit is contained in:
Adam Roach [:abr] 2013-06-06 17:40:21 -05:00
parent bb75a4fc41
commit 2691431b88
10 changed files with 14 additions and 475 deletions

View File

@ -35,13 +35,6 @@ MOCHITEST_FILES = \
test_peerConnection_offerRequiresReceiveVideo.html \
test_peerConnection_offerRequiresReceiveVideoAudio.html \
test_peerConnection_throwInCallbacks.html \
test_peerConnection_setLocalAnswerInStable.html \
test_peerConnection_setRemoteAnswerInStable.html \
test_peerConnection_setLocalAnswerInHaveLocalOffer.html \
test_peerConnection_setRemoteOfferInHaveLocalOffer.html \
test_peerConnection_setLocalOfferInHaveRemoteOffer.html \
test_peerConnection_setRemoteAnswerInHaveRemoteOffer.html \
test_peerConnection_addCandidateInHaveLocalOffer.html \
test_peerConnection_bug822674.html \
test_peerConnection_bug825703.html \
test_peerConnection_bug827843.html \

View File

@ -182,23 +182,11 @@ function unexpectedCallbackAndFinish(error) {
return function(aObj) {
var where = error.fileName + ":" + error.lineNumber;
if (aObj && aObj.name && aObj.message) {
ok(false, "Unexpected callback/event from " + where + " with name = '" +
ok(false, "Unexpected error callback from " + where + " with name = '" +
aObj.name + "', message = '" + aObj.message + "'");
} else {
ok(false, "Unexpected callback/event from " + where + " with " + aObj);
ok(false, "Unexpected error callback from " + where + " with " + aObj);
}
SimpleTest.finish();
}
}
/**
* Generates a callback function suitable for putting int a success
* callback in circumstances where success is unexpected. The callback,
* if activated, will kill off the test gracefully.
*/
function unexpectedSuccessCallbackAndFinish(error, reason) {
return function() {
unexpectedCallbackAndFinish(error)(message);
}
}

View File

@ -246,19 +246,10 @@ var commandsPeerConnection = [
});
}
],
[
'PC_CHECK_INITIAL_SIGNALINGSTATE',
function (test) {
is(test.pcLocal.signalingState,"stable", "Initial local signalingState is stable");
is(test.pcRemote.signalingState,"stable", "Initial remote signalingState is stable");
test.next();
}
],
[
'PC_LOCAL_CREATE_OFFER',
function (test) {
test.pcLocal.createOffer(function () {
is(test.pcLocal.signalingState, "stable", "Local create offer does not change signaling state");
test.next();
});
}
@ -266,24 +257,23 @@ var commandsPeerConnection = [
[
'PC_LOCAL_SET_LOCAL_DESCRIPTION',
function (test) {
test.expectStateChange(test.pcLocal, "have-local-offer", test);
test.pcLocal.setLocalDescription(test.pcLocal._last_offer,
test.checkStateInCallback(test.pcLocal, "have-local-offer", test));
test.pcLocal.setLocalDescription(test.pcLocal._last_offer, function () {
test.next();
});
}
],
[
'PC_REMOTE_SET_REMOTE_DESCRIPTION',
function (test) {
test.expectStateChange(test.pcRemote, "have-remote-offer", test);
test.pcRemote.setRemoteDescription(test.pcLocal._last_offer,
test.checkStateInCallback(test.pcRemote, "have-remote-offer", test));
test.pcRemote.setRemoteDescription(test.pcLocal._last_offer, function () {
test.next();
});
}
],
[
'PC_REMOTE_CREATE_ANSWER',
function (test) {
test.pcRemote.createAnswer(function () {
is(test.pcRemote.signalingState, "have-remote-offer", "Remote create offer does not change signaling state");
test.next();
});
}
@ -291,17 +281,17 @@ var commandsPeerConnection = [
[
'PC_LOCAL_SET_REMOTE_DESCRIPTION',
function (test) {
test.expectStateChange(test.pcLocal, "stable", test);
test.pcLocal.setRemoteDescription(test.pcRemote._last_answer,
test.checkStateInCallback(test.pcLocal, "stable", test));
test.pcLocal.setRemoteDescription(test.pcRemote._last_answer, function () {
test.next();
});
}
],
[
'PC_REMOTE_SET_LOCAL_DESCRIPTION',
function (test) {
test.expectStateChange(test.pcRemote, "stable", test);
test.pcRemote.setLocalDescription(test.pcRemote._last_answer,
test.checkStateInCallback(test.pcRemote, "stable", test));
test.pcRemote.setLocalDescription(test.pcRemote._last_answer, function () {
test.next();
});
}
],
[
@ -404,64 +394,6 @@ PeerConnectionTest.prototype.teardown = function PCT_teardown() {
SimpleTest.finish();
};
/**
* Sets up the "onsignalingstatechange" handler for the indicated peerconnection
* as a one-shot test. If the test.commandSuccess flag is set when the event
* happens, then the next test in the command chain is triggered. After
* running, this sets the event handler so that it will fail the test if
* it fires again before we expect it. This is intended to be used in
* conjunction with checkStateInCallback, below.
*
* @param {pcw} PeerConnectionWrapper
* The peer connection to expect a state change on
* @param {state} string
* The state that we expect to change to
* @param {test} PeerConnectionTest
* The test strucure currently in use.
*/
PeerConnectionTest.prototype.expectStateChange =
function PCT_expectStateChange(pcw, state, test) {
pcw.signalingChangeEvent = false;
pcw._pc.onsignalingstatechange = function() {
pcw._pc.onsignalingstatechange = unexpectedCallbackAndFinish(new Error);
is(pcw._pc.signalingState, state, pcw.label + ": State is " + state + " in onsignalingstatechange");
pcw.signalingChangeEvent = true;
if (pcw.commandSuccess) {
test.next();
} else {
info("Waiting for success callback...");
}
};
}
/**
* Returns a function, suitable for use as a success callback, that
* checks the signaling state of the PC; and, if the signalingstatechange
* event has already fired, moves on to the next test case. This is
* intended to be used in conjunction with expectStateChange, above.
*
* @param {pcw} PeerConnectionWrapper
* The peer connection to expect a state change on
* @param {state} string
* The state that we expect to change to
* @param {test} PeerConnectionTest
* The test strucure currently in use.
*/
PeerConnectionTest.prototype.checkStateInCallback =
function PCT_checkStateInCallback(pcw, state, test) {
pcw.commandSuccess = false;
return function() {
pcw.commandSuccess = true;
is(pcw.signalingState, state, pcw.label + ": State is " + state + " in success callback");
if (pcw.signalingChangeEvent) {
test.next();
} else {
info("Waiting for signalingstatechange event...");
}
};
}
/**
* This class handles acts as a wrapper around a PeerConnection instance.
@ -488,9 +420,6 @@ function PeerConnectionWrapper(label, configuration) {
// Bug 834835: Assume type is video until we get get{Audio,Video}Tracks.
self.attachMedia(event.stream, 'video', 'remote');
};
// Make sure no signaling state changes are fired until we expect them to
this._pc.onsignalingstatechange = unexpectedCallbackAndFinish(new Error);
}
PeerConnectionWrapper.prototype = {
@ -533,15 +462,6 @@ PeerConnectionWrapper.prototype = {
this._pc.remoteDescription = desc;
},
/**
* Returns the remote signaling state.
*
* @returns {object} The local description
*/
get signalingState() {
return this._pc.signalingState;
},
/**
* Callback when we get media from either side. Also an appropriate
* HTML media element will be created.
@ -651,25 +571,6 @@ PeerConnectionWrapper.prototype = {
}, unexpectedCallbackAndFinish(new Error));
},
/**
* Tries to set the local description and expect failure. Automatically
* causes the test case to fail if the call succeeds.
*
* @param {object} desc
* mozRTCSessionDescription for the local description request
* @param {function} onFailure
* Callback to execute if the call fails.
*/
setLocalDescriptionAndFail : function PCW_setLocalDescriptionAndFail(desc, onFailure) {
var self = this;
this._pc.setLocalDescription(desc,
unexpectedSuccessCallbackAndFinish(new Error, "setLocalDescription should have failed."),
function (err) {
info("As expected, failed to set the local description for " + self.label);
onFailure(err);
});
},
/**
* Sets the remote description and automatically handles the failure case.
*
@ -686,62 +587,6 @@ PeerConnectionWrapper.prototype = {
}, unexpectedCallbackAndFinish(new Error));
},
/**
* Tries to set the remote description and expect failure. Automatically
* causes the test case to fail if the call succeeds.
*
* @param {object} desc
* mozRTCSessionDescription for the remote description request
* @param {function} onFailure
* Callback to execute if the call fails.
*/
setRemoteDescriptionAndFail : function PCW_setRemoteDescriptionAndFail(desc, onFailure) {
var self = this;
this._pc.setRemoteDescription(desc,
unexpectedSuccessCallbackAndFinish(new Error, "setRemoteDescription should have failed."),
function (err) {
info("As expected, failed to set the remote description for " + self.label);
onFailure(err);
});
},
/**
* Adds an ICE candidate and automatically handles the failure case.
*
* @param {object} candidate
* SDP candidate
* @param {function} onSuccess
* Callback to execute if the local description was set successfully
*/
addIceCandidate : function PCW_addIceCandidate(candidate, onSuccess) {
var self = this;
this._pc.addIceCandidate(candidate, function () {
info("Successfully added an ICE candidate to " + self.label);
onSuccess();
}, unexpectedCallbackAndFinish(new Error));
},
/**
* Tries to add an ICE candidate and expects failure. Automatically
* causes the test case to fail if the call succeeds.
*
* @param {object} candidate
* SDP candidate
* @param {function} onFailure
* Callback to execute if the call fails.
*/
addIceCandidateAndFail : function PCW_addIceCandidateAndFail(candidate, onFailure) {
var self = this;
this._pc.addIceCandidate(candidate,
unexpectedSuccessCallbackAndFinish(new Error, "addIceCandidate should have failed."),
function (err) {
info("As expected, failed to add an ICE candidate to " + self.label);
onFailure(err);
}) ;
},
/**
* Checks that we are getting the media we expect.
*

View File

@ -1,43 +0,0 @@
<!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>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "784519",
title: "addCandidate (answer) in 'have-local-offer'"
});
var test;
runTest(function () {
test = new PeerConnectionTest();
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter("PC_LOCAL_SET_LOCAL_DESCRIPTION");
test.chain.append([[
"PC_LOCAL_ADD_CANDIDATE",
function (test) {
test.pcLocal.addIceCandidateAndFail(
mozRTCIceCandidate(
{candidate:"1 1 UDP 2130706431 192.168.2.1 50005 typ host",
sdpMLineIndex: 1}),
function(err) {
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
test.next();
} );
}
]]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -1,41 +0,0 @@
<!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>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "784519",
title: "setLocalDescription (answer) in 'have-local-offer'"
});
var test;
runTest(function () {
test = new PeerConnectionTest();
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter("PC_LOCAL_SET_LOCAL_DESCRIPTION");
test.chain.append([[
"PC_LOCAL_SET_LOCAL_ANSWER",
function (test) {
test.pcLocal._last_offer.type="answer";
test.pcLocal.setLocalDescriptionAndFail(test.pcLocal._last_offer,
function(err) {
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
test.next();
} );
}
]]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -1,41 +0,0 @@
<!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>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "784519",
title: "setLocalDescription (answer) in 'stable'"
});
var test;
runTest(function () {
test = new PeerConnectionTest();
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter("PC_LOCAL_CREATE_OFFER");
test.chain.append([[
"PC_LOCAL_SET_LOCAL_ANSWER",
function (test) {
test.pcLocal._last_offer.type="answer";
test.pcLocal.setLocalDescriptionAndFail(test.pcLocal._last_offer,
function(err) {
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
test.next();
} );
}
]]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -1,40 +0,0 @@
<!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>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "784519",
title: "setLocalDescription (offer) in 'have-remote-offer'"
});
var test;
runTest(function () {
test = new PeerConnectionTest();
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter("PC_REMOTE_SET_REMOTE_DESCRIPTION");
test.chain.append([[
"PC_REMOTE_SET_LOCAL_OFFER",
function (test) {
test.pcRemote.setLocalDescriptionAndFail(test.pcLocal._last_offer,
function(err) {
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
test.next();
} );
}
]]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -1,41 +0,0 @@
<!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>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "784519",
title: "setRemoteDescription (answer) in 'have-remote-offer'"
});
var test;
runTest(function () {
test = new PeerConnectionTest();
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter("PC_REMOTE_SET_REMOTE_DESCRIPTION");
test.chain.append([[
"PC_REMOTE_SET_REMOTE_ANSWER",
function (test) {
test.pcLocal._last_offer.type="answer";
test.pcRemote.setRemoteDescriptionAndFail(test.pcLocal._last_offer,
function(err) {
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
test.next();
} );
}
]]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -1,41 +0,0 @@
<!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>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "784519",
title: "setRemoteDescription (answer) in 'stable'"
});
var test;
runTest(function () {
test = new PeerConnectionTest();
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter("PC_LOCAL_CREATE_OFFER");
test.chain.append([[
"PC_LOCAL_SET_REMOTE_ANSWER",
function (test) {
test.pcLocal._last_offer.type="answer";
test.pcLocal.setRemoteDescriptionAndFail(test.pcLocal._last_offer,
function(err) {
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
test.next();
} );
}
]]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -1,40 +0,0 @@
<!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>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "784519",
title: "setRemoteDescription (offer) in 'have-local-offer'"
});
var test;
runTest(function () {
test = new PeerConnectionTest();
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter("PC_LOCAL_SET_LOCAL_DESCRIPTION");
test.chain.append([[
"PC_LOCAL_SET_REMOTE_OFFER",
function (test) {
test.pcLocal.setRemoteDescriptionAndFail(test.pcLocal._last_offer,
function(err) {
is(err.name, "INVALID_STATE", "Error is INVALID_STATE");
test.next();
} );
}
]]);
test.run();
});
</script>
</pre>
</body>
</html>