| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Flags: --harmony-proxies --harmony-reflect | |
| 6 | |
| 7 // Test that traps that involve walking the target object's prototype chain | |
| 8 // don't overflow the stack when the original proxy is on that chain. | |
| 9 | |
| 10 (function TestGetPrototype() { | |
| 11 var p = new Proxy({}, {}); | |
| 12 p.__proto__ = p; | |
| 13 try { return p.__proto__; } catch(e) { assertInstanceof(e, RangeError); } | |
| 14 })(); | |
| 15 | |
| 16 (function TestSetPrototype() { | |
| 17 var p = new Proxy({}, {}); | |
| 18 p.__proto__ = p; | |
| 19 try { p.__proto__ = p; } catch(e) { assertInstanceof(e, RangeError); } | |
| 20 })(); | |
| 21 | |
| 22 (function TestHasProperty() { | |
| 23 var p = new Proxy({}, {}); | |
| 24 p.__proto__ = p; | |
| 25 try { | |
| 26 return Reflect.has(p, "foo"); | |
| 27 } catch(e) { assertInstanceof(e, RangeError); } | |
| 28 })(); | |
| 29 | |
| 30 (function TestSet() { | |
| 31 var p = new Proxy({}, {}); | |
| 32 p.__proto__ = p; | |
| 33 try { p.foo = 1; } catch(e) { assertInstanceof(e, RangeError); } | |
| 34 })(); | |
| 35 | |
| 36 (function TestGet() { | |
| 37 var p = new Proxy({}, {}); | |
| 38 p.__proto__ = p; | |
| 39 try { return p.foo; } catch(e) { assertInstanceof(e, RangeError); } | |
| 40 })(); | |
| 41 | |
| 42 (function TestEnumerate() { | |
| 43 var p = new Proxy({}, {}); | |
| 44 p.__proto__ = p; | |
| 45 try { for (var x in p) {} } catch(e) { assertInstanceof(e, RangeError); } | |
| 46 })(); | |
| 47 | |
| 48 // The following traps don't involve the target object's prototype chain; | |
| 49 // we test them anyway for completeness. | |
| 50 | |
| 51 (function TestIsExtensible() { | |
| 52 var p = new Proxy({}, {}); | |
| 53 p.__proto__ = p; | |
| 54 return Reflect.isExtensible(p); | |
| 55 })(); | |
| 56 | |
| 57 (function TestPreventExtensions() { | |
| 58 var p = new Proxy({}, {}); | |
| 59 p.__proto__ = p; | |
| 60 Reflect.preventExtensions(p); | |
| 61 })(); | |
| 62 | |
| 63 (function TestGetOwnPropertyDescriptor() { | |
| 64 var p = new Proxy({}, {}); | |
| 65 p.__proto__ = p; | |
| 66 return Object.getOwnPropertyDescriptor(p, "foo"); | |
| 67 })(); | |
| 68 | |
| 69 (function TestDeleteProperty() { | |
| 70 var p = new Proxy({}, {}); | |
| 71 p.__proto__ = p; | |
| 72 delete p.foo; | |
| 73 })(); | |
| 74 | |
| 75 (function TestDefineProperty() { | |
| 76 var p = new Proxy({}, {}); | |
| 77 p.__proto__ = p; | |
| 78 Object.defineProperty(p, "foo", {value: "bar"}); | |
| 79 })(); | |
| 80 | |
| 81 (function TestOwnKeys() { | |
| 82 var p = new Proxy({}, {}); | |
| 83 p.__proto__ = p; | |
| 84 return Reflect.ownKeys(p); | |
| 85 })(); | |
| 86 | |
| 87 (function TestCall() { | |
| 88 var p = new Proxy(function() {}, {}); | |
| 89 p.__proto__ = p; | |
| 90 return p(); | |
| 91 })(); | |
| 92 | |
| 93 (function TestConstruct() { | |
| 94 var p = new Proxy(function() { this.foo = 1; }, {}); | |
| 95 p.__proto__ = p; | |
| 96 return new p(); | |
| 97 })(); | |
| OLD | NEW |