tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

RTCDataChannelEvent-constructor.html (1381B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>RTCDataChannelEvent constructor</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7 // Test is based on the following revision:
      8 // https://rawgit.com/w3c/webrtc-pc/1cc5bfc3ff18741033d804c4a71f7891242fb5b3/webrtc.html
      9 
     10 test(function() {
     11    assert_equals(RTCDataChannelEvent.length, 2);
     12    assert_throws_js(
     13        TypeError,
     14        function() { new RTCDataChannelEvent('type'); }
     15    );
     16 }, 'RTCDataChannelEvent constructor without a required argument.');
     17 
     18 test(function() {
     19    assert_throws_js(
     20        TypeError,
     21        function() { new RTCDataChannelEvent('type', { channel: null }); }
     22    );
     23 }, 'RTCDataChannelEvent constructor with channel passed as null.');
     24 
     25 test(function() {
     26    assert_throws_js(
     27        TypeError,
     28        function() { new RTCDataChannelEvent('type', { channel: undefined }); }
     29    );
     30 }, 'RTCDataChannelEvent constructor with a channel passed as undefined.');
     31 
     32 test(t => {
     33    const pc = new RTCPeerConnection();
     34    t.add_cleanup(() => pc.close());
     35 
     36    const dc = pc.createDataChannel('constructor');
     37    const event = new RTCDataChannelEvent('type', { channel: dc });
     38    assert_true(event instanceof RTCDataChannelEvent);
     39    assert_equals(event.channel, dc);
     40 }, 'RTCDataChannelEvent constructor with full arguments.');
     41 </script>