summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webrtc/RTCPeerConnection-addTcpIceCandidate.html
blob: 1e7fc3ba9576d0ee124a6d6ee9729d682ee86fe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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>