summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html')
-rw-r--r--testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html95
1 files changed, 95 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html b/testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html
new file mode 100644
index 0000000000..1e7fc3ba95
--- /dev/null
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html
@@ -0,0 +1,95 @@
+<!doctype html>
+<title>Test RTCPeerConnection.prototype.addIceCandidate with TCP candidates</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="RTCPeerConnection-helper.js"></script>
+<script>
+'use strict';
+
+const sdp = `v=0
+o=- 166855176514521964 2 IN IP4 127.0.0.1
+s=-
+t=0 0
+a=msid-semantic:WMS *
+m=audio 9 UDP/TLS/RTP/SAVPF 111
+c=IN IP4 0.0.0.0
+a=rtcp:9 IN IP4 0.0.0.0
+a=ice-ufrag:655Y
+a=ice-pwd:somelongpwdwithenoughrandomness
+a=fingerprint:sha-256 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
+a=setup:actpass
+a=mid:audio1
+a=sendonly
+a=rtcp-mux
+a=rtcp-rsize
+a=rtpmap:111 opus/48000/2
+a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
+a=ssrc:1001 cname:some
+`;
+
+const candidate_8001 = 'a=candidate:2983561038 1 tcp 1518214911 127.0.0.1 8001 typ host tcptype passive generation 0 ufrag 655Y network-id 1 network-cost 10';
+
+const candidate_2049 = 'a=candidate:2983561038 1 tcp 1518214911 127.0.0.1 2049 typ host tcptype passive generation 0 ufrag 655Y network-id 1 network-cost 10';
+
+const candidate_37 = 'a=candidate:2983561038 1 tcp 1518214911 127.0.0.1 37 typ host tcptype passive generation 0 ufrag 655Y network-id 1 network-cost 10';
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp + candidate_8001 + '\n'})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ await waitForConnectionStateChangeWithTimeout(t, pc,
+ ['failed', 'disconnected'], 1000);
+}, 'TCP candidate aimed at port 8001 accepted');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp + candidate_2049 + '\n'})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ pc.onicestatechange = t.unreached_func();
+ await new Promise(resolve => t.step_timeout(resolve, 500));
+}, 'TCP candidate aimed at port 2049 ignored');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp + candidate_37 + '\n'})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ pc.onicestatechange = t.unreached_func();
+ await new Promise(resolve => t.step_timeout(resolve, 500));
+}, 'TCP candidate aimed at port 37 ignored');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ await pc.addIceCandidate(new RTCIceCandidate({
+ candidate: candidate_8001,
+ sdpMid: 'audio1'
+ }));
+ await waitForConnectionStateChangeWithTimeout(
+ t, pc, ['failed', 'disconnected'], 1000);
+}, 'TCP addIceCandidate aimed at port 8001 accepted');
+
+promise_test(async t => {
+ const pc = new RTCPeerConnection();
+ t.add_cleanup(() => pc.close());
+ await pc.setRemoteDescription({type: 'offer', sdp: sdp})
+ const answer = await pc.createAnswer();
+ await pc.setLocalDescription(answer);
+ await pc.addIceCandidate(new RTCIceCandidate({
+ candidate: candidate_2049,
+ sdpMid: 'audio1'
+ }));
+ pc.onicestatechange = t.unreached_func();
+ await new Promise(resolve => t.step_timeout(resolve, 500));
+}, 'TCP addIceCandidate aimed at port 2049 ignored');
+
+
+</script>