tor-browser

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

constructor-options-style-valid.js (1132B)


      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: Checks handling of valid values for the style option to the DurationFormat constructor.
      7 info: |
      8    InitializeDurationFormat (DurationFormat, locales, options)
      9    (...)
     10    13. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow", "digital" », "short").
     11    14. Set durationFormat.[[Style]] to style.
     12 features: [Intl.DurationFormat]
     13 ---*/
     14 
     15 const validOptions = [
     16  [undefined, "short"],
     17  ["long", "long"],
     18  ["short", "short"],
     19  ["narrow", "narrow"],
     20  ["digital", "digital"],
     21  [{ toString() { return "short"; } }, "short"],
     22  [{ toString() { return "long"; } }, "long"],
     23  [{ toString() { return "narrow"; } }, "narrow"],
     24  [{ toString() { return "digital"; } }, "digital"],
     25 ];
     26 
     27 for (const [validOption, expected] of validOptions) {
     28  const df = new Intl.DurationFormat([], {"style": validOption});
     29  const resolvedOptions = df.resolvedOptions();
     30  assert.sameValue(resolvedOptions.style, expected);
     31 }
     32 
     33 reportCompare(0, 0);