tor-browser

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

constructor-options-firstDayOfWeek-invalid.js (1050B)


      1 // |reftest| skip -- Intl.Locale-info is not supported
      2 // Copyright 2023 Google Inc.  All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-intl.locale
      7 description: >
      8    Checks error cases for the options argument to the Locale constructor.
      9 info: |
     10    Intl.Locale( tag [, options] )
     11 
     12    ...
     13    x. Let fw be ? GetOption(options, "firstDayOfWeek", "string", undefined, undefined).
     14    x. If fw is not undefined, then
     15       x. Set fw to !WeekdayToString(fw).
     16       x. If fw does not match the type sequence (from UTS 35 Unicode Locale Identifier, section 3.2), throw a RangeError exception.
     17    ...
     18 
     19 features: [Intl.Locale,Intl.Locale-info]
     20 ---*/
     21 
     22 const invalidFirstDayOfWeekOptions = [
     23  "",
     24  "m",
     25  "mo",
     26  "longerThan8Chars",
     27 ];
     28 for (const firstDayOfWeek of invalidFirstDayOfWeekOptions) {
     29  assert.throws(RangeError, function() {
     30    new Intl.Locale('en', {firstDayOfWeek});
     31  }, `new Intl.Locale("en", {firstDayOfWeek: "${firstDayOfWeek}"}) throws RangeError`);
     32 }
     33 
     34 reportCompare(0, 0);