Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
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 that Intl.Collator.prototype functions throw a
6 * TypeError if called on a non-object value or an object that hasn't been
7 * initialized as a Collator.
8 * @author Norbert Lindenberg
9 */
11 var functions = {
12 "compare getter": Object.getOwnPropertyDescriptor(Intl.Collator.prototype, "compare").get,
13 resolvedOptions: Intl.Collator.prototype.resolvedOptions
14 };
15 var invalidTargets = [undefined, null, true, 0, "Collator", [], {}];
17 Object.getOwnPropertyNames(functions).forEach(function (functionName) {
18 var f = functions[functionName];
19 invalidTargets.forEach(function (target) {
20 var error;
21 try {
22 f.call(target);
23 } catch (e) {
24 error = e;
25 }
26 if (error === undefined) {
27 $ERROR("Calling " + functionName + " on " + target + " was not rejected.");
28 } else if (error.name !== "TypeError") {
29 $ERROR("Calling " + functionName + " on " + target + " was rejected with wrong error " + error.name + ".");
30 }
31 });
32 });