this-constructor-with-unsettable-element.js (896B)
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 an element fails on an instance of a custom 9 this-value 10 info: | 11 3.j.ii.8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). 12 9. If _defineStatus_ is an abrupt completion, return ? AsyncIteratorClose(_iteratorRecord_, _defineStatus_). 13 includes: [asyncHelpers.js] 14 flags: [async] 15 features: [Array.fromAsync] 16 ---*/ 17 18 asyncTest(async function () { 19 function MyArray() { 20 Object.defineProperty(this, 0, { 21 enumerable: true, 22 writable: true, 23 configurable: false, 24 value: 0 25 }); 26 } 27 28 await assert.throwsAsync(TypeError, () => Array.fromAsync.call(MyArray, [0, 1, 2]), "Promise rejected if defining element fails"); 29 });