New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding tests for RTCDataChannel id attribute. #5742
Conversation
When no ID argument is provided, and the DTLS role hasn't been determined, the id attribute should return `null`. After the DTLS role is determined by an answer being applied with "a=setup:active" (or "passive"), the null IDs should be replaced with either odd or even IDs, depending on the negotiated role.
Notifying @agouaillard, @alvestrand, @dontcallmedom, @foolip, @guidou, @henbos, and @phoglund. (Learn how reviewing works.) |
This is the thing @foolip requested on w3c/webrtc-pc#1137, with an additional test for the odd/even ID selection after |
Read the thread, looked at the code. LGTM. As soon as @foolip approve, (and travis is happy) I will merge. |
LintPassed |
Firefox (nightly channel)Testing web-platform-tests at revision 5805688 All results2 tests ran/webrtc/RTCDataChannel-id.html
/webrtc/RTCPeerConnection-createDataChannel.html
|
Chrome (unstable channel)Testing web-platform-tests at revision 5805688 All results2 tests ran/webrtc/RTCDataChannel-id.html
/webrtc/RTCPeerConnection-createDataChannel.html
|
The new tests are failing on Firefox because it looks like Firefox only assigns the ID after the DTLS (and SCTP?) handshake completes. But the spec currently says it should be assigned by setting an answer. This was discussed briefly in a virtual interim, and changed in this PR: w3c/webrtc-pc#1038 But there wasn't a lot of discussion. @jesup, @jan-ivar, any opinions? Should the spec be more loose about when the ID is assigned? |
This is a spec question. If the test as is tests the current spec draft, I am tempted to merge it in, and let the discussion happen in the spec repository.
If / when there is a spec change, then this test will be modified accordingly.
The risk is that any test could be otherwise stay on hold waiting for the final version of the spec.
Unless there is a strong objection, I will merge it Tuesday evening end of day pacific time.
…Sent from my iPhone
On 30 Apr 2017, at 1:38 pm, Taylor Brandstetter ***@***.***> wrote:
The new tests are failing on Firefox because it looks like Firefox only assigns the ID after the DTLS (and SCTP?) handshake completes. But the spec currently says it should be assigned by setting an answer. This was discussed briefly in a virtual interim, and changed in this PR: w3c/webrtc-pc#1038
But there wasn't a lot of discussion. @jesup, @jan-ivar, any opinions? Should the spec be more loose about when the ID is assigned? I
―
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
const answer = new RTCSessionDescription({ | ||
type: "answer", | ||
sdp: pc.localDescription.sdp.replace("actpass", "active") | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agouaillard By that standard we shouldn't use the legacy RTCSessionDescription constructor ;)
// and should use even data channel IDs, according to rtcweb-data-channel. | ||
assert_equals(channel.id, 0, 'id'); | ||
const another_channel = pc.createDataChannel('another'); | ||
assert_equals(another_channel.id, 2, 'id'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the spec says the next channel must be '2', just that it must be even.
.then(function() { | ||
// Since the remote description had a "passive" DTLS role, we're the client | ||
// and should use even data channel IDs, according to rtcweb-data-channel. | ||
assert_equals(channel.id, 0, 'id'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the spec says this must be 0, just that it must be even
.then(function() { | ||
// Since the remote description had an "active" DTLS role, we're the server | ||
// and should use odd data channel IDs, according to rtcweb-data-channel. | ||
assert_equals(channel.id, 1, 'id'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the spec says this must be 1, just that it must be odd:
"If the side is the DTLS client, it MUST choose an even
Stream Identifier, if the side is the DTLS server, it MUST choose an
odd one. "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Now only testing that the IDs are odd, and distinct from each other.
// and should use odd data channel IDs, according to rtcweb-data-channel. | ||
assert_equals(channel.id, 1, 'id'); | ||
const another_channel = pc.createDataChannel('another'); | ||
assert_equals(another_channel.id, 3, 'id'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the spec says this must be 3, just that it must be odd
The interim discussion was on "what do we return before the id is established", and agreed null made more sense than the current impl's 65535. Assigning the ID when setting the answer would require we inform the DataChannel code of the DTLS roles that will be negotiated, assuming one is guaranteed to know that at Answer time. Right now as stated we (firefox) assign them on DTLS negotiation, which gates us being able to actually send the Open packets on a specific id. |
These tests are now available on w3c-test.org |
Since the answer contains the answerer's selected role, this should be guaranteed. Would it be feasible to change Firefox's behavior? Or should the spec's requirements be made more loose (for example, "the ID will be assigned at some point before |
assert_equals(channel.priority, 'low', 'priority'); | ||
}, 'createDataChannel defaults'); | ||
|
||
async_test(test => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this test into RTCDataChannel-id.html or similar? This file is for the createDataChannel method without further poking at the returned RTCDataChannel.
.then(function() { | ||
// Turn our own offer SDP into valid answer SDP by setting the DTLS role to | ||
// "active". | ||
const answer = new RTCSessionDescription({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setRemoteDescription takes a RTCSessionDescriptionInit dictionary, so just passing the object (dictionary) directly should work?
assert_not_equals(channel.id, another_channel.id); | ||
test.done(); | ||
}) | ||
.catch(test.step_func(function(e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test would probably be slightly smaller using promise_test
, which would avoid the need for this.
const pc = new RTCPeerConnection; | ||
const channel = pc.createDataChannel(''); | ||
pc.createOffer() | ||
.then(function(offer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be offer => pc.setLocalDescription(offer)
@foolip Addressed your comments; take another look. |
When no ID argument is provided, and the DTLS role hasn't been
determined, the id attribute should return
null
.After the DTLS role is determined by an answer being applied with
"a=setup:active" (or "passive"), the null IDs should be replaced with
either odd or even IDs, depending on the negotiated role.
This change is