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 compare function is bound to its Intl.Collator. |
michael@0 | 6 | * @author Norbert Lindenberg |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | $INCLUDE("testIntl.js"); |
michael@0 | 10 | |
michael@0 | 11 | var strings = ["d", "O", "od", "oe", "of", "ö", "o\u0308", "X", "y", "Z", "Z.", "𠮷野家", "吉野家", "!A", "A", "b", "C"]; |
michael@0 | 12 | var locales = [undefined, ["de"], ["de-u-co-phonebk"], ["en"], ["ja"], ["sv"]]; |
michael@0 | 13 | var options = [ |
michael@0 | 14 | undefined, |
michael@0 | 15 | {usage: "search"}, |
michael@0 | 16 | {sensitivity: "base", ignorePunctuation: true} |
michael@0 | 17 | ]; |
michael@0 | 18 | |
michael@0 | 19 | locales.forEach(function (locales) { |
michael@0 | 20 | options.forEach(function (options) { |
michael@0 | 21 | var collatorObj = new Intl.Collator(locales, options); |
michael@0 | 22 | var compareFunc = collatorObj.compare; |
michael@0 | 23 | var referenceSorted = strings.slice(); |
michael@0 | 24 | referenceSorted.sort(function (a, b) { return collatorObj.compare(a, b); }); |
michael@0 | 25 | var sorted = strings; |
michael@0 | 26 | sorted.sort(compareFunc); |
michael@0 | 27 | try { |
michael@0 | 28 | testArraysAreSame(referenceSorted, sorted); |
michael@0 | 29 | } catch (e) { |
michael@0 | 30 | e.message += " (Testing with locales " + locales + "; options " + |
michael@0 | 31 | (options ? JSON.stringify(options) : options) + ".)"; |
michael@0 | 32 | throw e; |
michael@0 | 33 | } |
michael@0 | 34 | }); |
michael@0 | 35 | }); |
michael@0 | 36 |