OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 var publicSymbol = Symbol() | 335 var publicSymbol = Symbol() |
336 var publicSymbol2 = Symbol() | 336 var publicSymbol2 = Symbol() |
337 var obj = {} | 337 var obj = {} |
338 obj[publicSymbol] = 1 | 338 obj[publicSymbol] = 1 |
339 obj[privateSymbol] = 2 | 339 obj[privateSymbol] = 2 |
340 obj[publicSymbol2] = 3 | 340 obj[publicSymbol2] = 3 |
341 var syms = Object.getOwnPropertySymbols(obj) | 341 var syms = Object.getOwnPropertySymbols(obj) |
342 assertEquals(syms, [publicSymbol, publicSymbol2]) | 342 assertEquals(syms, [publicSymbol, publicSymbol2]) |
343 } | 343 } |
344 TestGetOwnPropertySymbols() | 344 TestGetOwnPropertySymbols() |
| 345 |
| 346 |
| 347 function TestSealAndFreeze(freeze) { |
| 348 var sym = %CreatePrivateSymbol("private") |
| 349 var obj = {} |
| 350 obj[sym] = 1 |
| 351 freeze(obj) |
| 352 obj[sym] = 2 |
| 353 assertEquals(2, obj[sym]) |
| 354 assertTrue(delete obj[sym]) |
| 355 assertEquals(undefined, obj[sym]) |
| 356 } |
| 357 TestSealAndFreeze(Object.seal) |
| 358 TestSealAndFreeze(Object.freeze) |
| 359 TestSealAndFreeze(Object.preventExtensions) |
OLD | NEW |