fune/testing/web-platform/tests/webrtc/RTCSctpTransport-constructor.html
Sam Sneddon 3dca6a5a11 Bug 1659864 [wpt PR 25086] - Replace ===/!== in assert_true/false, a=testonly
Automatic update from web-platform-tests
Replace assert_true(x === y) with assert_equals

--
Replace assert_false(x === y) with assert_not_equals

--
Replace assert_true(x !== y) with assert_not_equals

--
Replace assert_true(x == y) with assert_equals

--
Replace assert_false(x == y) with assert_not_equals

--
Replace assert_true(x != y) with assert_not_equals

--
Fix actual/expected argument order

Co-authored-by: Jan-Ivar Bruaroey <jan-ivar@users.noreply.github.com>

--

wpt-commits: e2ddf48b78209d0aef4fa513b53a9f28243c9335, d80a3bccd7b88a7810522c6a1e317a53b0daad57, 54ee81d1501b46e990bc1a1cde162949f7d0ba71, d4beec831b7484382a25bca41b1449b68c235d0a, 278cf9fd6cfb113fd72dc5186534db239cde9e29, e1f3c83b5abc4d122e92db3c390aa8c9b8b4b792, 3cabe516b8e1234ccafd4f5e8aef7f9663b2f53f
wpt-pr: 25086
2020-09-25 19:29:25 +00:00

125 lines
4.5 KiB
HTML

<!doctype html>
<meta charset="utf-8">
<title>RTCSctpTransport constructor</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 revision:
// https://rawgit.com/w3c/webrtc-pc/1cc5bfc3ff18741033d804c4a71f7891242fb5b3/webrtc.html
// The following helper functions are called from RTCPeerConnection-helper.js:
// generateDataChannelOffer()
// generateAnswer()
/*
6.1.
partial interface RTCPeerConnection {
readonly attribute RTCSctpTransport? sctp;
...
};
6.1.1.
interface RTCSctpTransport {
readonly attribute RTCDtlsTransport transport;
readonly attribute RTCSctpTransportState state;
readonly attribute unrestricted double maxMessageSize;
attribute EventHandler onstatechange;
};
4.4.1.1. Constructor
9. Let connection have an [[SctpTransport]] internal slot, initialized to null.
4.4.1.6. Set the RTCSessionSessionDescription
2.2.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, create an RTCSctpTransport with an initial state
of "connecting" and assign the result to the [[SctpTransport]] slot.
*/
promise_test(async (t) => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
assert_equals(pc1.sctp, null, 'RTCSctpTransport must be null');
const offer = await generateAudioReceiveOnlyOffer(pc1);
await Promise.all([pc1.setLocalDescription(offer), pc2.setRemoteDescription(offer)]);
const answer = await pc2.createAnswer();
await pc1.setRemoteDescription(answer);
assert_equals(pc1.sctp, null, 'RTCSctpTransport must remain null');
}, 'setRemoteDescription() with answer not containing data media should not initialize pc.sctp');
promise_test(async (t) => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
assert_equals(pc1.sctp, null, 'RTCSctpTransport must be null');
const offer = await generateAudioReceiveOnlyOffer(pc2);
await Promise.all([pc2.setLocalDescription(offer), pc1.setRemoteDescription(offer)]);
const answer = await pc1.createAnswer();
await pc1.setLocalDescription(answer);
assert_equals(pc1.sctp, null, 'RTCSctpTransport must remain null');
}, 'setLocalDescription() with answer not containing data media should not initialize pc.sctp');
function validateSctpTransport(sctp) {
assert_not_equals(sctp, null, 'RTCSctpTransport must be available');
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_equals(sctp.state, 'connecting', 'RTCSctpTransport should be in the connecting state');
// Note: Yes, Number.POSITIVE_INFINITY is also a 'number'
assert_equals(typeof sctp.maxMessageSize, 'number',
'Expect sctp.maxMessageSize to be a number');
}
promise_test(async (t) => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
assert_equals(pc1.sctp, null, 'RTCSctpTransport must be null');
const offer = await generateDataChannelOffer(pc1);
await Promise.all([pc1.setLocalDescription(offer), pc2.setRemoteDescription(offer)]);
const answer = await pc2.createAnswer();
await pc1.setRemoteDescription(answer);
validateSctpTransport(pc1.sctp);
}, 'setRemoteDescription() with answer containing data media should initialize pc.sctp');
promise_test(async (t) => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
assert_equals(pc1.sctp, null, 'RTCSctpTransport must be null');
const offer = await generateDataChannelOffer(pc2);
await Promise.all([pc2.setLocalDescription(offer), pc1.setRemoteDescription(offer)]);
const answer = await pc1.createAnswer();
await pc1.setLocalDescription(answer);
validateSctpTransport(pc1.sctp);
}, 'setLocalDescription() with answer containing data media should initialize pc.sctp');
</script>