File: RTCSctpTransport-constructor.html

package info (click to toggle)
thunderbird 1%3A60.9.0-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,339,492 kB
  • sloc: cpp: 5,457,040; ansic: 2,360,385; python: 596,167; asm: 340,963; java: 326,296; xml: 258,830; sh: 84,445; makefile: 23,705; perl: 17,317; objc: 3,768; yacc: 1,766; ada: 1,681; lex: 1,364; pascal: 1,264; cs: 879; exp: 527; php: 436; lisp: 258; ruby: 153; awk: 152; sed: 53; csh: 27
file content (87 lines) | stat: -rw-r--r-- 3,116 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!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 editor draft:
  // https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html

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

  /*
    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.4.1.1.  Constructor
      8.  Let connection have an [[sctpTransport]] internal slot, initialized to null.

    4.3.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, 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({ pc, 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>