Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 // Copyright 2012 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * @description Tests the special handling of the "co" key in Intl.Collator.
6 * @author Norbert Lindenberg
7 */
9 function checkCollation(extensionCoValue, usageValue, expectedCollations, expectedUsage) {
10 var requestLocale = extensionCoValue !== undefined ? "de-DE-u-co-" + extensionCoValue : "de-DE";
11 var options = usageValue !== undefined ? { usage: usageValue } : undefined;
12 var collator = new Intl.Collator([requestLocale], options);
14 var collation = collator.resolvedOptions().collation;
15 if (expectedCollations.indexOf(collation) === -1) {
16 $ERROR((extensionCoValue === undefined ? "Default collation" : "Collation for \"" + extensionCoValue) +
17 "\" should be " + expectedCollations.join(" or ") + ", but is " + collation + ".");
18 }
20 var usage = collator.resolvedOptions().usage;
21 if (expectedUsage !== usage) {
22 $ERROR((usageValue === undefined ? "Default usage" : "Usage") +
23 " should be " + expectedUsage + ", but is " + usage + ".");
24 }
25 }
27 checkCollation(undefined, undefined, ["default"], "sort");
29 checkCollation("phonebk", undefined, ["phonebk", "default"], "sort");
31 checkCollation("invalid", undefined, ["default"], "sort");
33 checkCollation("standard", undefined, ["default"], "sort");
35 checkCollation("standard", "search", ["default"], "search");
37 checkCollation("standard", "sort", ["default"], "sort");
39 checkCollation("search", undefined, ["default"], "sort");
41 checkCollation("search", "search", ["default"], "search");
43 checkCollation("search", "sort", ["default"], "sort");