OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 set 5E0(_) {}, | 253 set 5E0(_) {}, |
254 set 6e-0(_) {}, | 254 set 6e-0(_) {}, |
255 set 7E-0(_) {}, | 255 set 7E-0(_) {}, |
256 set 0x8(_) {}, | 256 set 0x8(_) {}, |
257 set 0X9(_) {}, | 257 set 0X9(_) {}, |
258 }); | 258 }); |
259 TestNumericNamesSetter(['1.2', '1.3'], { | 259 TestNumericNamesSetter(['1.2', '1.3'], { |
260 set 1.2(_) {; }, | 260 set 1.2(_) {; }, |
261 set 1.30(_) {; } | 261 set 1.30(_) {; } |
262 }); | 262 }); |
| 263 |
| 264 |
| 265 (function TestPrototypeInObjectLiteral() { |
| 266 // The prototype chain should not be used if the definition |
| 267 // happens in the object literal. |
| 268 |
| 269 Object.defineProperty(Object.prototype, 'c', { |
| 270 get: function () { |
| 271 return 21; |
| 272 }, |
| 273 set: function () { |
| 274 } |
| 275 }); |
| 276 |
| 277 var o = {}; |
| 278 o.c = 7; |
| 279 assertEquals(21, o.c); |
| 280 |
| 281 var l = {c: 7}; |
| 282 assertEquals(7, l.c); |
| 283 |
| 284 delete Object.prototype.c; |
| 285 })(); |
| 286 |
| 287 (function TestProxyWithDefinitionInObjectLiteral() { |
| 288 // Trap for set should not be used if the definition |
| 289 // happens in the object literal. |
| 290 var handler = { |
| 291 set: function(target, name, value) { |
| 292 } |
| 293 }; |
| 294 |
| 295 const prop = 'a'; |
| 296 |
| 297 var p = new Proxy({}, handler); |
| 298 p[prop] = 'my value'; |
| 299 assertEquals(undefined, p[prop]); |
| 300 |
| 301 |
| 302 var l = new Proxy({[prop]: 'my value'}, handler); |
| 303 assertEquals('my value', l[prop]); |
| 304 })(); |
OLD | NEW |