tor-browser

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

await-awaits-thenables-that-throw.js (590B)


      1 // |reftest| async
      2 // Copyright 2016 Microsoft, Inc. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 author: Brian Terlson <brian.terlson@microsoft.com>
      7 esid: pending
      8 description: >
      9  Await can await any thenable.
     10 flags: [async]
     11 includes: [asyncHelpers.js]
     12 ---*/
     13 
     14 var error = {};
     15 var thenable = {
     16  then: function (resolve, reject) {
     17    throw error;
     18  }
     19 }
     20 async function foo() {
     21  var caught = false;
     22  try {
     23    await thenable;
     24  } catch(e) {
     25    caught = true;
     26    assert.sameValue(e, error);
     27  }
     28 
     29  assert(caught);
     30 }
     31 
     32 asyncTest(foo);