OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-object-literals --allow-natives-syntax | 5 // Flags: --harmony-object-literals --allow-natives-syntax |
6 | 6 |
7 | 7 |
8 (function TestBasics() { | 8 (function TestBasics() { |
9 var object = { | 9 var object = { |
10 method() { | 10 method() { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 }; | 97 }; |
98 var f = object.method; | 98 var f = object.method; |
99 assertFalse(f.hasOwnProperty('prototype')); | 99 assertFalse(f.hasOwnProperty('prototype')); |
100 assertEquals(undefined, f.prototype); | 100 assertEquals(undefined, f.prototype); |
101 | 101 |
102 f.prototype = 42; | 102 f.prototype = 42; |
103 assertEquals(42, f.prototype); | 103 assertEquals(42, f.prototype); |
104 })(); | 104 })(); |
105 | 105 |
106 | 106 |
| 107 (function TestNoRestrictedPropertiesStrict() { |
| 108 var obj = { |
| 109 method() { "use strict"; } |
| 110 }; |
| 111 assertFalse(obj.method.hasOwnProperty("arguments")); |
| 112 assertThrows(function() { return obj.method.arguments; }, TypeError); |
| 113 assertThrows(function() { obj.method.arguments = {}; }, TypeError); |
| 114 |
| 115 assertFalse(obj.method.hasOwnProperty("caller")); |
| 116 assertThrows(function() { return obj.method.caller; }, TypeError); |
| 117 assertThrows(function() { obj.method.caller = {}; }, TypeError); |
| 118 })(); |
| 119 |
| 120 |
| 121 (function TestNoRestrictedPropertiesSloppy() { |
| 122 var obj = { |
| 123 method() {} |
| 124 }; |
| 125 assertFalse(obj.method.hasOwnProperty("arguments")); |
| 126 assertThrows(function() { return obj.method.arguments; }, TypeError); |
| 127 assertThrows(function() { obj.method.arguments = {}; }, TypeError); |
| 128 |
| 129 assertFalse(obj.method.hasOwnProperty("caller")); |
| 130 assertThrows(function() { return obj.method.caller; }, TypeError); |
| 131 assertThrows(function() { obj.method.caller = {}; }, TypeError); |
| 132 })(); |
| 133 |
| 134 |
107 (function TestToString() { | 135 (function TestToString() { |
108 var object = { | 136 var object = { |
109 method() { 42; } | 137 method() { 42; } |
110 }; | 138 }; |
111 assertEquals('method() { 42; }', object.method.toString()); | 139 assertEquals('method() { 42; }', object.method.toString()); |
112 })(); | 140 })(); |
113 | 141 |
114 | 142 |
115 (function TestOptimized() { | 143 (function TestOptimized() { |
116 var object = { | 144 var object = { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 var p = {}; | 291 var p = {}; |
264 var object = { | 292 var object = { |
265 __proto__() { | 293 __proto__() { |
266 return 1; | 294 return 1; |
267 }, | 295 }, |
268 __proto__: p | 296 __proto__: p |
269 }; | 297 }; |
270 assertEquals(p, Object.getPrototypeOf(object)); | 298 assertEquals(p, Object.getPrototypeOf(object)); |
271 assertEquals(1, object.__proto__()); | 299 assertEquals(1, object.__proto__()); |
272 })(); | 300 })(); |
OLD | NEW |