this-constructor-with-bad-length-setter.js (978B)
1 // |reftest| async 2 // Copyright (C) 2023 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 Rejects the promise if setting the length fails on an instance of a custom 9 this-value 10 info: | 11 3.j.ii.4.a. Perform ? Set(_A_, *"length"*, 𝔽(_k_), *true*). 12 ... 13 3.k.viii. Perform ? Set(_A_, *"length"*, 𝔽(_len_), *true*) 14 includes: [asyncHelpers.js] 15 flags: [async] 16 features: [Array.fromAsync] 17 ---*/ 18 19 asyncTest(async function () { 20 class MyArray { 21 set length(v) { 22 throw new Test262Error("setter of length property throws") 23 } 24 } 25 26 await assert.throwsAsync(Test262Error, () => Array.fromAsync.call(MyArray, [0, 1, 2]), "Promise rejected if setting length fails"); 27 28 await assert.throwsAsync(Test262Error, () => Array.fromAsync.call(MyArray, { 29 length: 3, 30 0: 0, 31 1: 1, 32 2: 2 33 }), "Promise rejected if setting length from array-like fails"); 34 });