tor-browser

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

constructor-parse-twice.js (1907B)


      1 // Copyright 2018 André Bargull; 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.locale
      6 description: >
      7  Verifies the handling of options with grandfathered tags.
      8 info: |
      9  Intl.Locale( tag [, options] )
     10  12. Set tag to ? ApplyOptionsToTag(tag, options).
     11  14. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined).
     12  16. Set opt.[[ca]] to calendar.
     13  30. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
     14 
     15  ApplyOptionsToTag( tag, options )
     16  ...
     17  2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception.
     18 
     19  IsStructurallyValidLanguageTag ( locale )
     20 
     21  The IsStructurallyValidLanguageTag abstract operation verifies that the
     22  locale argument (which must be a String value)
     23 
     24  represents a well-formed Unicode BCP 47 Locale Identifier" as specified in
     25  Unicode Technical Standard 35 section 3.2, or successor,
     26 
     27 features: [Intl.Locale]
     28 ---*/
     29 
     30 const testData = [
     31  // Canonicalized version of "en-GB-oed", which we can add "US" to right away.
     32  {
     33    tag: "en-GB-oxendict",
     34    options: {
     35      region: "US",
     36      calendar: "gregory",
     37    },
     38    canonical: "en-US-oxendict-u-ca-gregory",
     39  },
     40 ];
     41 
     42 for (const {tag, options, canonical} of testData) {
     43  assert.sameValue(
     44    new Intl.Locale(tag, options).toString(),
     45    canonical,
     46    `new Intl.Locale("${tag}", ${options}).toString() returns "${canonical}"`
     47  );
     48 }
     49 
     50 assert.throws(RangeError, () =>
     51    new Intl.Locale("no-bok", {region: "NO", calendar: "gregory"}));
     52 assert.throws(RangeError, () =>
     53    new Intl.Locale("no-bok", {region: "SE", calendar: "gregory"}));
     54 assert.throws(RangeError, () =>
     55    new Intl.Locale("no-bok-NO", {region: "SE", calendar: "gregory"}));
     56 assert.throws(RangeError, () =>
     57    new Intl.Locale("no-bok-SE", {region: "NO", calendar: "gregory"}));
     58 
     59 
     60 reportCompare(0, 0);