tor-browser

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

overflow-invalid-string.js (1247B)


      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.plaintime.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.plaintime.from step 2:
     14      2. Let _overflow_ be ? ToTemporalOverflow(_options_).
     15 features: [Temporal]
     16 ---*/
     17 
     18 const validValues = [
     19  new Temporal.PlainTime(12),
     20  { hour: 12 },
     21  "12:00",
     22 ];
     23 
     24 const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"];
     25 for (const value of validValues) {
     26  for (const overflow of badOverflows) {
     27    assert.throws(
     28      RangeError,
     29      () => Temporal.PlainTime.from(value, { overflow }),
     30      `invalid overflow ("${overflow}")`
     31    );
     32  }
     33 }
     34 
     35 reportCompare(0, 0);