summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/tests/mochitests/test_peerConnection_closeDuringIce.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_closeDuringIce.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_closeDuringIce.html')
-rw-r--r--dom/media/webrtc/tests/mochitests/test_peerConnection_closeDuringIce.html79
1 files changed, 79 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_closeDuringIce.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_closeDuringIce.html
new file mode 100644
index 0000000000..db3a2922d5
--- /dev/null
+++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_closeDuringIce.html
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script type="application/javascript" src="pc.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+ createHTML({
+ bug: "1087629",
+ title: "Close PCs during ICE connectivity check"
+ });
+
+// Test closeDuringIce to simulate problems during peer connections
+
+
+function PC_LOCAL_SETUP_NULL_ICE_HANDLER(test) {
+ test.pcLocal.setupIceCandidateHandler(test, function() {}, function () {});
+}
+function PC_REMOTE_SETUP_NULL_ICE_HANDLER(test) {
+ test.pcRemote.setupIceCandidateHandler(test, function() {}, function () {});
+}
+function PC_REMOTE_ADD_FAKE_ICE_CANDIDATE(test) {
+ var cand = {"candidate":"candidate:0 1 UDP 2130379007 192.0.2.1 12345 typ host","sdpMid":"","sdpMLineIndex":0};
+ test.pcRemote.storeOrAddIceCandidate(cand);
+ info(test.pcRemote + " Stored fake candidate: " + JSON.stringify(cand));
+}
+function PC_LOCAL_ADD_FAKE_ICE_CANDIDATE(test) {
+ var cand = {"candidate":"candidate:0 1 UDP 2130379007 192.0.2.2 56789 typ host","sdpMid":"","sdpMLineIndex":0};
+ test.pcLocal.storeOrAddIceCandidate(cand);
+ info(test.pcLocal + " Stored fake candidate: " + JSON.stringify(cand));
+}
+function PC_LOCAL_CLOSE_DURING_ICE(test) {
+ return test.pcLocal.iceChecking.then(() => {
+ test.pcLocal.onsignalingstatechange = function () {};
+ test.pcLocal.close();
+ });
+}
+function PC_REMOTE_CLOSE_DURING_ICE(test) {
+ return test.pcRemote.iceChecking.then(() => {
+ test.pcRemote.onsignalingstatechange = function () {};
+ test.pcRemote.close();
+ });
+}
+function PC_LOCAL_WAIT_FOR_ICE_CHECKING(test) {
+ var resolveIceChecking;
+ test.pcLocal.iceChecking = new Promise(r => resolveIceChecking = r);
+ test.pcLocal.ice_connection_callbacks.checkIceStatus = () => {
+ if (test.pcLocal._pc.iceConnectionState === "checking") {
+ resolveIceChecking();
+ }
+ }
+}
+function PC_REMOTE_WAIT_FOR_ICE_CHECKING(test) {
+ var resolveIceChecking;
+ test.pcRemote.iceChecking = new Promise(r => resolveIceChecking = r);
+ test.pcRemote.ice_connection_callbacks.checkIceStatus = () => {
+ if (test.pcRemote._pc.iceConnectionState === "checking") {
+ resolveIceChecking();
+ }
+ }
+}
+
+runNetworkTest(() => {
+ var test = new PeerConnectionTest();
+ test.setMediaConstraints([{audio: true}], [{audio: true}]);
+ test.chain.replace("PC_LOCAL_SETUP_ICE_HANDLER", PC_LOCAL_SETUP_NULL_ICE_HANDLER);
+ test.chain.replace("PC_REMOTE_SETUP_ICE_HANDLER", PC_REMOTE_SETUP_NULL_ICE_HANDLER);
+ test.chain.insertAfter("PC_REMOTE_SETUP_NULL_ICE_HANDLER", PC_LOCAL_WAIT_FOR_ICE_CHECKING);
+ test.chain.insertAfter("PC_LOCAL_WAIT_FOR_ICE_CHECKING", PC_REMOTE_WAIT_FOR_ICE_CHECKING);
+ test.chain.removeAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION");
+ test.chain.append([PC_REMOTE_ADD_FAKE_ICE_CANDIDATE, PC_LOCAL_ADD_FAKE_ICE_CANDIDATE,
+ PC_LOCAL_CLOSE_DURING_ICE, PC_REMOTE_CLOSE_DURING_ICE]);
+ return test.run();
+});
+</script>
+</pre>
+</body>
+</html>