tor-browser

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

testharness-additions.js (831B)


      1 // Copyright 2020 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 function assert_throws_jspi(code, func, description) {
      6    try {
      7      func();
      8    } catch (e) {
      9      assert_true(
     10          e.name === code.name,
     11          'expected exception ' + code.name + ', got ' + e.name);
     12      return;
     13    }
     14    assert_true(
     15        false, 'expected exception ' + code.name + ', no exception thrown');
     16  }
     17 
     18  function promise_rejects_jspi(test, expected, promise, description) {
     19    return promise
     20          .then(() => assert_unreached('Should have rejected: ' + description))
     21          .catch(function(e) {
     22              assert_throws_jspi(expected, function() {
     23                throw e;
     24              }, description);
     25        });
     26  }