Skip to content
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

Add test for constructing RTCSctpTransport #6147

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions webrtc/RTCSctpTransport-constructor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!doctype html>
<meta charset="utf-8">
<title>RTCSctpTransport constructor</title>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add this to interfaces.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This require quite a bit of refactoring on interfaces.html since it involves async initialization. I will put that in a separate PR together with other pending interface tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will put that in a separate PR together with other pending interface tests.

Sounds like a good plan!

<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://w3c.github.io/webrtc-pc/archives/20170515/webrtc.html

// The following helper functions are called from RTCPeerConnection-helper.js:
// generateOffer()
// generateAnswer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome :)

If I have time, I will try to update all the other tests with this comment.


/*
6.1. RTCPeerConnection Interface Extensions
partial interface RTCPeerConnection {
readonly attribute RTCSctpTransport? sctp;
...
};

1.1. RTCSctpTransport Interface
interface RTCSctpTransport {
readonly attribute RTCDtlsTransport transport;
readonly attribute unsigned long maxMessageSize;
};

4.3.1. Operation
When the RTCPeerConnection() constructor is invoked
8. Let connection have an [[sctpTransport]] internal slot,
initialized to null.

To set an RTCSessionDescription description
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,
set the value of connection's [[sctpTransport]] internal slot
to a newly created RTCSctpTransport.
*/

promise_test(t => {
const pc = new RTCPeerConnection();
assert_equals(pc.sctp, null);
pc.createDataChannel('test');

return pc.createOffer()
.then(offer =>
pc.setLocalDescription(offer)
.then(() => generateAnswer(offer)))
.then(answer => pc.setRemoteDescription(answer))
.then(() => {
const { sctp } = pc;
assert_not_equals(sctp, null);
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_true(typeof sctp.maxMessageSize, 'number',
'Expect sctp.maxMessageSize to be a number');
});
}, 'setRemoteDescription() with answer containing data media should initialize pc.sctp');

promise_test(t => {
const pc = new RTCPeerConnection();
assert_equals(pc.sctp, null);

return generateOffer({ data: true })
.then(offer => pc.setRemoteDescription(offer))
.then(() => pc.createAnswer())
.then(answer => pc.setLocalDescription(answer))
.then(() => {
const { sctp } = pc;
assert_not_equals(sctp, null);
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_true(typeof sctp.maxMessageSize, 'number',
'Expect sctp.maxMessageSize to be a number');
});
}, 'setLocalDescription() with answer containing data media should initialize pc.sctp');
</script>