Bug 1259236 - test pc.addTrack of track in constructed stream.
MozReview-Commit-ID: E1qFH7xYY0H
--- a/dom/media/tests/mochitest/head.js
+++ b/dom/media/tests/mochitest/head.js
@@ -415,16 +415,27 @@ var listenUntil = (target, eventName, on
var result = onFire();
if (result) {
target.removeEventListener(eventName, callback, false);
resolve(result);
}
}, false));
};
+/* Test that a function throws the right error */
+function mustThrowWith(msg, reason, f) {
+ try {
+ f();
+ ok(false, msg + " must throw");
+ } catch (e) {
+ is(e.name, reason, msg + " must throw: " + e.message);
+ }
+};
+
+
/*** Test control flow methods */
/**
* Generates a callback function fired only under unexpected circumstances
* while running the tests. The generated function kills off the test as well
* gracefully.
*
* @param {String} [message]
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -65,16 +65,17 @@ skip-if = (toolkit == 'gonk' || buildapp
[test_getUserMedia_stopAudioStreamWithFollowupAudio.html]
[test_getUserMedia_stopVideoAudioStream.html]
[test_getUserMedia_stopVideoAudioStreamWithFollowupVideoAudio.html]
[test_getUserMedia_stopVideoStream.html]
[test_getUserMedia_stopVideoStreamWithFollowupVideo.html]
[test_getUserMedia_peerIdentity.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g(Bug 1021776, too --ing slow on b2g)
[test_peerConnection_addIceCandidate.html]
+[test_peerConnection_addTrack.html]
[test_peerConnection_basicAudio.html]
skip-if = toolkit == 'gonk' # B2G emulator is too slow to handle a two-way audio call reliably
[test_peerConnection_basicAudioRequireEOC.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_basicAudioPcmaPcmuOnly.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_basicAudioDynamicPtMissingRtpmap.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_addTrack.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript;version=1.8">
+ createHTML({
+ bug: "1259236",
+ title: "PeerConnection addTrack errors",
+ visible: true
+ });
+
+ runNetworkTest(function() {
+ navigator.mediaDevices.getUserMedia({ video: true })
+ .then(gumStream => {
+ let newStream = new MediaStream(gumStream.getTracks());
+
+ mustThrowWith("pc.addTrack a track from a constructed MediaStream",
+ "NotSupportedError",
+ () => new RTCPeerConnection().addTrack(newStream.getTracks()[0],
+ newStream));
+ })
+ .catch(e => ok(false, "unexpected failure: " + e))
+ .then(networkTestFinished);
+ });
+</script>
+</pre>
+</body>
+</html>
--- a/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
+++ b/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
@@ -14,25 +14,16 @@
var pc1 = new RTCPeerConnection();
var pc2 = new RTCPeerConnection();
var add = (pc, can, failed) => can && pc.addIceCandidate(can).catch(failed);
pc1.onicecandidate = e => add(pc2, e.candidate, generateErrorCallback());
pc2.onicecandidate = e => add(pc1, e.candidate, generateErrorCallback());
- function mustThrowWith(msg, reason, f) {
- try {
- f();
- ok(false, msg + " must throw");
- } catch (e) {
- is(e.name, reason, msg + " must throw: " + e.message);
- }
- };
-
var v1, v2;
var delivered = new Promise(resolve => pc2.ontrack = e => {
// Test RTCTrackEvent here.
ok(e.streams.length > 0, "has streams");
ok(e.streams[0].getTracks().some(track => track == e.track), "has track");
ok(pc2.getReceivers().some(receiver => receiver == e.receiver), "has receiver");
if (e.streams[0].getTracks().length == 2) {
// Test RTCTrackEvent required args here.