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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<!doctype html>
<meta charset="utf-8">
<title>RTCSctpTransport constructor</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script>
'use strict';
// Test is based on the following revision:
// https://rawgit.com/w3c/webrtc-pc/1cc5bfc3ff18741033d804c4a71f7891242fb5b3/webrtc.html
// The following helper functions are called from RTCPeerConnection-helper.js:
// generateDataChannelOffer()
// generateAnswer()
/*
6.1.
partial interface RTCPeerConnection {
readonly attribute RTCSctpTransport? sctp;
...
};
6.1.1.
interface RTCSctpTransport {
readonly attribute RTCDtlsTransport transport;
readonly attribute RTCSctpTransportState state;
readonly attribute unrestricted double maxMessageSize;
attribute EventHandler onstatechange;
};
4.4.1.1. Constructor
9. Let connection have an [[SctpTransport]] internal slot, initialized to null.
4.4.1.6. Set the RTCSessionSessionDescription
2.2.6. If description is of type "answer" or "pranswer", then run the
following steps:
1. If description initiates the establishment of a new SCTP association, as defined in
[SCTP-SDP], Sections 10.3 and 10.4, create an RTCSctpTransport with an initial state
of "connecting" and assign the result to the [[SctpTransport]] slot.
*/
promise_test(async (t) => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
assert_equals(pc1.sctp, null, 'RTCSctpTransport must be null');
const offer = await generateAudioReceiveOnlyOffer(pc1);
await Promise.all([pc1.setLocalDescription(offer), pc2.setRemoteDescription(offer)]);
const answer = await pc2.createAnswer();
await pc1.setRemoteDescription(answer);
assert_equals(pc1.sctp, null, 'RTCSctpTransport must remain null');
}, 'setRemoteDescription() with answer not containing data media should not initialize pc.sctp');
promise_test(async (t) => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
assert_equals(pc1.sctp, null, 'RTCSctpTransport must be null');
const offer = await generateAudioReceiveOnlyOffer(pc2);
await Promise.all([pc2.setLocalDescription(offer), pc1.setRemoteDescription(offer)]);
const answer = await pc1.createAnswer();
await pc1.setLocalDescription(answer);
assert_equals(pc1.sctp, null, 'RTCSctpTransport must remain null');
}, 'setLocalDescription() with answer not containing data media should not initialize pc.sctp');
function validateSctpTransport(sctp) {
assert_not_equals(sctp, null, 'RTCSctpTransport must be available');
assert_true(sctp instanceof RTCSctpTransport,
'Expect pc.sctp to be instance of RTCSctpTransport');
assert_true(sctp.transport instanceof RTCDtlsTransport,
'Expect sctp.transport to be instance of RTCDtlsTransport');
assert_equals(sctp.state, 'connecting', 'RTCSctpTransport should be in the connecting state');
// Note: Yes, Number.POSITIVE_INFINITY is also a 'number'
assert_equals(typeof sctp.maxMessageSize, 'number',
'Expect sctp.maxMessageSize to be a number');
}
promise_test(async (t) => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
assert_equals(pc1.sctp, null, 'RTCSctpTransport must be null');
const offer = await generateDataChannelOffer(pc1);
await Promise.all([pc1.setLocalDescription(offer), pc2.setRemoteDescription(offer)]);
const answer = await pc2.createAnswer();
await pc1.setRemoteDescription(answer);
validateSctpTransport(pc1.sctp);
}, 'setRemoteDescription() with answer containing data media should initialize pc.sctp');
promise_test(async (t) => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
assert_equals(pc1.sctp, null, 'RTCSctpTransport must be null');
const offer = await generateDataChannelOffer(pc2);
await Promise.all([pc2.setLocalDescription(offer), pc1.setRemoteDescription(offer)]);
const answer = await pc1.createAnswer();
await pc1.setLocalDescription(answer);
validateSctpTransport(pc1.sctp);
}, 'setLocalDescription() with answer containing data media should initialize pc.sctp');
</script>
|