OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 }, | 147 }, |
148 getOwnPropertyDescriptor: function(target, name) { | 148 getOwnPropertyDescriptor: function(target, name) { |
149 return { enumerable: true }; | 149 return { enumerable: true }; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 var proxy6 = Proxy.create(handler6); | 153 var proxy6 = Proxy.create(handler6); |
154 testStringify('[1,null,true]', [1, proxy6, true]); | 154 testStringify('[1,null,true]', [1, proxy6, true]); |
155 testStringify('{"a":1,"c":true}', {a: 1, b: proxy6, c: true}); | 155 testStringify('{"a":1,"c":true}', {a: 1, b: proxy6, c: true}); |
156 | 156 |
| 157 // Object containing a proxy that changes the parent's properties. |
| 158 var handler7 = { |
| 159 get: function(target, name) { |
| 160 delete parent7.a; |
| 161 delete parent7.c; |
| 162 parent7.e = "5"; |
| 163 return name.toUpperCase(); |
| 164 }, |
| 165 enumerate: function(target) { |
| 166 return ['a', 'b', 'c']; |
| 167 }, |
| 168 getOwnPropertyDescriptor: function(target, name) { |
| 169 return { enumerable: true }; |
| 170 } |
| 171 } |
| 172 |
| 173 var proxy7 = Proxy.create(handler7); |
| 174 var parent7 = { a: "1", b: proxy7, c: "3", d: "4" }; |
| 175 assertEquals('{"a":"1","b":{"a":"A","b":"B","c":"C"},"d":"4"}', |
| 176 JSON.stringify(parent7)); |
| 177 assertEquals('{"b":{"a":"A","b":"B","c":"C"},"d":"4","e":"5"}', |
| 178 JSON.stringify(parent7)); |
OLD | NEW |