| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
description: > |
| 6 |
`Promise.race` invoked on a constructor value |
| 7 |
es6id: 25.4.4.3 |
| 8 |
info: | |
| 9 |
1. Let C be the this value. |
| 10 |
[...] |
| 11 |
6. Let promiseCapability be NewPromiseCapability(C). |
| 12 |
[...] |
| 13 |
10. Let iteratorRecord be Record {[[iterator]]: iterator, [[done]]: false}. |
| 14 |
11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C). |
| 15 |
[...] |
| 16 |
13. Return Completion(result). |
| 17 |
features: [class] |
| 18 |
---*/ |
| 19 |
|
| 20 |
var executor = null; |
| 21 |
var callCount = 0; |
| 22 |
|
| 23 |
class SubPromise extends Promise { |
| 24 |
constructor(a) { |
| 25 |
super(a); |
| 26 |
executor = a; |
| 27 |
callCount += 1; |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
var instance = Promise.race.call(SubPromise); |
| 32 |
|
| 33 |
assert.sameValue(instance.constructor, SubPromise); |
| 34 |
assert.sameValue(instance instanceof SubPromise, true); |
| 35 |
|
| 36 |
assert.sameValue(callCount, 1); |
| 37 |
assert.sameValue(typeof executor, 'function'); |