Bug 1425621 - Part 6: Update mochitests to match new behavior. r?jib
MozReview-Commit-ID: GIloM9yzyEB
--- a/dom/media/tests/mochitest/test_peerConnection_addtrack_removetrack_events.html
+++ b/dom/media/tests/mochitest/test_peerConnection_addtrack_removetrack_events.html
@@ -52,21 +52,16 @@ runNetworkTest(function (options) {
"Expected event to be instance of MediaStreamTrackEvent");
is(trackEvent.type, "addtrack",
"Expected addtrack event type");
is(test.pcRemote.getWebrtcTrackId(trackEvent.track), newTrack.id, "Expected track in event");
is(trackEvent.track.readyState, "live",
"added track should be live");
})
.then(() => haveNoEvent(remoteStream, "addtrack"));
-
- remoteStream.addEventListener("removetrack",
- function onRemovetrack(trackEvent) {
- ok(false, "UA shouldn't raise 'removetrack' when receiving peer connection");
- })
});
},
],
[
function PC_REMOTE_CHECK_EVENTS(test) {
return eventsPromise;
},
]
--- a/dom/media/tests/mochitest/test_peerConnection_removeThenAddAudioTrack.html
+++ b/dom/media/tests/mochitest/test_peerConnection_removeThenAddAudioTrack.html
@@ -9,18 +9,18 @@
createHTML({
bug: "1017888",
title: "Renegotiation: remove then add audio track"
});
runNetworkTest(function (options) {
const test = new PeerConnectionTest(options);
let originalTrack;
- let haveMuteEvent;
- let haveUnmuteEvent;
+ let haveMuteEvent = new Promise(() => {});
+ let haveUnmuteEvent = new Promise(() => {});
addRenegotiation(test.chain,
[
function PC_REMOTE_FIND_RECEIVER(test) {
is(test.pcRemote._pc.getReceivers().length, 1,
"pcRemote should have one receiver");
originalTrack = test.pcRemote._pc.getReceivers()[0].track;
},
function PC_LOCAL_REMOVE_AUDIO_TRACK(test) {
@@ -59,20 +59,25 @@
const analyser = new AudioStreamAnalyser(
new AudioContext(), new MediaStream([track]));
const freq = analyser.binIndexForFrequency(TEST_AUDIO_FREQ);
return analyser.waitForAnalysisSuccess(arr => arr[freq] < 50);
}
]
);
- test.chain.insertBefore("PC_REMOTE_SET_LOCAL_DESCRIPTION", [
+ // Second negotiation should cause the first track to mute...
+ test.chain.insertBefore("PC_REMOTE_SET_REMOTE_DESCRIPTION", [
function PC_REMOTE_SETUP_ONMUTE(test) {
haveMuteEvent = haveEvent(test.pcRemote._pc.getReceivers()[0].track, "mute");
- },
+ }
+ ], false, 1);
+
+ // ...and a second track to unmute.
+ test.chain.insertAfter("PC_REMOTE_SET_REMOTE_DESCRIPTION", [
function PC_REMOTE_SETUP_ONUNMUTE(test) {
haveUnmuteEvent = haveEvent(test.pcRemote._pc.getReceivers()[1].track, "unmute");
}
], false, 1);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
});
--- a/dom/media/tests/mochitest/test_peerConnection_removeThenAddVideoTrack.html
+++ b/dom/media/tests/mochitest/test_peerConnection_removeThenAddVideoTrack.html
@@ -11,18 +11,18 @@
bug: "1017888",
title: "Renegotiation: remove then add video track"
});
runNetworkTest(function (options) {
const test = new PeerConnectionTest(options);
const helper = new VideoStreamHelper();
var originalTrack;
- let haveMuteEvent;
- let haveUnmuteEvent;
+ let haveMuteEvent = new Promise(() => {});
+ let haveUnmuteEvent = new Promise(() => {});
addRenegotiation(test.chain,
[
function PC_REMOTE_FIND_RECEIVER(test) {
is(test.pcRemote._pc.getReceivers().length, 1,
"pcRemote should have one receiver");
originalTrack = test.pcRemote._pc.getReceivers()[0].track;
},
function PC_LOCAL_REMOVE_VIDEO_TRACK(test) {
@@ -61,20 +61,25 @@
const vAdded = test.pcRemote.remoteMediaElements.find(
elem => elem.id.includes(track.id));
return helper.checkVideoPaused(vAdded, 10, 10, 16, 5000);
}
]
);
- test.chain.insertBefore("PC_REMOTE_SET_LOCAL_DESCRIPTION", [
+ // Second negotiation should cause the first track to mute...
+ test.chain.insertBefore("PC_REMOTE_SET_REMOTE_DESCRIPTION", [
function PC_REMOTE_SETUP_ONMUTE(test) {
haveMuteEvent = haveEvent(test.pcRemote._pc.getReceivers()[0].track, "mute");
- },
+ }
+ ], false, 1);
+
+ // ...and a second track to unmute.
+ test.chain.insertAfter("PC_REMOTE_SET_REMOTE_DESCRIPTION", [
function PC_REMOTE_SETUP_ONUNMUTE(test) {
haveUnmuteEvent = haveEvent(test.pcRemote._pc.getReceivers()[1].track, "unmute");
}
], false, 1);
test.setMediaConstraints([{video: true}], [{video: true}]);
test.run();
});