From f15119cd14444b728490c03f4e0c50494e03687b Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Sun, 4 Nov 2018 20:31:22 -0800 Subject: [PATCH 1/3] Update RTCRtpTransceiver setDirection to direction setter --- webrtc/RTCDTMFSender-ontonechange.https.html | 2 +- ....html => RTCRtpTransceiver-direction.html} | 29 +++++++++---------- webrtc/RTCRtpTransceiver.https.html | 4 +-- 3 files changed, 17 insertions(+), 18 deletions(-) rename webrtc/{RTCRtpTransceiver-setDirection.html => RTCRtpTransceiver-direction.html} (74%) diff --git a/webrtc/RTCDTMFSender-ontonechange.https.html b/webrtc/RTCDTMFSender-ontonechange.https.html index ff6d117b3c75dd..49e23abe2f4aa6 100644 --- a/webrtc/RTCDTMFSender-ontonechange.https.html +++ b/webrtc/RTCDTMFSender-ontonechange.https.html @@ -247,7 +247,7 @@ // tonechange event, to make sure that tonechange is triggered // then stopped if(tone === 'A') { - transceiver.setDirection('recvonly'); + transceiver.direction = 'recvonly'; pc.createOffer() .then(offer => diff --git a/webrtc/RTCRtpTransceiver-setDirection.html b/webrtc/RTCRtpTransceiver-direction.html similarity index 74% rename from webrtc/RTCRtpTransceiver-setDirection.html rename to webrtc/RTCRtpTransceiver-direction.html index 32cbff5d985868..47fec762992655 100644 --- a/webrtc/RTCRtpTransceiver-setDirection.html +++ b/webrtc/RTCRtpTransceiver-direction.html @@ -1,6 +1,6 @@ -RTCRtpTransceiver.prototype.setDirection +RTCRtpTransceiver.prototype.direction @@ -8,7 +8,7 @@ 'use strict'; // Test is based on the following editor draft: - // https://rawgit.com/w3c/webrtc-pc/cc8d80f455b86c8041d63bceb8b457f45c72aa89/webrtc.html + // https://rawgit.com/w3c/webrtc-pc/8495678808d126d8bc764bf944996f32981fa6fd/webrtc.html // The following helper functions are called from RTCPeerConnection-helper.js: // generateAnswer @@ -16,16 +16,15 @@ /* 5.4. RTCRtpTransceiver Interface interface RTCRtpTransceiver { - readonly attribute RTCRtpTransceiverDirection direction; + attribute RTCRtpTransceiverDirection direction; readonly attribute RTCRtpTransceiverDirection? currentDirection; - void setDirection(RTCRtpTransceiverDirection direction); ... }; */ /* - 5.4. setDirection - 4. Set transceiver's [[Direction]] slot to newDirection. + 5.4. direction + 7. Set transceiver's [[Direction]] slot to newDirection. */ test(t => { const pc = new RTCPeerConnection(); @@ -33,15 +32,15 @@ assert_equals(transceiver.direction, 'sendrecv'); assert_equals(transceiver.currentDirection, null); - transceiver.setDirection('recvonly'); + transceiver.direction = 'recvonly'; assert_equals(transceiver.direction, 'recvonly'); assert_equals(transceiver.currentDirection, null, 'Expect transceiver.currentDirection to not change'); - }, 'setDirection should change transceiver.direction'); + }, 'setting direction should change transceiver.direction'); /* - 5.4. setDirection + 5.4. direction 3. If newDirection is equal to transceiver's [[Direction]] slot, abort these steps. */ @@ -49,10 +48,10 @@ const pc = new RTCPeerConnection(); const transceiver = pc.addTransceiver('audio', { direction: 'sendonly' }); assert_equals(transceiver.direction, 'sendonly'); - transceiver.setDirection('sendonly'); + transceiver.direction = 'sendonly'; assert_equals(transceiver.direction, 'sendonly'); - }, 'setDirection with same direction should have no effect'); + }, 'setting direction with same direction should have no effect'); promise_test(t => { const pc = new RTCPeerConnection(); @@ -68,21 +67,21 @@ .then(answer => pc.setRemoteDescription(answer)) .then(() => { assert_equals(transceiver.currentDirection, 'recvonly'); - transceiver.setDirection('sendrecv'); + transceiver.direction = 'sendrecv'; assert_equals(transceiver.direction, 'sendrecv'); assert_equals(transceiver.currentDirection, 'recvonly'); }); - }, 'setDirection should change transceiver.direction independent of transceiver.currentDirection'); + }, 'setting direction should change transceiver.direction independent of transceiver.currentDirection'); /* TODO - Calls to setDirection() do not take effect immediately. Instead, future calls + 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. setDirection + 5.4. direction 6. Update the negotiation-needed flag for connection. Coverage Report diff --git a/webrtc/RTCRtpTransceiver.https.html b/webrtc/RTCRtpTransceiver.https.html index 2de9fb9f6ee4db..7d16deaa8c7633 100644 --- a/webrtc/RTCRtpTransceiver.https.html +++ b/webrtc/RTCRtpTransceiver.https.html @@ -1181,7 +1181,7 @@ "InvalidStateError", "replaceTrack on stopped transceiver"); checkThrows(() => transceiver.direction = "sendrecv", - "InvalidStateError", "setDirection on stopped transceiver"); + "InvalidStateError", "set direction on stopped transceiver"); checkThrows(() => transceiver.sender.dtmf.insertDTMF("111"), "InvalidStateError", "insertDTMF on stopped transceiver"); @@ -1775,7 +1775,7 @@ await pc2.setRemoteDescription({type: "rollback"}); // Transceiver should be _gone_, again. replaceTrack doesn't prevent this, - // nor does setDirection. + // nor does setting direction. hasProps(pc2.getTransceivers(), []); // Setting the same offer for a _third_ time should do the same thing From 683054ce143d39139d1f9d5f45dca1d971e237f9 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Sun, 4 Nov 2018 21:35:40 -0800 Subject: [PATCH 2/3] Fix currentDirection in RTCRtpTransceiver-direction.html --- webrtc/RTCRtpTransceiver-direction.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webrtc/RTCRtpTransceiver-direction.html b/webrtc/RTCRtpTransceiver-direction.html index 47fec762992655..e76bc1fbb7740f 100644 --- a/webrtc/RTCRtpTransceiver-direction.html +++ b/webrtc/RTCRtpTransceiver-direction.html @@ -66,10 +66,10 @@ .then(() => generateAnswer(offer))) .then(answer => pc.setRemoteDescription(answer)) .then(() => { - assert_equals(transceiver.currentDirection, 'recvonly'); + assert_equals(transceiver.currentDirection, 'inactive'); transceiver.direction = 'sendrecv'; assert_equals(transceiver.direction, 'sendrecv'); - assert_equals(transceiver.currentDirection, 'recvonly'); + assert_equals(transceiver.currentDirection, 'inactive'); }); }, 'setting direction should change transceiver.direction independent of transceiver.currentDirection'); From c959163a757e201a913ba7e89c95a091b3dd35f8 Mon Sep 17 00:00:00 2001 From: Mark Roberts Date: Tue, 6 Nov 2018 08:17:02 -0800 Subject: [PATCH 3/3] Add negative test for setDirection --- webrtc/historical.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webrtc/historical.html b/webrtc/historical.html index d49503e16d6c5d..ffa28be5bca307 100644 --- a/webrtc/historical.html +++ b/webrtc/historical.html @@ -24,6 +24,14 @@ }, "RTCPeerConnection member " + name + " should not exist"); }); +[ + "setDirection", +].forEach(function(name) { + test(function() { + assert_false(name in RTCRtpTransceiver.prototype); + }, "RTCRtpTransceiver member " + name + " should not exist"); +}); + [ "DataChannel", "mozRTCIceCandidate",