tor-browser

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

RTCConfiguration-iceCandidatePoolSize.html (3700B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <!--
      4 4.2.1 RTCConfiguration Dictionary
      5 
      6  The RTCConfiguration defines a set of parameters to configure how the peer to peer communication established via RTCPeerConnection is established or re-established.
      7 
      8  ...
      9 
     10  iceCandidatePoolSize of type octet, defaulting to 0
     11    Size of the prefetched ICE pool as defined in [JSEP] (section 3.5.4. and section 4.1.1.).
     12 -->
     13 <script src="/resources/testharness.js"></script>
     14 <script src="/resources/testharnessreport.js"></script>
     15 <script>
     16 
     17 /*
     18 
     19 dictionary RTCConfiguration {
     20    ...
     21    [EnforceRange]
     22    octet                    iceCandidatePoolSize = 0;
     23 };
     24 
     25 ... of type octet
     26 */
     27 test(() => {
     28  const pc = new RTCPeerConnection();
     29  assert_idl_attribute(pc, "getConfiguration");
     30  assert_equals(pc.getConfiguration().iceCandidatePoolSize, 0);
     31 }, "Initialize a new RTCPeerConnection with no iceCandidatePoolSize");
     32 
     33 test(() => {
     34  const pc = new RTCPeerConnection({
     35    iceCandidatePoolSize: 0
     36  });
     37  assert_idl_attribute(pc, "getConfiguration");
     38  assert_equals(pc.getConfiguration().iceCandidatePoolSize, 0);
     39 }, "Initialize a new RTCPeerConnection with iceCandidatePoolSize: 0");
     40 
     41 test(() => {
     42  const pc = new RTCPeerConnection({
     43    iceCandidatePoolSize: 255
     44  });
     45  assert_idl_attribute(pc, "getConfiguration");
     46  assert_equals(pc.getConfiguration().iceCandidatePoolSize, 255);
     47 }, "Initialize a new RTCPeerConnection with iceCandidatePoolSize: 255");
     48 
     49 test(() => {
     50  assert_throws_js(TypeError, () => {
     51    new RTCPeerConnection({
     52      iceCandidatePoolSize: -1
     53    });
     54  });
     55 }, "Initialize a new RTCPeerConnection with iceCandidatePoolSize: -1 (Out Of Range)");
     56 
     57 test(() => {
     58  assert_throws_js(TypeError, () => {
     59    new RTCPeerConnection({
     60      iceCandidatePoolSize: 256
     61    });
     62  });
     63 }, "Initialize a new RTCPeerConnection with iceCandidatePoolSize: 256 (Out Of Range)");
     64 
     65 
     66 /*
     67 Reconfiguration
     68 */
     69 
     70 test(() => {
     71  const pc = new RTCPeerConnection();
     72  assert_idl_attribute(pc, "getConfiguration");
     73  assert_idl_attribute(pc, "setConfiguration");
     74  pc.setConfiguration({
     75    iceCandidatePoolSize: 0
     76  });
     77  assert_equals(pc.getConfiguration().iceCandidatePoolSize, 0);
     78 }, "Reconfigure RTCPeerConnection instance iceCandidatePoolSize to 0");
     79 
     80 test(() => {
     81  const pc = new RTCPeerConnection();
     82  assert_idl_attribute(pc, "getConfiguration");
     83  assert_idl_attribute(pc, "setConfiguration");
     84  pc.setConfiguration({
     85    iceCandidatePoolSize: 255
     86  });
     87  assert_equals(pc.getConfiguration().iceCandidatePoolSize, 255);
     88 }, "Reconfigure RTCPeerConnection instance iceCandidatePoolSize to 255");
     89 
     90 /*
     91 The following tests include an explicit assertion for the existence of a
     92 setConfiguration function to prevent the assert_throws_js from catching the
     93 TypeError object that will be thrown when attempting to call the
     94 non-existent setConfiguration method (in cases where it has not yet
     95 been implemented). Without this check, these tests will pass incorrectly.
     96 */
     97 
     98 test(() => {
     99  const pc = new RTCPeerConnection();
    100  assert_equals(typeof pc.setConfiguration, "function", "RTCPeerConnection.prototype.setConfiguration is not implemented");
    101  assert_throws_js(TypeError, () => {
    102    pc.setConfiguration({
    103      iceCandidatePoolSize: -1
    104    });
    105  });
    106 }, "Reconfigure RTCPeerConnection instance iceCandidatePoolSize to -1 (Out Of Range)");
    107 
    108 test(() => {
    109  const pc = new RTCPeerConnection();
    110  assert_equals(typeof pc.setConfiguration, "function", "RTCPeerConnection.prototype.setConfiguration is not implemented");
    111  assert_throws_js(TypeError, () => {
    112    pc.setConfiguration({
    113      iceCandidatePoolSize: 256
    114    });
    115  });
    116 }, "Reconfigure RTCPeerConnection instance iceCandidatePoolSize to 256 (Out Of Range)");
    117 </script>