tor-browser

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

disambiguation-invalid-string.js (1791B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-temporal.zoneddatetime.from
      7 description: RangeError thrown when disambiguation option not one of the allowed string values
      8 info: |
      9    sec-getoption step 10:
     10      10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception.
     11    sec-temporal-totemporaldisambiguation step 1:
     12      1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*).
     13    sec-temporal-totemporalzoneddatetime step 5:
     14      5. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_).
     15    sec-temporal.zoneddatetime.from step 2:
     16      2. If Type(_item_) is Object and _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then
     17        a. ...
     18        b. Perform ? ToTemporalDisambiguation(_options_).
     19        c. ...
     20        d. Return ...
     21      3. Return ? ToTemporalZonedDateTime(_item_, _options_).
     22 features: [Temporal]
     23 ---*/
     24 
     25 const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC");
     26 assert.throws(RangeError, () => Temporal.ZonedDateTime.from(datetime, { disambiguation: "other string" }));
     27 
     28 const propertyBag = { timeZone: "UTC", year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321 };
     29 [
     30    "",
     31    "EARLIER",
     32    "balance",
     33    "other string",
     34    3,
     35    null
     36 ].forEach(disambiguation => {
     37    assert.throws(RangeError, () => Temporal.ZonedDateTime.from(propertyBag, { disambiguation }))
     38 });
     39 
     40 reportCompare(0, 0);