| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 desc = Object.getOwnPropertyDescriptor(obj, 'z'); | 85 desc = Object.getOwnPropertyDescriptor(obj, 'z'); |
| 86 assertFalse(desc.writable); | 86 assertFalse(desc.writable); |
| 87 assertFalse(desc.configurable); | 87 assertFalse(desc.configurable); |
| 88 assertEquals("foobar", desc.value); | 88 assertEquals("foobar", desc.value); |
| 89 | 89 |
| 90 // Make sure that even if we try overwrite a value that is not writable, it is | 90 // Make sure that even if we try overwrite a value that is not writable, it is |
| 91 // not changed. | 91 // not changed. |
| 92 obj.x = "tete"; | 92 obj.x = "tete"; |
| 93 assertEquals(42, obj.x); | 93 assertEquals(42, obj.x); |
| 94 obj.x = { get: function() {return 43}, set: function() {} }; | 94 obj.x = { get: function() {return 43;}, set: function() {} }; |
| 95 assertEquals(42, obj.x); | 95 assertEquals(42, obj.x); |
| 96 | 96 |
| 97 // Test on accessors. | 97 // Test on accessors. |
| 98 var obj2 = {}; | 98 var obj2 = {}; |
| 99 function get() { return 43; }; | 99 function get() { return 43; } |
| 100 function set() {}; | 100 function set() {} |
| 101 Object.defineProperty(obj2, 'x', { get: get, set: set, configurable: true }); | 101 Object.defineProperty(obj2, 'x', { get: get, set: set, configurable: true }); |
| 102 | 102 |
| 103 desc = Object.getOwnPropertyDescriptor(obj2, 'x'); | 103 desc = Object.getOwnPropertyDescriptor(obj2, 'x'); |
| 104 assertTrue(desc.configurable); | 104 assertTrue(desc.configurable); |
| 105 assertEquals(undefined, desc.value); | 105 assertEquals(undefined, desc.value); |
| 106 assertEquals(set, desc.set); | 106 assertEquals(set, desc.set); |
| 107 assertEquals(get, desc.get); | 107 assertEquals(get, desc.get); |
| 108 | 108 |
| 109 assertTrue(Object.isExtensible(obj2)); | 109 assertTrue(Object.isExtensible(obj2)); |
| 110 assertFalse(Object.isFrozen(obj2)); | 110 assertFalse(Object.isFrozen(obj2)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // Make sure that an object that has only non-writable, but one | 182 // Make sure that an object that has only non-writable, but one |
| 183 // configurable property, is not classified as frozen. | 183 // configurable property, is not classified as frozen. |
| 184 var obj5 = {}; | 184 var obj5 = {}; |
| 185 Object.defineProperty(obj5, 'x', {configurable: true, writable: false}); | 185 Object.defineProperty(obj5, 'x', {configurable: true, writable: false}); |
| 186 Object.defineProperty(obj5, 'y', {configurable: false, writable: false}); | 186 Object.defineProperty(obj5, 'y', {configurable: false, writable: false}); |
| 187 Object.preventExtensions(obj5); | 187 Object.preventExtensions(obj5); |
| 188 | 188 |
| 189 assertFalse(Object.isFrozen(obj5)); | 189 assertFalse(Object.isFrozen(obj5)); |
| 190 | 190 |
| 191 // Make sure that Object.freeze returns the frozen object. | 191 // Make sure that Object.freeze returns the frozen object. |
| 192 var obj6 = {} | 192 var obj6 = {}; |
| 193 assertTrue(obj6 === Object.freeze(obj6)) | 193 assertTrue(obj6 === Object.freeze(obj6)); |
| OLD | NEW |