tor-browser

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

overflow-invalid-string.js (1687B)


      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.plainmonthday.from
      7 description: RangeError thrown when overflow 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-totemporaloverflow step 1:
     12      1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*).
     13    sec-temporal-totemporalmonthday steps 3–4:
     14      3. If Type(_item_) is Object, then
     15        ...
     16        j. Return ? MonthDayFromFields(_calendar_, _fields_, _options_).
     17      4. Perform ? ToTemporalOverflow(_options_).
     18    sec-temporal.plainmonthday.from steps 2–3:
     19      2. If Type(_item_) is Object and _item_ has an [[InitializedTemporalMonthDay]] internal slot, then
     20        a. Perform ? ToTemporalOverflow(_options_).
     21        b. Return ...
     22      3. Return ? ToTemporalMonthDay(_item_, _options_).
     23 features: [Temporal]
     24 ---*/
     25 
     26 const validValues = [
     27  new Temporal.PlainMonthDay(5, 2),
     28  { monthCode: "M05", day: 2 },
     29  "05-02",
     30 ];
     31 
     32 const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"];
     33 for (const value of validValues) {
     34  for (const overflow of badOverflows) {
     35    assert.throws(
     36      RangeError,
     37      () => Temporal.PlainMonthDay.from(value, { overflow }),
     38      `invalid overflow ("${overflow}")`
     39    );
     40  }
     41 }
     42 
     43 reportCompare(0, 0);