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