tor-browser

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

15.9.5.5-02.js (1847B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 //-----------------------------------------------------------------------------
      7 var BUGNUMBER = 398485;
      8 var summary = 'Date.prototype.toLocaleString should not clamp year';
      9 var actual = '';
     10 var expect = '';
     11 
     12 
     13 //-----------------------------------------------------------------------------
     14 test();
     15 //-----------------------------------------------------------------------------
     16 
     17 function test()
     18 {
     19  printBugNumber(BUGNUMBER);
     20  printStatus (summary);
     21 
     22  var d;
     23  var y;
     24  var l;
     25  var maxms = 8640000000000000;
     26 
     27  d = new Date(-maxms );
     28  y = d.getFullYear();
     29 
     30  actual = y;
     31  expect = -271821;
     32  reportCompare(expect, actual, summary + ': check year');
     33 
     34  l = d.toLocaleString();
     35  print(l);
     36  if (this.hasOwnProperty("Intl")) {
     37    // ECMA-402 specifies that toLocaleString uses a proleptic Gregorian
     38    // calender without year 0.
     39    // Also, localized strings usually use era indicators such as "BC"
     40    // instead of minus signs.
     41    expect = Math.abs(y - 1) + '';
     42  } else {
     43    // ECMA-262 up to edition 5.1 didn't specify toLocaleString;
     44    // the previous implementation assumed a calendar with year 0 and used
     45    // minus sign.
     46    expect = y + '';
     47  }
     48  actual = l.match(/-?[0-9]{3,}/) + '';
     49  reportCompare(expect, actual, summary + ': check toLocaleString');
     50 
     51  d = new Date(maxms );
     52  y = d.getFullYear();
     53  l = d.toLocaleString();
     54  print(l);
     55 
     56  actual = y;
     57  expect = 275760;
     58  reportCompare(expect, actual, summary + ': check year');
     59 
     60  actual = l.match(new RegExp(y)) + '';
     61  expect = y + '';
     62  reportCompare(expect, actual, summary + ': check toLocaleString');
     63 }