tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

constructor-options-numberingSystem-invalid.js (1065B)


      1 // Copyright 2022 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.DurationFormat
      6 description: >
      7    Checks error cases for the options argument to the DurationFormat constructor.
      8 info: |
      9    Intl.DurationFormat ( [ locales [ , options ] ] )
     10    (...)
     11    6. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined).
     12    7. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
     13 features: [Intl.DurationFormat]
     14 ---*/
     15 
     16 const invalidOptions = [
     17  "",
     18  "a",
     19  "ab",
     20  "abcdefghi",
     21  "abc-abcdefghi",
     22  "!invalid!",
     23  "-latn-",
     24  "latn-",
     25  "latn--",
     26  "latn-ca",
     27  "latn-ca-",
     28  "latn-ca-gregory",
     29  "latné",
     30  "latn编号",
     31 ];
     32 for (const numberingSystem of invalidOptions) {
     33  assert.throws(RangeError, function() {
     34    new Intl.DurationFormat('en', {numberingSystem});
     35  }, `new Intl.DurationFormat("en", {numberingSystem: "${numberingSystem}"}) throws RangeError`);
     36 }
     37 
     38 reportCompare(0, 0);