From 5867eb3f1a487cfcd166c8d93f5734bd1dfff3ef Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 25 Jul 2018 20:35:14 -0400 Subject: [PATCH] thrower in the middle --- .../Promise/resolve-constructor-trickery.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/built-ins/Promise/resolve-constructor-trickery.js diff --git a/test/built-ins/Promise/resolve-constructor-trickery.js b/test/built-ins/Promise/resolve-constructor-trickery.js new file mode 100644 index 0000000000..0724f7b859 --- /dev/null +++ b/test/built-ins/Promise/resolve-constructor-trickery.js @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: thrower in the middle +flags: [async] +---*/ + +var throwable = new Test262Error("lol"); +var p = Promise.resolve(42); + +Object.defineProperty(p, "constructor", { + get() { + throw throwable; + } +}); + +async function fn() { + return await p; +} + +fn().then( + result => { + throw new Test262Error("Promise should be rejected."); + }, + error => { + assert.sameValue(error, throwable, "Promise should be rejected with throwable"); + } +).then($DONE, $DONE); +