Skip to content

Commit

Permalink
Bug 1793776: Test-case for pref. r=jib
Browse files Browse the repository at this point in the history
  • Loading branch information
docfaraday committed Oct 7, 2022
1 parent 5d43825 commit 2325fcc
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ skip-if = toolkit == 'android' # no simulcast support on android
skip-if = toolkit == 'android' # no simulcast support on android
[test_peerConnection_simulcastOddResolution.html]
skip-if = toolkit == 'android' # no simulcast support on android
[test_peerConnection_stereoFmtpPref.html]
[test_peerConnection_relayOnly.html]
disabled=bug 1612063 # test is racy
[test_peerConnection_callbacks.html]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1793776",
title: "Test that media.peerconnection.sdp.disable_stereo_fmtp works"
});

const tests = [
async function testStereo() {
const offerer = new RTCPeerConnection();
offerer.addTransceiver('audio');
const answerer = new RTCPeerConnection();
await offerer.setLocalDescription();
ok(offerer.localDescription.sdp.includes('stereo=1'),
'Offer uses stereo=1 when media.peerconnection.sdp.disable_stereo_fmtp is not set');
await answerer.setRemoteDescription(offerer.localDescription);
const {sdp} = await answerer.createAnswer();
ok(sdp.includes('stereo=1'), 'Answer uses stereo=1 when media.peerconnection.sdp.disable_stereo_fmtp is not set');
},

async function testNoStereo() {
await pushPrefs(
['media.peerconnection.sdp.disable_stereo_fmtp', true]);

const offerer = new RTCPeerConnection();
offerer.addTransceiver('audio');
const answerer = new RTCPeerConnection();
await offerer.setLocalDescription();
ok(offerer.localDescription.sdp.includes('stereo=0'),
'Offer uses stereo=0 when media.peerconnection.sdp.disable_stereo_fmtp is set');
await answerer.setRemoteDescription(offerer.localDescription);
const {sdp} = await answerer.createAnswer();
ok(sdp.includes('stereo=0'), 'Answer uses stereo=0 when media.peerconnection.sdp.disable_stereo_fmtp is set');
},
];

runNetworkTest(async () => {
for (const test of tests) {
info(`Running test: ${test.name}`);
try {
await test();
} catch (e) {
ok(false, `Caught ${e.name}: ${e.message} ${e.stack}`);
}
info(`Done running test: ${test.name}`);
// Make sure we don't build up a pile of GC work, and also get PCImpl to
// print their timecards.
await new Promise(r => SpecialPowers.exactGC(r));
}

await SpecialPowers.popPrefEnv();
});
</script>
</pre>
</body>
</html>

0 comments on commit 2325fcc

Please sign in to comment.