constructor-options-throwing-getters.js (763B)
1 // Copyright 2018 Igalia, S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-Intl.Locale 6 description: Checks the propagation of exceptions from the options for the Locale constructor. 7 features: [Intl.Locale] 8 ---*/ 9 10 function CustomError() {} 11 12 const options = [ 13 "language", 14 "script", 15 "region", 16 "variants", 17 "calendar", 18 "collation", 19 "hourCycle", 20 "caseFirst", 21 "numeric", 22 "numberingSystem", 23 ]; 24 25 for (const option of options) { 26 assert.throws(CustomError, () => { 27 new Intl.Locale("en", { 28 get [option]() { 29 throw new CustomError(); 30 } 31 }); 32 }, 33 `new Intl.Locale("en", {get ${option}() {throw new CustomError();}}) throws CustomError`); 34 } 35 36 reportCompare(0, 0);