Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/race/iter-next-val-err-no-close.js

raw
1 // Copyright (C) 2016 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 Error when accessing an iterator result's `value` property (not closing
7 iterator)
8 esid: sec-promise.race
9 es6id: 25.4.4.3
10 info: |
11 11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
12 12. If result is an abrupt completion,
13 a. If iteratorRecord.[[done]] is false, let result be
14 IteratorClose(iterator, result).
15 b. IfAbruptRejectPromise(result, promiseCapability).
16
17 [...]
18
19 25.4.4.3.1 Runtime Semantics: PerformPromiseRace
20
21 1. Repeat
22 [...]
23 e. Let nextValue be IteratorValue(next).
24 f. If nextValue is an abrupt completion, set iteratorRecord.[[done]] to
25 true.
26 g. ReturnIfAbrupt(nextValue).
27 features: [Symbol.iterator]
28 ---*/
29
30 var iterNextValThrows = {};
31 var returnCount = 0;
32 var poisonedVal = {
33 done: false
34 };
35 var error = new Test262Error();
36 Object.defineProperty(poisonedVal, 'value', {
37 get: function() {
38 throw error;
39 }
40 });
41 iterNextValThrows[Symbol.iterator] = function() {
42 return {
43 next: function() {
44 return poisonedVal;
45 },
46 return: function() {
47 returnCount += 1;
48 }
49 };
50 };
51
52 Promise.race(iterNextValThrows);
53
54 assert.sameValue(returnCount, 0);