tor-browser

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

test_rtcIdentityProvider.js (1059B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 function run_test() {
      5  let sb = new Cu.Sandbox('https://www.example.com',
      6                          { wantGlobalProperties: ['rtcIdentityProvider'] });
      7 
      8  function exerciseInterface() {
      9    equal(typeof rtcIdentityProvider, 'object');
     10    equal(typeof rtcIdentityProvider.register, 'function');
     11    rtcIdentityProvider.register({
     12      generateAssertion: function(a, b, c) {
     13        return Promise.resolve({
     14          idp: { domain: 'example.com' },
     15          assertion: JSON.stringify([a, b, c])
     16        });
     17      },
     18      validateAssertion: function(d, e) {
     19        return Promise.resolve({
     20          identity: 'user@example.com',
     21          contents: JSON.stringify([d, e])
     22        });
     23      }
     24    });
     25  }
     26 
     27  sb.equal = equal;
     28  Cu.evalInSandbox('(' + exerciseInterface.toSource() + ')();', sb);
     29  ok(sb.rtcIdentityProvider.hasIdp);
     30 
     31  Cu.importGlobalProperties(['rtcIdentityProvider']);
     32  exerciseInterface();
     33  ok(rtcIdentityProvider.hasIdp);
     34 }