Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 1 | // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Flags: --allow-natives-syntax |
| 6 | |
| 7 | function assertAsync(b, s) { |
| 8 | if (!b) { |
| 9 | %AbortJS(" FAILED!") |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | class P extends Promise { |
| 14 | constructor() { |
| 15 | super(...arguments) |
| 16 | return new Proxy(this, { |
| 17 | get: (_, key) => { |
| 18 | return key == 'then' ? |
| 19 | this.then.bind(this) : |
| 20 | this.constructor.resolve(20) |
| 21 | } |
| 22 | }) |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | let p = P.resolve(10) |
| 27 | p.key.then(v => assertAsync(v === 20)); |