iterator-close-non-throw-get-method-is-null.js (1243B)
1 // |reftest| async 2 // Copyright (C) 2020 Alexey Shvayka. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 /*--- 5 esid: sec-asynciteratorclose 6 description: > 7 If iterator's "return" method is `null`, 8 received non-throw completion is forwarded to the runtime. 9 info: | 10 AsyncIteratorClose ( iteratorRecord, completion ) 11 12 [...] 13 4. Let innerResult be GetMethod(iterator, "return"). 14 5. If innerResult.[[Type]] is normal, 15 a. Let return be innerResult.[[Value]]. 16 b. If return is undefined, return Completion(completion). 17 18 GetMethod ( V, P ) 19 20 [...] 21 2. Let func be ? GetV(V, P). 22 3. If func is either undefined or null, return undefined. 23 features: [Symbol.asyncIterator, async-iteration] 24 flags: [async] 25 includes: [asyncHelpers.js] 26 ---*/ 27 28 var iterationCount = 0; 29 var returnGets = 0; 30 31 var iterable = {}; 32 iterable[Symbol.asyncIterator] = function() { 33 return { 34 next: function() { 35 return {value: 1, done: false}; 36 }, 37 get return() { 38 returnGets += 1; 39 return null; 40 }, 41 }; 42 }; 43 44 asyncTest(async function() { 45 for await (var _ of iterable) { 46 iterationCount += 1; 47 break; 48 } 49 50 assert.sameValue(iterationCount, 1); 51 assert.sameValue(returnGets, 1); 52 });