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
|
<!doctype html>
<meta charset=utf-8>
<title>RTCRtpTransceiver.prototype.direction</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 editor draft:
// https://rawgit.com/w3c/webrtc-pc/8495678808d126d8bc764bf944996f32981fa6fd/webrtc.html
// The following helper functions are called from RTCPeerConnection-helper.js:
// generateAnswer
/*
5.4. RTCRtpTransceiver Interface
interface RTCRtpTransceiver {
attribute RTCRtpTransceiverDirection direction;
readonly attribute RTCRtpTransceiverDirection? currentDirection;
...
};
*/
/*
5.4. direction
7. Set transceiver's [[Direction]] slot to newDirection.
*/
test(t => {
const pc = new RTCPeerConnection();
const transceiver = pc.addTransceiver('audio');
assert_equals(transceiver.direction, 'sendrecv');
assert_equals(transceiver.currentDirection, null);
transceiver.direction = 'recvonly';
assert_equals(transceiver.direction, 'recvonly');
assert_equals(transceiver.currentDirection, null,
'Expect transceiver.currentDirection to not change');
}, 'setting direction should change transceiver.direction');
/*
5.4. direction
3. If newDirection is equal to transceiver's [[Direction]] slot, abort
these steps.
*/
test(t => {
const pc = new RTCPeerConnection();
const transceiver = pc.addTransceiver('audio', { direction: 'sendonly' });
assert_equals(transceiver.direction, 'sendonly');
transceiver.direction = 'sendonly';
assert_equals(transceiver.direction, 'sendonly');
}, 'setting direction with same direction should have no effect');
promise_test(t => {
const pc = new RTCPeerConnection();
t.add_cleanup(() => pc.close());
const transceiver = pc.addTransceiver('audio', { direction: 'recvonly' });
assert_equals(transceiver.direction, 'recvonly');
assert_equals(transceiver.currentDirection, null);
return pc.createOffer()
.then(offer =>
pc.setLocalDescription(offer)
.then(() => generateAnswer(offer)))
.then(answer => pc.setRemoteDescription(answer))
.then(() => {
assert_equals(transceiver.currentDirection, 'inactive');
transceiver.direction = 'sendrecv';
assert_equals(transceiver.direction, 'sendrecv');
assert_equals(transceiver.currentDirection, 'inactive');
});
}, 'setting direction should change transceiver.direction independent of transceiver.currentDirection');
/*
TODO
An update of directionality does not take effect immediately. Instead, future calls
to createOffer and createAnswer mark the corresponding media description as
sendrecv, sendonly, recvonly or inactive as defined in [JSEP] (section 5.2.2.
and section 5.3.2.).
Tested in RTCPeerConnection-onnegotiationneeded.html
5.4. direction
6. Update the negotiation-needed flag for connection.
Coverage Report
Tested 6
Not Tested 1
Untestable 0
Total 7
*/
</script>
|