tor-browser

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

asyncHelpers-throwsAsync-single-arg.js (801B)


      1 // |reftest| async
      2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 description: |
      6    assert.throwsAsync returns a promise that rejects when invoked with a single argument
      7 flags: [async]
      8 includes: [asyncHelpers.js]
      9 ---*/
     10 
     11 asyncTest(async function () {
     12  var caught = false;
     13  const p = assert.throwsAsync(function () {});
     14  assert(p instanceof Promise);
     15  try {
     16    await p;
     17  } catch (err) {
     18    caught = true;
     19    assert.sameValue(
     20      err.constructor,
     21      Test262Error,
     22      "Expected a Test262Error, but a '" +
     23        err.constructor.name +
     24        "' was thrown."
     25    );
     26  } finally {
     27    assert(
     28      caught,
     29      "assert.throwsAsync did not reject when invoked with a single argumemnt"
     30    );
     31  }
     32 });