OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --allow-natives-syntax | 5 // Flags: --allow-natives-syntax |
6 | 6 |
7 var buffer1 = new ArrayBuffer(100 * 1024); | 7 var buffer1 = new ArrayBuffer(100 * 1024); |
8 | 8 |
9 var array1 = new Uint8Array(buffer1, {valueOf : function() { | 9 var array1 = new Uint8Array(buffer1, {valueOf : function() { |
10 %ArrayBufferNeuter(buffer1); | 10 %ArrayBufferNeuter(buffer1); |
(...skipping 23 matching lines...) Expand all Loading... |
34 var buffer4 = new ArrayBuffer(100 * 1024); | 34 var buffer4 = new ArrayBuffer(100 * 1024); |
35 assertThrows(function() { | 35 assertThrows(function() { |
36 var dataView2 = new DataView(buffer4, 0, {valueOf : function() { | 36 var dataView2 = new DataView(buffer4, 0, {valueOf : function() { |
37 %ArrayBufferNeuter(buffer4); | 37 %ArrayBufferNeuter(buffer4); |
38 return 100 * 1024 * 1024; | 38 return 100 * 1024 * 1024; |
39 }}); | 39 }}); |
40 }, RangeError); | 40 }, RangeError); |
41 | 41 |
42 | 42 |
43 var buffer5 = new ArrayBuffer(100 * 1024); | 43 var buffer5 = new ArrayBuffer(100 * 1024); |
44 var buffer6 = buffer5.slice({valueOf : function() { | 44 assertThrows(function() { |
45 %ArrayBufferNeuter(buffer5); | 45 buffer5.slice({valueOf : function() { |
46 return 0; | 46 %ArrayBufferNeuter(buffer5); |
47 }}, 100 * 1024 * 1024); | 47 return 0; |
48 assertEquals(0, buffer6.byteLength); | 48 }}, 100 * 1024 * 1024); |
| 49 }, TypeError); |
49 | 50 |
50 | 51 |
51 var buffer7 = new ArrayBuffer(100 * 1024 * 1024); | 52 var buffer7 = new ArrayBuffer(100 * 1024 * 1024); |
52 var buffer8 = buffer7.slice(0, {valueOf : function() { | 53 assertThrows(function() { |
53 %ArrayBufferNeuter(buffer7); | 54 buffer7.slice(0, {valueOf : function() { |
54 return 100 * 1024 * 1024; | 55 %ArrayBufferNeuter(buffer7); |
55 }}); | 56 return 100 * 1024 * 1024; |
56 assertEquals(0, buffer8.byteLength); | 57 }}); |
| 58 }, TypeError); |
57 | 59 |
58 var buffer9 = new ArrayBuffer(1024); | 60 var buffer9 = new ArrayBuffer(1024); |
59 var array9 = new Uint8Array(buffer9); | 61 var array9 = new Uint8Array(buffer9); |
60 var array10 = array9.subarray({valueOf : function() { | 62 var array10 = array9.subarray({valueOf : function() { |
61 %ArrayBufferNeuter(buffer9); | 63 %ArrayBufferNeuter(buffer9); |
62 return 0; | 64 return 0; |
63 }}, 1024); | 65 }}, 1024); |
64 assertEquals(0, array9.length); | 66 assertEquals(0, array9.length); |
65 assertEquals(0, array10.length); | 67 assertEquals(0, array10.length); |
66 | 68 |
67 var buffer11 = new ArrayBuffer(1024); | 69 var buffer11 = new ArrayBuffer(1024); |
68 var array11 = new Uint8Array(buffer11); | 70 var array11 = new Uint8Array(buffer11); |
69 var array12 = array11.subarray(0, {valueOf : function() { | 71 var array12 = array11.subarray(0, {valueOf : function() { |
70 %ArrayBufferNeuter(buffer11); | 72 %ArrayBufferNeuter(buffer11); |
71 return 1024; | 73 return 1024; |
72 }}); | 74 }}); |
73 assertEquals(0, array11.length); | 75 assertEquals(0, array11.length); |
74 assertEquals(0, array12.length); | 76 assertEquals(0, array12.length); |
OLD | NEW |