| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 var a = []; | |
| 29 a[0xfffffffe] = 10; | |
| 30 assertThrows("a.unshift(1);", RangeError); | |
| 31 assertEquals(0xffffffff, a.length); | |
| 32 assertEquals(10, a[0xffffffff]); | |
| 33 assertEquals(undefined, a[0xfffffffe]); | |
| 34 | |
| 35 a = [1,2,3]; | |
| 36 a[0xfffffffe] = 10; | |
| 37 assertThrows("a.splice(1,1,7,7,7,7,7);", RangeError); | |
| 38 assertEquals([1,7,7,7,7,7,3], a.slice(0, 7)); | |
| 39 assertEquals(0xffffffff, a.length); | |
| 40 assertEquals(10, a[0xfffffffe + 5 - 1]); | |
| 41 | |
| 42 a = [1]; | 28 a = [1]; |
| 43 Object.defineProperty(a, "1", {writable:false, configurable:false, value: 100}); | 29 Object.defineProperty(a, "1", {writable:false, configurable:false, value: 100}); |
| 44 assertThrows("a.unshift(4);", TypeError); | 30 assertThrows("a.unshift(4);", TypeError); |
| 45 assertEquals([1, 100, 100], a); | 31 assertEquals([1, 100, 100], a); |
| 46 var desc = Object.getOwnPropertyDescriptor(a, "1"); | 32 var desc = Object.getOwnPropertyDescriptor(a, "1"); |
| 47 assertEquals(false, desc.writable); | 33 assertEquals(false, desc.writable); |
| 48 assertEquals(false, desc.configurable); | 34 assertEquals(false, desc.configurable); |
| 49 | 35 |
| 50 a = [1]; | 36 a = [1]; |
| 51 var g = function() { return 100; }; | 37 var g = function() { return 100; }; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 70 a = [1]; | 56 a = [1]; |
| 71 Object.defineProperty(a, "1", {configurable:false, value:10}); | 57 Object.defineProperty(a, "1", {configurable:false, value:10}); |
| 72 assertThrows("a.splice(1,1);", TypeError); | 58 assertThrows("a.splice(1,1);", TypeError); |
| 73 assertEquals([1, 10], a); | 59 assertEquals([1, 10], a); |
| 74 desc = Object.getOwnPropertyDescriptor(a, "1"); | 60 desc = Object.getOwnPropertyDescriptor(a, "1"); |
| 75 assertEquals(false, desc.configurable); | 61 assertEquals(false, desc.configurable); |
| 76 | 62 |
| 77 a = [0,1,2,3,4,5,6]; | 63 a = [0,1,2,3,4,5,6]; |
| 78 Object.defineProperty(a, "3", {configurable:false, writable:false, value:3}); | 64 Object.defineProperty(a, "3", {configurable:false, writable:false, value:3}); |
| 79 assertThrows("a.splice(1,4);", TypeError); | 65 assertThrows("a.splice(1,4);", TypeError); |
| 80 assertEquals([0,5,6,3,,,,,], a); | 66 assertEquals([0,5,6,3,,,,], a); |
| 81 desc = Object.getOwnPropertyDescriptor(a, "3"); | 67 desc = Object.getOwnPropertyDescriptor(a, "3"); |
| 82 assertEquals(false, desc.configurable); | 68 assertEquals(false, desc.configurable); |
| 83 assertEquals(false, desc.writable); | 69 assertEquals(false, desc.writable); |
| 84 | 70 |
| 85 a = [0,1,2,3,4,5,6]; | 71 a = [0,1,2,3,4,5,6]; |
| 86 Object.defineProperty(a, "5", {configurable:false, value:5}); | 72 Object.defineProperty(a, "5", {configurable:false, value:5}); |
| 87 assertThrows("a.splice(1,4);", TypeError); | 73 assertThrows("a.splice(1,4);", TypeError); |
| 88 assertEquals([0,5,6,3,4,5,,,], a); | 74 assertEquals([0,5,6,3,4,5,,], a); |
| 89 desc = Object.getOwnPropertyDescriptor(a, "5"); | 75 desc = Object.getOwnPropertyDescriptor(a, "5"); |
| 90 assertEquals(false, desc.configurable); | 76 assertEquals(false, desc.configurable); |
| 91 | 77 |
| 92 a = [1,2,3,,5]; | 78 a = [1,2,3,,5]; |
| 93 Object.defineProperty(a, "1", {configurable:false, writable:true, value:2}); | 79 Object.defineProperty(a, "1", {configurable:false, writable:true, value:2}); |
| 94 assertEquals(1, a.shift()); | 80 assertEquals(1, a.shift()); |
| 95 assertEquals([2,3,,5], a); | 81 assertEquals([2,3,,5], a); |
| 96 desc = Object.getOwnPropertyDescriptor(a, "1"); | 82 desc = Object.getOwnPropertyDescriptor(a, "1"); |
| 97 assertEquals(false, desc.configurable); | 83 assertEquals(false, desc.configurable); |
| 98 assertEquals(true, desc.writable); | 84 assertEquals(true, desc.writable); |
| 99 assertThrows("a.shift();", TypeError); | 85 assertThrows("a.shift();", TypeError); |
| 100 assertEquals([3,3,,5], a); | 86 assertEquals([3,3,,5], a); |
| 101 desc = Object.getOwnPropertyDescriptor(a, "1"); | 87 desc = Object.getOwnPropertyDescriptor(a, "1"); |
| 102 assertEquals(false, desc.configurable); | 88 assertEquals(false, desc.configurable); |
| 103 assertEquals(true, desc.writable); | 89 assertEquals(true, desc.writable); |
| 104 | 90 |
| 105 a = [1,2,3]; | 91 a = [1,2,3]; |
| 106 Object.defineProperty(a, "2", {configurable:false, value:3}); | 92 Object.defineProperty(a, "2", {configurable:false, value:3}); |
| 107 assertThrows("a.pop();", TypeError); | 93 assertThrows("a.pop();", TypeError); |
| 108 assertEquals([1,2,3], a); | 94 assertEquals([1,2,3], a); |
| 109 desc = Object.getOwnPropertyDescriptor(a, "2"); | 95 desc = Object.getOwnPropertyDescriptor(a, "2"); |
| 110 assertEquals(false, desc.configurable); | 96 assertEquals(false, desc.configurable); |
| 111 | |
| 112 a = [1,2,,,5]; | |
| 113 Object.defineProperty(a, "4", {writable:true, configurable:false, value:5}); | |
| 114 assertThrows("a.sort();", TypeError); | |
| 115 assertEquals([1,2,5,,5], a); | |
| 116 desc = Object.getOwnPropertyDescriptor(a, "2"); | |
| 117 assertEquals(true, desc.configurable); | |
| 118 desc = Object.getOwnPropertyDescriptor(a, "4"); | |
| 119 assertEquals(false, desc.configurable); | |
| 120 | |
| 121 a = [1,2,3,,5,6]; | |
| 122 Object.defineProperty(a, "4", {value:5, writable:false}); | |
| 123 assertThrows("a.sort();", TypeError); | |
| 124 assertEquals([1,2,3,5,5,6], a); | |
| 125 desc = Object.getOwnPropertyDescriptor(a, "4"); | |
| 126 assertEquals(false, desc.writable); | |
| OLD | NEW |