tor-browser

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

RTCOAuthCredential.html (1543B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>RTCConfiguration iceServers with OAuth credentials</title>
      4 <script src='/resources/testharness.js'></script>
      5 <script src='/resources/testharnessreport.js'></script>
      6 <script src='../webrtc/RTCConfiguration-helper.js'></script>
      7 <script>
      8  'use strict';
      9 
     10 // These tests are based on
     11 // https://w3c.github.io/webrtc-extensions/#rtcoauthcredential-dictionary
     12 
     13 /*
     14    4.3.2.  To set a configuration
     15    11.6. If scheme name is turn or turns, and server.credentialType is "oauth",
     16    and server.credential is not an RTCOAuthCredential, then throw an
     17    InvalidAccessError and abort these steps.
     18 */
     19 config_test(makePc => {
     20  assert_throws_dom('InvalidAccessError', () =>
     21    makePc({ iceServers: [{
     22      urls: 'turns:turn.example.org',
     23      credentialType: 'oauth',
     24      username: 'user',
     25      credential: 'cred'
     26    }] }));
     27 }, 'with turns server, credentialType oauth, and string credential should throw InvalidAccessError');
     28 
     29 config_test(makePc => {
     30  const pc = makePc({ iceServers: [{
     31    urls: 'turns:turn2.example.net',
     32    username: '22BIjxU93h/IgwEb',
     33    credential: {
     34      macKey: 'WmtzanB3ZW9peFhtdm42NzUzNG0=',
     35      accessToken: 'AAwg3kPHWPfvk9bDFL936wYvkoctMADzQ5VhNDgeMR3+ZlZ35byg972fW8QjpEl7bx91YLBPFsIhsxloWcXPhA=='
     36    },
     37    credentialType: 'oauth'
     38  }]});
     39  const { iceServers } = pc.getConfiguration();
     40  const server = iceServers[0];
     41  assert_equals(server.credentialType, 'oauth');
     42 }, 'with turns server, credential type and credential from spec should not throw');
     43 
     44 </script>