OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 13 matching lines...) Expand all Loading... |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --harmony-proxies | 28 // Flags: --harmony-proxies |
29 | 29 |
30 | 30 |
31 // Helper. | 31 // Helper. |
32 | 32 |
33 function TestWithProxies(test, x, y, z) { | 33 function TestWithProxies(test, x, y, z) { |
34 test(Proxy.create, x, y, z) | 34 test(function(h) { return new Proxy({}, h) }, x, y, z) |
35 test(function(h) {return Proxy.createFunction(h, function() {})}, x, y, z) | 35 test(function(h) { |
| 36 return Proxy.createFunction(h, function() {}) |
| 37 }, x, y, z) |
36 } | 38 } |
37 | 39 |
38 | 40 |
39 | 41 |
40 // Getting. | 42 // Getting. |
41 | 43 |
42 function TestWithGet(handler) { | 44 function TestWithGet(handler) { |
43 TestWithProxies(TestWithGet2, handler) | 45 TestWithProxies(TestWithGet2, handler) |
44 } | 46 } |
45 | 47 |
(...skipping 13 matching lines...) Expand all Loading... |
59 var o = Object.create(p, {d: {value: "own"}}) | 61 var o = Object.create(p, {d: {value: "own"}}) |
60 with (o) { | 62 with (o) { |
61 assertEquals("onproxy", a) | 63 assertEquals("onproxy", a) |
62 assertEquals("local", b) | 64 assertEquals("local", b) |
63 assertEquals("global", c) | 65 assertEquals("global", c) |
64 assertEquals("own", d) | 66 assertEquals("own", d) |
65 } | 67 } |
66 } | 68 } |
67 | 69 |
68 TestWithGet({ | 70 TestWithGet({ |
69 get: function(r, k) { key = k; return k === "a" ? "onproxy" : undefined }, | 71 get: function(r, k) { |
| 72 key = k; |
| 73 return k === "a" ? "onproxy" : undefined |
| 74 }, |
70 getPropertyDescriptor: function(k) { | 75 getPropertyDescriptor: function(k) { |
71 key = k; | 76 key = k; |
72 return k === "a" ? {value: "onproxy", configurable: true} : undefined | 77 return k === "a" ? {value: "onproxy", configurable: true} : undefined |
73 } | 78 } |
74 }) | 79 }) |
75 | 80 |
76 TestWithGet({ | 81 TestWithGet({ |
77 get: function(r, k) { return this.get2(r, k) }, | 82 get: function(r, k) { return this.get2(r, k) }, |
78 get2: function(r, k) { key = k; return k === "a" ? "onproxy" : undefined }, | 83 get2: function(r, k) { key = k; return k === "a" ? "onproxy" : undefined }, |
79 getPropertyDescriptor: function(k) { | 84 getPropertyDescriptor: function(k) { |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 }, | 442 }, |
438 defineProperty: function(k, desc) { throw "myexn" } | 443 defineProperty: function(k, desc) { throw "myexn" } |
439 }) | 444 }) |
440 | 445 |
441 TestWithSetThrow({ | 446 TestWithSetThrow({ |
442 getPropertyDescriptor: function(k) { | 447 getPropertyDescriptor: function(k) { |
443 return k === "a" ? | 448 return k === "a" ? |
444 {set: function() { throw "myexn" }, configurable: true} : undefined | 449 {set: function() { throw "myexn" }, configurable: true} : undefined |
445 } | 450 } |
446 }, true) | 451 }, true) |
OLD | NEW |