]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | |
2 | var propertyKey = { | |
3 | toString() { | |
4 | throw new Error("propertyKey.toString is called."); | |
5 | } | |
6 | }; | |
7 | ||
8 | function shouldThrow(func, message) { | |
9 | var error = null; | |
10 | try { | |
11 | func(); | |
12 | } catch (e) { | |
13 | error = e; | |
14 | } | |
15 | if (!error) | |
16 | throw new Error("not thrown."); | |
17 | if (String(error) !== message) | |
18 | throw new Error("bad error: " + String(error)); | |
19 | } | |
20 | ||
21 | var object = {}; | |
22 | ||
23 | shouldThrow(function () { | |
24 | object.hasOwnProperty(propertyKey); | |
25 | }, "Error: propertyKey.toString is called."); | |
26 | ||
27 | shouldThrow(function () { | |
28 | Object.prototype.hasOwnProperty.call(null, propertyKey); | |
29 | }, "Error: propertyKey.toString is called."); | |
30 | ||
31 | shouldThrow(function () { | |
32 | Object.prototype.hasOwnProperty.call(null, 'ok'); | |
33 | }, "TypeError: null is not an object (evaluating 'Object.prototype.hasOwnProperty.call(null, 'ok')')"); | |
34 | ||
35 | shouldThrow(function () { | |
36 | object.propertyIsEnumerable(propertyKey); | |
37 | }, "Error: propertyKey.toString is called."); | |
38 | ||
39 | // ToPropertyKey is first, ToObject is following. | |
40 | shouldThrow(function () { | |
41 | Object.prototype.propertyIsEnumerable.call(null, propertyKey); | |
42 | }, "Error: propertyKey.toString is called."); | |
43 | ||
44 | shouldThrow(function () { | |
45 | // ToPropertyKey is first, ToObject is following. | |
46 | Object.prototype.propertyIsEnumerable.call(null, 'ok'); | |
47 | }, "TypeError: null is not an object (evaluating 'Object.prototype.propertyIsEnumerable.call(null, 'ok')')"); | |
48 | ||
49 | shouldThrow(function () { | |
50 | object.__defineGetter__(propertyKey, function () { | |
51 | return 'NG'; | |
52 | }); | |
53 | }, "Error: propertyKey.toString is called."); | |
54 | ||
55 | if (Object.getOwnPropertyDescriptor(object, '')) | |
56 | throw new Error("bad descriptor"); | |
57 | ||
58 | shouldThrow(function () { | |
59 | object.__defineSetter__(propertyKey, function () { | |
60 | return 'NG'; | |
61 | }); | |
62 | }, "Error: propertyKey.toString is called."); | |
63 | ||
64 | if (Object.getOwnPropertyDescriptor(object, '')) | |
65 | throw new Error("bad descriptor"); | |
66 | ||
67 | shouldThrow(function () { | |
68 | object.__lookupGetter__(propertyKey); | |
69 | }, "Error: propertyKey.toString is called."); | |
70 | ||
71 | shouldThrow(function () { | |
72 | object.__lookupSetter__(propertyKey); | |
73 | }, "Error: propertyKey.toString is called."); |