tor-browser

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

asyncHelpers-throwsAsync-resolved-error.js (844B)


      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    Thenables that resolve with an error do not satisfy the assertion.
      7 flags: [async]
      8 includes: [asyncHelpers.js]
      9 ---*/
     10 
     11 asyncTest(async function () {
     12  var caught = false;
     13 
     14  const p = assert.throwsAsync(
     15    Error,
     16    Promise.resolve(new Error("it's-a-me, Chris Pratt"))
     17  );
     18  assert(p instanceof Promise);
     19  try {
     20    await p;
     21  } catch (err) {
     22    caught = true;
     23    assert.sameValue(
     24      err.constructor,
     25      Test262Error,
     26      "Expected a Test262Error, but a '" +
     27        err.constructor.name +
     28        "' was thrown."
     29    );
     30  } finally {
     31    assert(
     32      caught,
     33      "assert.throwsAsync did not reject when the thenable resolved with an error"
     34    );
     35  }
     36 });