diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/webrtc/tests/mochitests/test_peerConnection_insertDTMF.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.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_insertDTMF.html')
-rw-r--r-- | dom/media/webrtc/tests/mochitests/test_peerConnection_insertDTMF.html | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_insertDTMF.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_insertDTMF.html new file mode 100644 index 0000000000..ca8b866a6d --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_insertDTMF.html @@ -0,0 +1,76 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="pc.js"></script> +</head> +<body> +<pre id="test"> +<script type="application/javascript"> +createHTML({ + bug: "1291715", + title: "Test insertDTMF on sender", + visible: true +}); + +function insertdtmftest(pc) { + ok(pc.getSenders().length, "have senders"); + var sender = pc.getSenders()[0]; + ok(sender.dtmf, "sender has dtmf object"); + + ok(sender.dtmf.toneBuffer === "", "sender should start with empty tonebuffer"); + + // These will trigger assertions on debug builds if we do not enforce the + // specified minimums and maximums for duration and interToneGap. + sender.dtmf.insertDTMF("A", 10); + sender.dtmf.insertDTMF("A", 10000); + sender.dtmf.insertDTMF("A", 70, 10); + + var threw = false; + try { + sender.dtmf.insertDTMF("bad tones"); + } catch (ex) { + threw = true; + is(ex.code, DOMException.INVALID_CHARACTER_ERR, "Expected InvalidCharacterError"); + } + ok(threw, "Expected exception"); + + sender.dtmf.insertDTMF("A"); + sender.dtmf.insertDTMF("B"); + ok(!sender.dtmf.toneBuffer.includes("A"), "calling insertDTMF should replace current characters"); + + sender.dtmf.insertDTMF("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + ok(sender.dtmf.toneBuffer.includes("A"), "lowercase characters should be normalized"); + + pc.removeTrack(sender); + threw = false; + try { + sender.dtmf.insertDTMF("AAA"); + } catch (ex) { + threw = true; + is(ex.code, DOMException.INVALID_STATE_ERR, "Expected InvalidStateError"); + } + ok(threw, "Expected exception"); +} + +runNetworkTest(() => { + test = new PeerConnectionTest(); + test.setMediaConstraints([{audio: true}], [{audio: true}]); + test.chain.removeAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW"); + + // Test sender dtmf. + test.chain.append([ + function PC_LOCAL_INSERT_DTMF(test) { + // We want to call removeTrack + test.pcLocal.expectNegotiationNeeded(); + return insertdtmftest(test.pcLocal._pc); + } + ]); + + return pushPrefs(['media.peerconnection.dtmf.enabled', true]) + .then(() => test.run()); +}); + +</script> +</pre> +</body> +</html> |