Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | |
| 2 // Redistribution and use in source and binary forms, with or without | |
|
Jakob Kummerow
2014/03/17 17:29:05
nit: you can use the new, short licence header.
Dmitry Lomov (no reviews)
2014/03/18 10:22:32
Done.
| |
| 3 // modification, are permitted provided that the following conditions are | |
| 4 // met: | |
| 5 // | |
| 6 // * Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // * Redistributions in binary form must reproduce the above | |
| 9 // copyright notice, this list of conditions and the following | |
| 10 // disclaimer in the documentation and/or other materials provided | |
| 11 // with the distribution. | |
| 12 // * Neither the name of Google Inc. nor the names of its | |
| 13 // contributors may be used to endorse or promote products derived | |
| 14 // from this software without specific prior written permission. | |
| 15 // | |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIM:ED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 27 | |
| 28 // Flags: --allow-natives-syntax | |
| 29 | |
| 30 buffer1 = new ArrayBuffer(100 * 1024 * 1024); | |
|
Jakob Kummerow
2014/03/17 17:29:05
Wouldn't 100K be enough for each bufferX? I fear t
Dmitry Lomov (no reviews)
2014/03/18 10:22:32
Done.
| |
| 31 | |
| 32 array1 = new Uint8Array(buffer1, {valueOf : function() { | |
|
Jakob Kummerow
2014/03/17 17:29:05
nit: how about some "var" keywords, here and for e
Dmitry Lomov (no reviews)
2014/03/18 10:22:32
Done.
| |
| 33 %ArrayBufferNeuter(buffer1); | |
| 34 return 0; | |
| 35 }}); | |
| 36 | |
| 37 assertEquals(0, array1.length); | |
| 38 for (i = 0; i < array1.length; i++) { | |
|
Jakob Kummerow
2014/03/17 17:29:05
This loop is pointless; if the assertEquals right
Dmitry Lomov (no reviews)
2014/03/18 10:22:32
Done.
| |
| 39 array1[i] = 0xCC; | |
| 40 } | |
| 41 | |
| 42 buffer2 = new ArrayBuffer(100 * 1024 * 1024); | |
| 43 | |
| 44 assertThrows(function() { | |
| 45 array2 = new Uint8Array(buffer2, 0, {valueOf : function() { | |
| 46 %ArrayBufferNeuter(buffer2); | |
| 47 return 100 * 1024 * 1024; | |
| 48 }}); | |
| 49 }, RangeError); | |
| 50 | |
| 51 | |
| 52 buffer3 = new ArrayBuffer(100 * 1024 * 1024); | |
| 53 dataView1 = new DataView(buffer3, {valueOf : function() { | |
| 54 %ArrayBufferNeuter(buffer3); | |
| 55 return 0; | |
| 56 }}); | |
| 57 | |
| 58 assertEquals(0, dataView1.byteLength); | |
| 59 for (i = 0; i < dataView1.byteLength; i++) { | |
|
Jakob Kummerow
2014/03/17 17:29:05
another pointless loop
Dmitry Lomov (no reviews)
2014/03/18 10:22:32
Done.
| |
| 60 dataView1.setUint8(i,0xCC); | |
| 61 } | |
| 62 | |
| 63 | |
| 64 buffer4 = new ArrayBuffer(100 * 1024 * 1024); | |
| 65 assertThrows(function() { | |
| 66 dataView2 = new DataView(buffer4, 0, {valueOf : function() { | |
| 67 %ArrayBufferNeuter(buffer4); | |
| 68 return 100 * 1024 * 1024; | |
| 69 }}); | |
| 70 }, RangeError); | |
| 71 | |
| 72 | |
| 73 buffer5 = new ArrayBuffer(100 * 1024 * 1024); | |
| 74 buffer6 = buffer5.slice({valueOf : function() { | |
| 75 %ArrayBufferNeuter(buffer5); | |
| 76 return 0; | |
| 77 }}, 100 * 1024 * 1024); | |
| 78 assertEquals(0, buffer6.byteLength); | |
| 79 | |
| 80 | |
| 81 buffer7 = new ArrayBuffer(100 * 1024 * 1024); | |
| 82 buffer8 = buffer7.slice(0, {valueOf : function() { | |
| 83 %ArrayBufferNeuter(buffer7); | |
| 84 return 100 * 1024 * 1024; | |
| 85 }}); | |
| 86 assertEquals(0, buffer8.byteLength); | |
| 87 | |
| 88 buffer9 = new ArrayBuffer(1024); | |
| 89 array9 = new Uint8Array(buffer9); | |
| 90 array10 = array9.subarray({valueOf : function() { | |
| 91 %ArrayBufferNeuter(buffer9); | |
|
Jakob Kummerow
2014/03/17 17:29:05
nit: funky indentation
Dmitry Lomov (no reviews)
2014/03/18 10:22:32
Done.
| |
| 92 return 0; | |
| 93 }}, 1024); | |
| 94 assertEquals(0, array9.length); | |
| 95 assertEquals(0, array10.length); | |
| 96 | |
| 97 buffer11 = new ArrayBuffer(1024); | |
| 98 array11 = new Uint8Array(buffer11); | |
| 99 array12 = array11.subarray(0, {valueOf : function() { | |
| 100 %ArrayBufferNeuter(buffer11); | |
| 101 return 1024; | |
| 102 }}); | |
| 103 assertEquals(0, array11.length); | |
| 104 assertEquals(0, array12.length); | |
| OLD | NEW |