Bug 1264479: added mochitest to test current and pending descriptions from JS. r?bwc
MozReview-Commit-ID: 8fSvyiPz2Tv
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -282,8 +282,10 @@ skip-if = (android_version == '18') # an
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
[test_selftest.html]
# Bug 1227781: Crash with bogus TURN server.
[test_peerConnection_bug1227781.html]
[test_peerConnection_stats.html]
skip-if = toolkit == 'android' # android(Bug 1189784, timeouts on 4.3 emulator, Bug 1373858)
[test_peerConnection_sender_and_receiver_stats.html]
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
+[test_peerConnection_verifyDescriptions.html]
+skip-if = (android_version == '18')
--- a/dom/media/tests/mochitest/pc.js
+++ b/dom/media/tests/mochitest/pc.js
@@ -841,45 +841,25 @@ PeerConnectionWrapper.prototype = {
*
* @returns {object} The local description
*/
get localDescription() {
return this._pc.localDescription;
},
/**
- * Sets the local description.
- *
- * @param {object} desc
- * The new local description
- */
- set localDescription(desc) {
- this._pc.localDescription = desc;
- },
-
- /**
* Returns the remote description.
*
* @returns {object} The remote description
*/
get remoteDescription() {
return this._pc.remoteDescription;
},
/**
- * Sets the remote description.
- *
- * @param {object} desc
- * The new remote description
- */
- set remoteDescription(desc) {
- this._pc.remoteDescription = desc;
- },
-
- /**
* Returns the signaling state.
*
* @returns {object} The local description
*/
get signalingState() {
return this._pc.signalingState;
},
/**
copy from dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
copy to dom/media/tests/mochitest/test_peerConnection_verifyDescriptions.html
--- a/dom/media/tests/mochitest/test_peerConnection_promiseSendOnly.html
+++ b/dom/media/tests/mochitest/test_peerConnection_verifyDescriptions.html
@@ -2,62 +2,60 @@
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
- bug: "1091898",
- title: "PeerConnection with promises (sendonly)",
- visible: true
+ bug: "1264479",
+ title: "PeerConnection verify current and pending descriptions"
});
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(() => {
+ ok(!pc1.currentLocalDescription, "pc1 currentLocalDescription is empty");
+ ok(pc1.pendingLocalDescription, "pc1 pendingLocalDescription is set");
+ ok(pc1.localDescription, "pc1 localDescription is set");
+ })
.then(() => pc2.setRemoteDescription(pc1.localDescription))
+ .then(() => {
+ ok(!pc2.currentRemoteDescription, "pc2 currentRemoteDescription is empty");
+ ok(pc2.pendingRemoteDescription, "pc2 pendingRemoteDescription is set");
+ ok(pc2.remoteDescription, "pc2 remoteDescription is set");
+ })
.then(() => pc2.createAnswer({})) // check that createAnswer accepts arg.
.then(answer => pc2.setLocalDescription(answer))
+ .then(() => {
+ ok(pc2.currentLocalDescription, "pc2 currentLocalDescription is set");
+ ok(!pc2.pendingLocalDescription, "pc2 pendingLocalDescription is empty");
+ ok(pc2.localDescription, "pc2 localDescription is set");
+ })
.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."))
+ .then(() => {
+ ok(pc1.currentRemoteDescription, "pc1 currentRemoteDescription is set");
+ ok(!pc1.pendingRemoteDescription, "pc1 pendingRemoteDescription is empty");
+ ok(pc1.remoteDescription, "pc1 remoteDescription is set");
+ })
.catch(reason => ok(false, "unexpected failure: " + reason))
.then(networkTestFinished);
});
</script>
</pre>
</body>
</html>