thisarg-omitted-sloppy.js (1086B)
1 // |reftest| async 2 // Copyright (C) 2022 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-array.fromasync 7 description: > 8 If thisArg is omitted, mapfn is called with the global object as the 9 this-value in sloppy mode 10 info: | 11 6. If _mapping_ is *true*, then 12 a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). 13 14 OrdinaryCallBindThis, when _F_.[[ThisMode]] is ~global~, where _F_ is the 15 function object: 16 6. Else, 17 a. If _thisArgument_ is *undefined* or *null*, then 18 i. Let _globalEnv_ be _calleeRealm_.[[GlobalEnv]]. 19 ii. Assert: _globalEnv_ is a Global Environment Record. 20 iii. Let _thisValue_ be _globalEnv_.[[GlobalThisValue]]. 21 flags: [async, noStrict] 22 includes: [asyncHelpers.js] 23 features: [Array.fromAsync] 24 ---*/ 25 26 asyncTest(async () => { 27 await Array.fromAsync([1, 2, 3], async function () { 28 assert.sameValue( 29 this, 30 globalThis, 31 "the global should be bound as the this-value of mapfn when thisArg is omitted" 32 ); 33 }); 34 });