tor-browser

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

constructor-options-timeStyle-invalid.js (871B)


      1 // Copyright 2019 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-createdatetimeformat
      6 description: >
      7    Checks error cases for the options argument to the DateTimeFormat constructor.
      8 info: |
      9    CreateDateTimeFormat ( dateTimeFormat, locales, options, required, defaults )
     10 
     11    ...
     12    41. Let timeStyle be ? GetOption(options, "timeStyle", "string", « "full", "long", "medium", "short" », undefined).
     13 features: [Intl.DateTimeFormat-datetimestyle]
     14 ---*/
     15 
     16 
     17 const invalidOptions = [
     18  "",
     19  "FULL",
     20  " long",
     21  "short ",
     22  "narrow",
     23  "numeric",
     24 ];
     25 for (const timeStyle of invalidOptions) {
     26  assert.throws(RangeError, function() {
     27    new Intl.DateTimeFormat("en", { timeStyle });
     28  }, `new Intl.DateTimeFormat("en", { timeStyle: "${timeStyle}" }) throws RangeError`);
     29 }
     30 
     31 reportCompare(0, 0);