tor-browser

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

invalid-license.js (1609B)


      1 function runTest(config)
      2 {
      3    promise_test(function (test) {
      4        var initDataType;
      5        var initData;
      6        var keySystem = config.keysystem;
      7        var invalidLicense = new Uint8Array([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77]);
      8        var messageEventFired = false;
      9 
     10        var p = navigator.requestMediaKeySystemAccess(keySystem, getSimpleConfiguration()).then(function (access) {
     11            initDataType = access.getConfiguration().initDataTypes[0];
     12            initData = getInitData(initDataType);
     13            return access.createMediaKeys();
     14        }).then(function (mediaKeys) {
     15            var keySession = mediaKeys.createSession();
     16            var eventWatcher = new EventWatcher(test, keySession, ['message']);
     17            var promise = eventWatcher.wait_for('message');
     18            keySession.generateRequest(initDataType, initData);
     19            return promise;
     20        }).then(function (messageEvent) {
     21            messageEventFired = true;
     22            return messageEvent.target.update(invalidLicense);
     23        }).catch(function (error) {
     24            // Ensure we reached the update() call we are trying to test.
     25            if (!messageEventFired) {
     26                assert_unreached(
     27                    `Failed to reach the update() call.  Error: '${error.name}' '${error.message}'`);
     28            }
     29 
     30            // Propagate the error on through.
     31            throw error;
     32        });
     33 
     34        return promise_rejects_js(
     35            test, TypeError, p,
     36            'update() should fail because of an invalid license.');
     37    }, 'Update with invalid Clear Key license');
     38 }