diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webrtc/RTCRtpTransceiver-direction.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webrtc/RTCRtpTransceiver-direction.html')
-rw-r--r-- | testing/web-platform/tests/webrtc/RTCRtpTransceiver-direction.html | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webrtc/RTCRtpTransceiver-direction.html b/testing/web-platform/tests/webrtc/RTCRtpTransceiver-direction.html new file mode 100644 index 0000000000..e76bc1fbb7 --- /dev/null +++ b/testing/web-platform/tests/webrtc/RTCRtpTransceiver-direction.html @@ -0,0 +1,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> |