summaryrefslogtreecommitdiffstats
path: root/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html')
-rw-r--r--dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html63
1 files changed, 63 insertions, 0 deletions
diff --git a/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html b/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
new file mode 100644
index 000000000..61cecafb5
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
@@ -0,0 +1,63 @@
+<!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: "1091898",
+ title: "PeerConnection with promises (sendonly)",
+ visible: true
+ });
+
+ 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());
+
+ 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].getTrackById(e.track.id), "has track");
+ ok(pc2.getReceivers().some(receiver => receiver == e.receiver), "has receiver");
+ if (e.streams[0].getTracks().length == 2) {
+ // Test RTCTrackEvent required args here.
+ mustThrowWith("RTCTrackEvent wo/required args",
+ "TypeError", () => new RTCTrackEvent("track", {}));
+ v2.srcObject = e.streams[0];
+ resolve();
+ }
+ });
+
+ runNetworkTest(function() {
+ v1 = createMediaElement('video', 'v1');
+ v2 = createMediaElement('video', 'v2');
+ var canPlayThrough = new Promise(resolve => v2.canplaythrough = e => resolve());
+
+ is(v2.currentTime, 0, "v2.currentTime is zero at outset");
+
+ navigator.mediaDevices.getUserMedia({ video: true, audio: true })
+ .then(stream => (v1.srcObject = stream).getTracks().forEach(t => pc1.addTrack(t, stream)))
+ .then(() => pc1.createOffer({})) // check that createOffer accepts arg.
+ .then(offer => pc1.setLocalDescription(offer))
+ .then(() => pc2.setRemoteDescription(pc1.localDescription))
+ .then(() => pc2.createAnswer({})) // check that createAnswer accepts arg.
+ .then(answer => pc2.setLocalDescription(answer))
+ .then(() => pc1.setRemoteDescription(pc2.localDescription))
+ .then(() => delivered)
+// .then(() => canPlayThrough) // why doesn't this fire?
+ .then(() => waitUntil(() => v2.currentTime > 0 && v2.srcObject.currentTime > 0))
+ .then(() => ok(v2.currentTime > 0, "v2.currentTime is moving (" + v2.currentTime + ")"))
+ .then(() => ok(true, "Connected."))
+ .catch(reason => ok(false, "unexpected failure: " + reason))
+ .then(networkTestFinished);
+ });
+</script>
+</pre>
+</body>
+</html>