| 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 assertEquals(42, desc.value); | 84 assertEquals(42, desc.value); |
| 85 | 85 |
| 86 desc = Object.getOwnPropertyDescriptor(obj, 'z'); | 86 desc = Object.getOwnPropertyDescriptor(obj, 'z'); |
| 87 assertTrue(desc.writable); | 87 assertTrue(desc.writable); |
| 88 assertFalse(desc.configurable); | 88 assertFalse(desc.configurable); |
| 89 assertEquals("foobar", desc.value); | 89 assertEquals("foobar", desc.value); |
| 90 | 90 |
| 91 // Since writable is not affected by seal we should still be able to | 91 // Since writable is not affected by seal we should still be able to |
| 92 // update the values. | 92 // update the values. |
| 93 obj.x = "43"; | 93 obj.x = "43"; |
| 94 assertEquals(43, obj.x); | 94 assertEquals("43", obj.x); |
| 95 | 95 |
| 96 // Test on accessors. | 96 // Test on accessors. |
| 97 var obj2 = {}; | 97 var obj2 = {}; |
| 98 function get() { return 43; }; | 98 function get() { return 43; }; |
| 99 function set() {}; | 99 function set() {}; |
| 100 Object.defineProperty(obj2, 'x', { get: get, set: set, configurable: true }); | 100 Object.defineProperty(obj2, 'x', { get: get, set: set, configurable: true }); |
| 101 | 101 |
| 102 desc = Object.getOwnPropertyDescriptor(obj2, 'x'); | 102 desc = Object.getOwnPropertyDescriptor(obj2, 'x'); |
| 103 assertTrue(desc.configurable); | 103 assertTrue(desc.configurable); |
| 104 assertEquals(undefined, desc.value); | 104 assertEquals(undefined, desc.value); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 135 desc = Object.getOwnPropertyDescriptor(arr, '1'); | 135 desc = Object.getOwnPropertyDescriptor(arr, '1'); |
| 136 assertTrue(desc.configurable); | 136 assertTrue(desc.configurable); |
| 137 assertTrue(desc.writable); | 137 assertTrue(desc.writable); |
| 138 assertEquals(43, desc.value); | 138 assertEquals(43, desc.value); |
| 139 | 139 |
| 140 assertTrue(Object.isExtensible(arr)); | 140 assertTrue(Object.isExtensible(arr)); |
| 141 assertFalse(Object.isSealed(arr)); | 141 assertFalse(Object.isSealed(arr)); |
| 142 Object.seal(arr); | 142 Object.seal(arr); |
| 143 assertTrue(Object.isSealed(arr)); | 143 assertTrue(Object.isSealed(arr)); |
| 144 assertFalse(Object.isExtensible(arr)); | 144 assertFalse(Object.isExtensible(arr)); |
| 145 // Since the values in the array is still writable this object | 145 // Since the values in the array is still writable this object |
| 146 // is not frozen. | 146 // is not frozen. |
| 147 assertFalse(Object.isFrozen(arr)); | 147 assertFalse(Object.isFrozen(arr)); |
| 148 | 148 |
| 149 desc = Object.getOwnPropertyDescriptor(arr, '0'); | 149 desc = Object.getOwnPropertyDescriptor(arr, '0'); |
| 150 assertFalse(desc.configurable); | 150 assertFalse(desc.configurable); |
| 151 assertTrue(desc.writable); | 151 assertTrue(desc.writable); |
| 152 assertEquals(42, desc.value); | 152 assertEquals(42, desc.value); |
| 153 | 153 |
| 154 desc = Object.getOwnPropertyDescriptor(arr, '1'); | 154 desc = Object.getOwnPropertyDescriptor(arr, '1'); |
| 155 assertFalse(desc.configurable); | 155 assertFalse(desc.configurable); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 179 // Make sure that an object that has a configurable property | 179 // Make sure that an object that has a configurable property |
| 180 // is not classified as sealed. | 180 // is not classified as sealed. |
| 181 var obj4 = {}; | 181 var obj4 = {}; |
| 182 Object.defineProperty(obj4, 'x', {configurable: true, writable: false}); | 182 Object.defineProperty(obj4, 'x', {configurable: true, writable: false}); |
| 183 Object.defineProperty(obj4, 'y', {configurable: false, writable: false}); | 183 Object.defineProperty(obj4, 'y', {configurable: false, writable: false}); |
| 184 Object.preventExtensions(obj4); | 184 Object.preventExtensions(obj4); |
| 185 | 185 |
| 186 assertFalse(Object.isSealed(obj4)); | 186 assertFalse(Object.isSealed(obj4)); |
| 187 | 187 |
| 188 // Make sure that Object.seal returns the sealed object. | 188 // Make sure that Object.seal returns the sealed object. |
| 189 var obj4 = {} | 189 var obj4 = {}; |
| 190 assertTrue(obj4 === Object.seal(obj4)) | 190 assertTrue(obj4 === Object.seal(obj4)); |
| OLD | NEW |