tor-browser

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

options-localeMatcher-valid.js (1717B)


      1 // Copyright (C) 2019 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-Intl.DisplayNames
      6 description: >
      7  Valid options for localeMatcher
      8 info: |
      9  Intl.DisplayNames ( locales , options )
     10 
     11  1. If NewTarget is undefined, throw a TypeError exception.
     12  2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
     13    « [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
     14  ...
     15  4. Let options be ? ToObject(options).
     16  ...
     17  8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
     18  ...
     19  10. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
     20  ...
     21  12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined).
     22  13. If type is undefined, throw a TypeError exception.
     23  ...
     24  15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
     25  ...
     26 
     27  GetOption ( options, property, type, values, fallback )
     28 
     29  1. Let value be ? Get(options, property).
     30  ...
     31 features: [Intl.DisplayNames]
     32 locale: [en]
     33 ---*/
     34 
     35 // results for option values verified in the tests for resolvedOptions
     36 
     37 const localeMatchers = [
     38  undefined,
     39  'lookup',
     40  'best fit'
     41 ];
     42 
     43 localeMatchers.forEach(localeMatcher => {
     44  const obj = new Intl.DisplayNames('en', { localeMatcher, type: 'language' });
     45 
     46  assert(obj instanceof Intl.DisplayNames, `instanceof check - ${localeMatcher}`);
     47  assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype, `proto check - ${localeMatcher}`);
     48 });
     49 
     50 reportCompare(0, 0);