tor-browser

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

getCanonicalLocales-overridden-arg-length.js (746B)


      1 // |reftest| skip-if(!this.hasOwnProperty("Intl"))
      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 // Tests the getCanonicalLocales function for overridden argument's length.
      7 
      8 var count = 0;
      9 var locs = { get length() { if (count++ > 0) throw 42; return 0; } };
     10 var locales = Intl.getCanonicalLocales(locs); // shouldn't throw 42
     11 assertEq(locales.length, 0);
     12 
     13 
     14 var obj = { get 0() { throw new Error("must not be gotten!"); },
     15            length: -Math.pow(2, 32) + 1 };
     16 
     17 assertEq(Intl.getCanonicalLocales(obj).length, 0);
     18 
     19 if (typeof reportCompare === 'function')
     20    reportCompare(0, 0);