зеркало из https://github.com/mozilla/gecko-dev.git
Bug 985274 - Ensure generated callback function handles string objects. r=drno
This commit is contained in:
Родитель
45f25fbe18
Коммит
52ddeb17ca
|
@ -127,7 +127,7 @@ function runTest(aCallback) {
|
|||
aCallback();
|
||||
}
|
||||
catch (err) {
|
||||
unexpectedCallbackAndFinish()(err);
|
||||
generateErrorCallback()(err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -214,7 +214,7 @@ function getBlobContent(blob, onSuccess) {
|
|||
* An optional message to show if no object gets passed into the
|
||||
* generated callback method.
|
||||
*/
|
||||
function unexpectedCallbackAndFinish(message) {
|
||||
function generateErrorCallback(message) {
|
||||
var stack = new Error().stack.split("\n");
|
||||
stack.shift(); // Don't include this instantiation frame
|
||||
|
||||
|
@ -223,9 +223,15 @@ function unexpectedCallbackAndFinish(message) {
|
|||
* The object fired back from the callback
|
||||
*/
|
||||
return function (aObj) {
|
||||
if (aObj && aObj.name && aObj.message) {
|
||||
ok(false, "Unexpected callback for '" + aObj.name + "' with message = '" +
|
||||
aObj.message + "' at " + JSON.stringify(stack));
|
||||
if (aObj) {
|
||||
if (aObj.name && aObj.message) {
|
||||
ok(false, "Unexpected callback for '" + aObj.name +
|
||||
"' with message = '" + aObj.message + "' at " +
|
||||
JSON.stringify(stack));
|
||||
} else {
|
||||
ok(false, "Unexpected callback with = '" + aObj +
|
||||
"' at: " + JSON.stringify(stack));
|
||||
}
|
||||
} else {
|
||||
ok(false, "Unexpected callback with message = '" + message +
|
||||
"' at: " + JSON.stringify(stack));
|
||||
|
|
|
@ -1274,7 +1274,7 @@ PeerConnectionWrapper.prototype = {
|
|||
self.attachMedia(stream, type, 'local');
|
||||
|
||||
_getAllUserMedia(constraintsList, index + 1);
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
} else {
|
||||
onSuccess();
|
||||
}
|
||||
|
@ -1323,7 +1323,7 @@ PeerConnectionWrapper.prototype = {
|
|||
info("Got offer: " + JSON.stringify(offer));
|
||||
self._last_offer = offer;
|
||||
onSuccess(offer);
|
||||
}, unexpectedCallbackAndFinish(), this.offerConstraints);
|
||||
}, generateErrorCallback(), this.offerConstraints);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1339,7 +1339,7 @@ PeerConnectionWrapper.prototype = {
|
|||
info(self + ": Got answer: " + JSON.stringify(answer));
|
||||
self._last_answer = answer;
|
||||
onSuccess(answer);
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1355,7 +1355,7 @@ PeerConnectionWrapper.prototype = {
|
|||
this._pc.setLocalDescription(desc, function () {
|
||||
info(self + ": Successfully set the local description");
|
||||
onSuccess();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1370,7 +1370,7 @@ PeerConnectionWrapper.prototype = {
|
|||
setLocalDescriptionAndFail : function PCW_setLocalDescriptionAndFail(desc, onFailure) {
|
||||
var self = this;
|
||||
this._pc.setLocalDescription(desc,
|
||||
unexpectedCallbackAndFinish("setLocalDescription should have failed."),
|
||||
generateErrorCallback("setLocalDescription should have failed."),
|
||||
function (err) {
|
||||
info(self + ": As expected, failed to set the local description");
|
||||
onFailure(err);
|
||||
|
@ -1390,7 +1390,7 @@ PeerConnectionWrapper.prototype = {
|
|||
this._pc.setRemoteDescription(desc, function () {
|
||||
info(self + ": Successfully set remote description");
|
||||
onSuccess();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1405,7 +1405,7 @@ PeerConnectionWrapper.prototype = {
|
|||
setRemoteDescriptionAndFail : function PCW_setRemoteDescriptionAndFail(desc, onFailure) {
|
||||
var self = this;
|
||||
this._pc.setRemoteDescription(desc,
|
||||
unexpectedCallbackAndFinish("setRemoteDescription should have failed."),
|
||||
generateErrorCallback("setRemoteDescription should have failed."),
|
||||
function (err) {
|
||||
info(self + ": As expected, failed to set the remote description");
|
||||
onFailure(err);
|
||||
|
@ -1426,7 +1426,7 @@ PeerConnectionWrapper.prototype = {
|
|||
this._pc.addIceCandidate(candidate, function () {
|
||||
info(self + ": Successfully added an ICE candidate");
|
||||
onSuccess();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1442,7 +1442,7 @@ PeerConnectionWrapper.prototype = {
|
|||
var self = this;
|
||||
|
||||
this._pc.addIceCandidate(candidate,
|
||||
unexpectedCallbackAndFinish("addIceCandidate should have failed."),
|
||||
generateErrorCallback("addIceCandidate should have failed."),
|
||||
function (err) {
|
||||
info(self + ": As expected, failed to add an ICE candidate");
|
||||
onFailure(err);
|
||||
|
@ -1568,7 +1568,7 @@ PeerConnectionWrapper.prototype = {
|
|||
info(self + ": Got stats: " + JSON.stringify(stats));
|
||||
self._last_stats = stats;
|
||||
onSuccess(stats);
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"m=application is not contained in the SDP");
|
||||
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish(), options);
|
||||
}, generateErrorCallback(), options);
|
||||
}, true);
|
||||
|
||||
</script>
|
||||
|
|
|
@ -34,9 +34,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=781534
|
|||
playback.playMedia(false, function () {
|
||||
aStream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=781534
|
|||
playback.playMedia(false, function () {
|
||||
aStream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=781534
|
|||
playback.playMedia(false, function () {
|
||||
aStream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -42,13 +42,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
audioStream.stop();
|
||||
videoStream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -34,11 +34,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
audioStreamPlayback.playMedia(true, function() {
|
||||
audioStream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -33,11 +33,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
streamPlayback.playMedia(true, function() {
|
||||
stream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -34,11 +34,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
videoStreamPlayback.playMedia(true, function() {
|
||||
videoStream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -30,8 +30,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
var audioStreamPlayback = new LocalMediaStreamPlayback(testAudio, stream);
|
||||
|
||||
audioStreamPlayback.playMediaWithStreamStop(false, SimpleTest.finish,
|
||||
unexpectedCallbackAndFinish());
|
||||
}, unexpectedCallbackAndFinish());
|
||||
generateErrorCallback());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -37,13 +37,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
streamPlayback.playMedia(false, function() {
|
||||
secondStream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -30,8 +30,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
|
||||
|
||||
streamPlayback.playMediaWithStreamStop(false, SimpleTest.finish,
|
||||
unexpectedCallbackAndFinish());
|
||||
}, unexpectedCallbackAndFinish());
|
||||
generateErrorCallback());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -37,13 +37,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
streamPlayback.playMedia(false, function() {
|
||||
secondStream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -30,8 +30,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
var videoStreamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
|
||||
|
||||
videoStreamPlayback.playMediaWithStreamStop(false, SimpleTest.finish,
|
||||
unexpectedCallbackAndFinish());
|
||||
}, unexpectedCallbackAndFinish());
|
||||
generateErrorCallback());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -38,13 +38,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=822109
|
|||
streamPlayback.playMedia(false, function() {
|
||||
secondStream.stop();
|
||||
SimpleTest.finish();
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
|
||||
}, unexpectedCallbackAndFinish());
|
||||
}, generateErrorCallback());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
function testCreateAnswerError() {
|
||||
var pc = new mozRTCPeerConnection();
|
||||
info ("Testing createAnswer error callback");
|
||||
pc.createAnswer(unexpectedCallbackAndFinish("createAnswer before offer should fail"),
|
||||
pc.createAnswer(generateErrorCallback("createAnswer before offer should fail"),
|
||||
errorCallback(testSetLocalDescriptionError));
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
info ("Testing setLocalDescription error callback");
|
||||
pc.setLocalDescription(new mozRTCSessionDescription({ sdp: "Picklechips!",
|
||||
type: "offer" }),
|
||||
unexpectedCallbackAndFinish("setLocalDescription with nonsense SDP should fail"),
|
||||
generateErrorCallback("setLocalDescription with nonsense SDP should fail"),
|
||||
errorCallback(testSetRemoteDescriptionError));
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
|||
info ("Testing setRemoteDescription error callback");
|
||||
pc.setRemoteDescription(new mozRTCSessionDescription({ sdp: "Who?",
|
||||
type: "offer" }),
|
||||
unexpectedCallbackAndFinish("setRemoteDescription with nonsense SDP should fail"),
|
||||
generateErrorCallback("setRemoteDescription with nonsense SDP should fail"),
|
||||
errorCallback(testAddIceCandidateError));
|
||||
};
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
|||
pc.addIceCandidate(new mozRTCIceCandidate({ candidate: "Pony Lords, jump!",
|
||||
sdpMid: "whee",
|
||||
sdpMLineIndex: 1 }),
|
||||
unexpectedCallbackAndFinish("addIceCandidate with nonsense candidate should fail"),
|
||||
generateErrorCallback("addIceCandidate with nonsense candidate should fail"),
|
||||
errorCallback(SimpleTest.finish));
|
||||
};
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
function getFail() {
|
||||
return function (err) {
|
||||
window.onerror = oldOnError;
|
||||
unexpectedCallbackAndFinish()(err);
|
||||
generateErrorCallback()(err);
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче