Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: test/mjsunit/regress/regress-353004.js

Issue 1929123002: Add checks for detached ArrayBuffers to ArrayBuffer.prototype.slice (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix tests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
OLDNEW
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/IfConditions.golden ('k') | test/mjsunit/regress/regress-4964.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698