Chromium Code Reviews| Index: test/mjsunit/regress/regress-353004.js |
| diff --git a/test/mjsunit/regress/regress-353004.js b/test/mjsunit/regress/regress-353004.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0bf526f198af110e04374cc72f48e223b2081707 |
| --- /dev/null |
| +++ b/test/mjsunit/regress/regress-353004.js |
| @@ -0,0 +1,104 @@ |
| +// Copyright 2014 the V8 project authors. All rights reserved. |
| +// 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.
|
| +// modification, are permitted provided that the following conditions are |
| +// met: |
| +// |
| +// * Redistributions of source code must retain the above copyright |
| +// notice, this list of conditions and the following disclaimer. |
| +// * Redistributions in binary form must reproduce the above |
| +// copyright notice, this list of conditions and the following |
| +// disclaimer in the documentation and/or other materials provided |
| +// with the distribution. |
| +// * Neither the name of Google Inc. nor the names of its |
| +// contributors may be used to endorse or promote products derived |
| +// from this software without specific prior written permission. |
| +// |
| +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| +// A PARTICULAR PURPOSE ARE DISCLAIM:ED. IN NO EVENT SHALL THE COPYRIGHT |
| +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| + |
| +// Flags: --allow-natives-syntax |
| + |
| +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.
|
| + |
| +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.
|
| + %ArrayBufferNeuter(buffer1); |
| + return 0; |
| +}}); |
| + |
| +assertEquals(0, array1.length); |
| +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.
|
| + array1[i] = 0xCC; |
| +} |
| + |
| +buffer2 = new ArrayBuffer(100 * 1024 * 1024); |
| + |
| +assertThrows(function() { |
| + array2 = new Uint8Array(buffer2, 0, {valueOf : function() { |
| + %ArrayBufferNeuter(buffer2); |
| + return 100 * 1024 * 1024; |
| + }}); |
| +}, RangeError); |
| + |
| + |
| +buffer3 = new ArrayBuffer(100 * 1024 * 1024); |
| +dataView1 = new DataView(buffer3, {valueOf : function() { |
| + %ArrayBufferNeuter(buffer3); |
| + return 0; |
| +}}); |
| + |
| +assertEquals(0, dataView1.byteLength); |
| +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.
|
| + dataView1.setUint8(i,0xCC); |
| +} |
| + |
| + |
| +buffer4 = new ArrayBuffer(100 * 1024 * 1024); |
| +assertThrows(function() { |
| + dataView2 = new DataView(buffer4, 0, {valueOf : function() { |
| + %ArrayBufferNeuter(buffer4); |
| + return 100 * 1024 * 1024; |
| + }}); |
| +}, RangeError); |
| + |
| + |
| +buffer5 = new ArrayBuffer(100 * 1024 * 1024); |
| +buffer6 = buffer5.slice({valueOf : function() { |
| + %ArrayBufferNeuter(buffer5); |
| + return 0; |
| +}}, 100 * 1024 * 1024); |
| +assertEquals(0, buffer6.byteLength); |
| + |
| + |
| +buffer7 = new ArrayBuffer(100 * 1024 * 1024); |
| +buffer8 = buffer7.slice(0, {valueOf : function() { |
| + %ArrayBufferNeuter(buffer7); |
| + return 100 * 1024 * 1024; |
| +}}); |
| +assertEquals(0, buffer8.byteLength); |
| + |
| +buffer9 = new ArrayBuffer(1024); |
| +array9 = new Uint8Array(buffer9); |
| +array10 = array9.subarray({valueOf : function() { |
| + %ArrayBufferNeuter(buffer9); |
|
Jakob Kummerow
2014/03/17 17:29:05
nit: funky indentation
Dmitry Lomov (no reviews)
2014/03/18 10:22:32
Done.
|
| + return 0; |
| + }}, 1024); |
| +assertEquals(0, array9.length); |
| +assertEquals(0, array10.length); |
| + |
| +buffer11 = new ArrayBuffer(1024); |
| +array11 = new Uint8Array(buffer11); |
| +array12 = array11.subarray(0, {valueOf : function() { |
| + %ArrayBufferNeuter(buffer11); |
| + return 1024; |
| + }}); |
| +assertEquals(0, array11.length); |
| +assertEquals(0, array12.length); |