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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 assertEquals([], keys(o)); | 144 assertEquals([], keys(o)); |
145 })(); | 145 })(); |
146 | 146 |
147 (function testKeysProxyOnProto() { | 147 (function testKeysProxyOnProto() { |
148 var handler = {ownKeys() { return ["0"]; }}; | 148 var handler = {ownKeys() { return ["0"]; }}; |
149 var proxy = new Proxy({}, handler); | 149 var proxy = new Proxy({}, handler); |
150 var object = [0]; | 150 var object = [0]; |
151 object.__proto__ = proxy; | 151 object.__proto__ = proxy; |
152 assertEquals(["0"], keys(object)); | 152 assertEquals(["0"], keys(object)); |
153 | 153 |
154 // The Proxy doesn't set his ownKeys enumerable. | 154 // The Proxy doesn't set its ownKeys enumerable. |
155 delete object[0]; | 155 delete object[0]; |
156 assertEquals([], keys(object)); | 156 assertEquals([], keys(object)); |
157 | 157 |
158 // The [[Has]] trap has no influence on which are enumerable properties are | 158 // The [[Has]] trap has no influence on which are enumerable properties are |
159 // shown in for-in. | 159 // shown in for-in. |
160 handler.has = function() { return true }; | 160 handler.has = function() { return true }; |
161 assertEquals([], keys(object)); | 161 assertEquals([], keys(object)); |
162 | 162 |
163 handler.getOwnPropertyDescriptor = function() { | 163 handler.getOwnPropertyDescriptor = function() { |
164 return {enumerable: true, configurable: true} | 164 return {enumerable: true, configurable: true} |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 ownKeys() { | 214 ownKeys() { |
215 return ['c']; | 215 return ['c']; |
216 }, | 216 }, |
217 getOwnPropertyDescriptor() { return {configurable: true, enumerable: true }
} | 217 getOwnPropertyDescriptor() { return {configurable: true, enumerable: true }
} |
218 } | 218 } |
219 var proxy = new Proxy({}, handler); | 219 var proxy = new Proxy({}, handler); |
220 var proxy2 = new Proxy(proxy, {}); | 220 var proxy2 = new Proxy(proxy, {}); |
221 assertEquals(['c'], keys(proxy)); | 221 assertEquals(['c'], keys(proxy)); |
222 assertEquals(['c'], keys(proxy2)); | 222 assertEquals(['c'], keys(proxy2)); |
223 })(); | 223 })(); |
OLD | NEW |