tor-browser

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

constructor-options-script-invalid.js (1236B)


      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    Checks error cases for the options argument to the Locale
      8    constructor.
      9 info: |
     10    Intl.Locale( tag [, options] )
     11    10. If options is undefined, then
     12    11. Else
     13        a. Let options be ? ToObject(options).
     14    12. Set tag to ? ApplyOptionsToTag(tag, options).
     15 
     16    ApplyOptionsToTag( tag, options )
     17    ...
     18    6. If script is not undefined, then
     19        a. If script does not match the script production, throw a RangeError exception.
     20    ...
     21 
     22 features: [Intl.Locale]
     23 ---*/
     24 
     25 /*
     26 script        = 4ALPHA              ; ISO 15924 code
     27 */
     28 const invalidScriptOptions = [
     29  "",
     30  "a",
     31  "ab",
     32  "abc",
     33  "abc7",
     34  "notascript",
     35  "undefined",
     36  "Bal\u0130",
     37  "Bal\u0131",
     38 
     39  // Value contains more than just the 'script' production.
     40  "ary-Arab",
     41  "Latn-SA",
     42  "Latn-vaidika",
     43  "Latn-a-asdf",
     44  "Latn-x-private",
     45 
     46  7,
     47 ];
     48 for (const script of invalidScriptOptions) {
     49  assert.throws(RangeError, function() {
     50    new Intl.Locale("en", {script});
     51  }, `new Intl.Locale("en", {script: "${script}"}) throws RangeError`);
     52 }
     53 
     54 reportCompare(0, 0);