summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/tests/mochitests/test_peerConnection_codecNegotiationFailure.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/webrtc/tests/mochitests/test_peerConnection_codecNegotiationFailure.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_peerConnection_codecNegotiationFailure.html')
-rw-r--r--dom/media/webrtc/tests/mochitests/test_peerConnection_codecNegotiationFailure.html111
1 files changed, 111 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_codecNegotiationFailure.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_codecNegotiationFailure.html
new file mode 100644
index 0000000000..819e13fe1b
--- /dev/null
+++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_codecNegotiationFailure.html
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script type="application/javascript" src="pc.js"></script>
+ <script type="application/javascript" src="iceTestUtils.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+ createHTML({
+ bug: "1683934",
+ title: "RTCPeerConnection check codec negotiation failure"
+ });
+
+ function makeWeirdCodecs(sdp) {
+ return sdp
+ .replaceAll('VP8', 'VEEEEEEEEP8')
+ .replaceAll('VP9', 'VEEEEEEEEP9')
+ .replaceAll('H264', 'HERP264');
+ }
+
+ const tests = [
+ async function offererWeirdCodecs() {
+ const pc1 = new RTCPeerConnection();
+ const pc2 = new RTCPeerConnection();
+
+ const stream = await navigator.mediaDevices.getUserMedia({video: true});
+ pc1.addTrack(stream.getTracks()[0]);
+ pc2.addTrack(stream.getTracks()[0]);
+
+ const offer = await pc1.createOffer();
+ offer.sdp = makeWeirdCodecs(offer.sdp);
+ // It is not an error to receive an offer with no codecs we support
+ await pc2.setRemoteDescription(offer);
+ await pc2.setLocalDescription();
+ await wait(2000);
+ },
+
+ async function answererWeirdCodecs() {
+ const pc1 = new RTCPeerConnection();
+ const pc2 = new RTCPeerConnection();
+
+ const stream = await navigator.mediaDevices.getUserMedia({video: true});
+ pc1.addTrack(stream.getTracks()[0]);
+ pc2.addTrack(stream.getTracks()[0]);
+
+ await pc1.setLocalDescription();
+ await pc2.setRemoteDescription(pc1.localDescription);
+ const answer = await pc2.createAnswer();
+ answer.sdp = makeWeirdCodecs(answer.sdp);
+ try {
+ await pc1.setRemoteDescription(answer);
+ ok(false, "Should have thrown");
+ } catch (e) {
+ ok(true, "Should have thrown");
+ }
+ },
+
+ async function reoffererWeirdCodecs() {
+ const pc1 = new RTCPeerConnection();
+ const pc2 = new RTCPeerConnection();
+
+ const stream = await navigator.mediaDevices.getUserMedia({video: true});
+ pc1.addTrack(stream.getTracks()[0]);
+ pc2.addTrack(stream.getTracks()[0]);
+
+ await connect(pc1, pc2, 32000, "Initial connection");
+
+ const offer = await pc1.createOffer();
+ offer.sdp = makeWeirdCodecs(offer.sdp);
+ // It is not an error to receive an offer with no codecs we support
+ await pc2.setRemoteDescription(offer);
+ await pc2.setLocalDescription();
+ await wait(2000);
+ },
+
+ async function reanswererWeirdCodecs() {
+ const pc1 = new RTCPeerConnection();
+ const pc2 = new RTCPeerConnection();
+
+ const stream = await navigator.mediaDevices.getUserMedia({video: true});
+ pc1.addTrack(stream.getTracks()[0]);
+ pc2.addTrack(stream.getTracks()[0]);
+
+ await connect(pc1, pc2, 32000, "Initial connection");
+ await pc1.setLocalDescription();
+ await pc2.setRemoteDescription(pc1.localDescription);
+ const answer = await pc2.createAnswer();
+ answer.sdp = makeWeirdCodecs(answer.sdp);
+ try {
+ await pc1.setRemoteDescription(answer);
+ ok(false, "Should have thrown");
+ } catch (e) {
+ ok(true, "Should have thrown");
+ }
+ },
+
+ ];
+
+ runNetworkTest(async () => {
+ for (const test of tests) {
+ info(`Running test: ${test.name}`);
+ await test();
+ info(`Done running test: ${test.name}`);
+ }
+ });
+
+</script>
+</pre>
+</body>
+</html>