Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright 2012 Mozilla Corporation. All rights reserved. |
michael@0 | 2 | // This code is governed by the BSD license found in the LICENSE file. |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * @description Tests that non-objects are converted to objects before canonicalization. |
michael@0 | 6 | * @author Norbert Lindenberg |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | $INCLUDE("testIntl.js"); |
michael@0 | 10 | |
michael@0 | 11 | testWithIntlConstructors(function (Constructor) { |
michael@0 | 12 | // undefined is handled separately |
michael@0 | 13 | |
michael@0 | 14 | // null should result in a TypeError |
michael@0 | 15 | var error; |
michael@0 | 16 | try { |
michael@0 | 17 | var supportedForNull = Constructor.supportedLocalesOf(null); |
michael@0 | 18 | } catch (e) { |
michael@0 | 19 | error = e; |
michael@0 | 20 | } |
michael@0 | 21 | if (error === undefined) { |
michael@0 | 22 | $ERROR("Null as locale list was not rejected."); |
michael@0 | 23 | } else if (error.name !== "TypeError") { |
michael@0 | 24 | $ERROR("Null as locale list was rejected with wrong error " + error.name + "."); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | // let's use an empty list for comparison |
michael@0 | 28 | var supportedForEmptyList = Constructor.supportedLocalesOf([]); |
michael@0 | 29 | // we don't compare the elements because length should be 0 - let's just verify that |
michael@0 | 30 | if (supportedForEmptyList.length !== 0) { |
michael@0 | 31 | $ERROR("Internal test error: Assumption about length being 0 is invalid."); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | // most non-objects will be interpreted as empty lists because a missing length property is interpreted as 0 |
michael@0 | 35 | var supportedForNumber = Constructor.supportedLocalesOf(5); |
michael@0 | 36 | if (supportedForNumber.length !== supportedForEmptyList.length) { |
michael@0 | 37 | $ERROR("Supported locales differ between numeric and empty list input."); |
michael@0 | 38 | } |
michael@0 | 39 | var supportedForBoolean = Constructor.supportedLocalesOf(true); |
michael@0 | 40 | if (supportedForBoolean.length !== supportedForEmptyList.length) { |
michael@0 | 41 | $ERROR("Supported locales differ between boolean and empty list input."); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | return true; |
michael@0 | 45 | }); |
michael@0 | 46 |