tor-browser

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

argument-object-tostring.js (1079B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
      2 // Copyright (C) 2022 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.instant.compare
      7 description: Object is converted to a string, then to Temporal.Instant
      8 features: [Temporal]
      9 ---*/
     10 
     11 const epoch = new Temporal.Instant(0n);
     12 
     13 const arg = {};
     14 assert.throws(RangeError, () => Temporal.Instant.compare(arg, epoch), "[object Object] is not a valid ISO string (first argument)");
     15 assert.throws(RangeError, () => Temporal.Instant.compare(epoch, arg), "[object Object] is not a valid ISO string (second argument)");
     16 
     17 arg.toString = function() {
     18  return "1970-01-01T00:00Z";
     19 };
     20 const result1 = Temporal.Instant.compare(arg, epoch);
     21 assert.sameValue(result1, 0, "result of toString is interpreted as ISO string (first argument)");
     22 const result2 = Temporal.Instant.compare(epoch, arg);
     23 assert.sameValue(result2, 0, "result of toString is interpreted as ISO string (second argument)");
     24 
     25 reportCompare(0, 0);