tor-browser

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

coerced-to-string.js (951B)


      1 // Copyright (C) 2021 André Bargull. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-intl.supportedvaluesof
      6 description: >
      7  Input key is coerced with ToString.
      8 info: |
      9  Intl.supportedValuesOf ( key )
     10 
     11  1. Let key be ? ToString(key).
     12  2. If key is "calendar", then
     13    a. Let list be ! AvailableCalendars( ).
     14  ...
     15  9. Return ! CreateArrayFromList( list ).
     16 includes: [compareArray.js]
     17 features: [Intl-enumeration]
     18 ---*/
     19 
     20 const calendars = Intl.supportedValuesOf("calendar");
     21 
     22 // ToString on a String object.
     23 assert.compareArray(Intl.supportedValuesOf(new String("calendar")), calendars);
     24 
     25 // ToString on a plain object.
     26 let obj = {
     27  toString() {
     28    return "calendar";
     29  }
     30 };
     31 assert.compareArray(Intl.supportedValuesOf(obj), calendars);
     32 
     33 // ToString() of a symbol throws a TypeError.
     34 assert.throws(TypeError, function() {
     35  Intl.supportedValuesOf(Symbol());
     36 });
     37 
     38 reportCompare(0, 0);