tor-browser

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

options-style-valid.js (1545B)


      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  10. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
     18  ...
     19  12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined).
     20  13. If type is undefined, throw a TypeError exception.
     21  ...
     22 
     23  GetOption ( options, property, type, values, fallback )
     24 
     25  1. Let value be ? Get(options, property).
     26  ...
     27 features: [Intl.DisplayNames]
     28 locale: [en]
     29 ---*/
     30 
     31 // results for option values verified in the tests for resolvedOptions
     32 
     33 const styles = [
     34  undefined,
     35  'narrow',
     36  'short',
     37  'long'
     38 ];
     39 
     40 const types = ['language', 'region', 'script', 'currency'];
     41 
     42 types.forEach( type => {
     43  styles.forEach(style => {
     44    var obj = new Intl.DisplayNames('en', { style, type });
     45 
     46    assert(obj instanceof Intl.DisplayNames, `instanceof check - ${style}`);
     47    assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype, `proto check - ${style}`);
     48  });
     49 });
     50 
     51 reportCompare(0, 0);