tor-browser

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

supportedLocalesOf-locales-arg-coered-to-object.js (1496B)


      1 // Copyright 2012 Mozilla Corporation. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 es5id: 9.2.1_4
      6 description: >
      7    Tests that non-objects are converted to objects before
      8    canonicalization.
      9 author: Norbert Lindenberg
     10 includes: [testIntl.js]
     11 ---*/
     12 
     13 testWithIntlConstructors(function (Constructor) {
     14    // undefined is handled separately
     15    
     16    // null should result in a TypeError
     17    assert.throws(TypeError, function() {
     18        var supportedForNull = Constructor.supportedLocalesOf(null);
     19    }, "Null as locale list was not rejected.");
     20    
     21    // let's use an empty list for comparison
     22    var supportedForEmptyList = Constructor.supportedLocalesOf([]);
     23    // we don't compare the elements because length should be 0 - let's just verify that
     24    assert.sameValue(supportedForEmptyList.length, 0, "Internal test error: Assumption about length being 0 is invalid.");
     25 
     26    // most non-objects will be interpreted as empty lists because a missing length property is interpreted as 0
     27    var supportedForNumber = Constructor.supportedLocalesOf(5);
     28    assert.sameValue(supportedForNumber.length, supportedForEmptyList.length, "Supported locales differ between numeric and empty list input.");
     29    var supportedForBoolean = Constructor.supportedLocalesOf(true);
     30    assert.sameValue(supportedForBoolean.length, supportedForEmptyList.length, "Supported locales differ between boolean and empty list input.");
     31 });
     32 
     33 reportCompare(0, 0);