tor-browser

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

throws-when-target-zoned-date-time-outside-valid-limits.js (1280B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2024 André Bargull. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-temporal.duration.compare
      7 description: >
      8  Throws RangeError when adding duration to ZonedDateTime relativeTo fails.
      9 info: |
     10  Temporal.Duration.compare ( one, two [ , options ] )
     11 
     12  12. If zonedRelativeTo is not undefined, and either TemporalUnitCategory(largestUnit1)
     13      or TemporalUnitCategory(largestUnit2) is date, then
     14    ...
     15    c. Let after1 be ? AddZonedDateTime(zonedRelativeTo.[[EpochNanoseconds]], timeZone,
     16       calendar, duration1, constrain).
     17    d. Let after2 be ? AddZonedDateTime(zonedRelativeTo.[[EpochNanoseconds]], timeZone,
     18       calendar, duration2, constrain).
     19    ...
     20 features: [Temporal]
     21 ---*/
     22 
     23 var blank = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
     24 var oneDay = new Temporal.Duration(0, 0, 0, 1);
     25 
     26 var relativeTo = new Temporal.ZonedDateTime(864n * 10n**19n, "UTC");
     27 
     28 var options = {
     29  relativeTo
     30 };
     31 
     32 assert.throws(RangeError, () => Temporal.Duration.compare(oneDay, blank, options));
     33 assert.throws(RangeError, () => Temporal.Duration.compare(blank, oneDay, options));
     34 
     35 reportCompare(0, 0);