2016-06-25 00:43:22 +02:00
|
|
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
2015-06-22 23:16:17 +02:00
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
|
|
|
/*---
|
|
|
|
description: >
|
2016-06-25 00:43:22 +02:00
|
|
|
Error retrieving the constructor's `resolve` method (iterator closing)
|
|
|
|
esid: sec-promise.race
|
|
|
|
info: |
|
2015-06-22 23:16:17 +02:00
|
|
|
11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
|
|
|
|
12. If result is an abrupt completion,
|
|
|
|
a. If iteratorRecord.[[done]] is false, let result be
|
|
|
|
IteratorClose(iterator, result).
|
|
|
|
b. IfAbruptRejectPromise(result, promiseCapability).
|
|
|
|
|
|
|
|
[...]
|
|
|
|
|
|
|
|
25.4.4.3.1 Runtime Semantics: PerformPromiseRace
|
|
|
|
|
|
|
|
1. Repeat
|
|
|
|
[...]
|
|
|
|
h. Let nextPromise be Invoke(C, "resolve", «nextValue»).
|
|
|
|
i. ReturnIfAbrupt(nextPromise).
|
2016-06-25 00:43:22 +02:00
|
|
|
features: [Symbol.iterator]
|
2015-06-22 23:16:17 +02:00
|
|
|
---*/
|
|
|
|
|
2016-06-25 00:43:22 +02:00
|
|
|
var iter = {};
|
2019-04-24 19:35:20 +02:00
|
|
|
|
2016-06-25 00:43:22 +02:00
|
|
|
var returnCount = 0;
|
2019-04-24 19:35:20 +02:00
|
|
|
var nextCount = 0;
|
|
|
|
|
2016-06-25 00:43:22 +02:00
|
|
|
iter[Symbol.iterator] = function() {
|
|
|
|
return {
|
|
|
|
next: function() {
|
2019-04-24 19:35:20 +02:00
|
|
|
nextCount += 1;
|
2018-02-15 21:11:21 +01:00
|
|
|
return {
|
|
|
|
done: false
|
|
|
|
};
|
2016-06-25 00:43:22 +02:00
|
|
|
},
|
|
|
|
return: function() {
|
|
|
|
returnCount += 1;
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
2015-06-22 23:16:17 +02:00
|
|
|
Object.defineProperty(Promise, 'resolve', {
|
2019-04-24 19:35:20 +02:00
|
|
|
get() {
|
2016-06-25 00:43:22 +02:00
|
|
|
throw new Test262Error();
|
2015-06-22 23:16:17 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-06-25 00:43:22 +02:00
|
|
|
Promise.race(iter);
|
|
|
|
|
2019-04-24 19:35:20 +02:00
|
|
|
assert.sameValue(nextCount, 0);
|
2019-06-21 20:26:57 +02:00
|
|
|
assert.sameValue(returnCount, 1);
|