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

Side by Side Diff: src/js/arraybuffer.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
« no previous file with comments | « no previous file | src/messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if (fin < first) { 63 if (fin < first) {
64 fin = first; 64 fin = first;
65 } 65 }
66 var newLen = fin - first; 66 var newLen = fin - first;
67 var constructor = SpeciesConstructor(this, GlobalArrayBuffer, true); 67 var constructor = SpeciesConstructor(this, GlobalArrayBuffer, true);
68 var result = new constructor(newLen); 68 var result = new constructor(newLen);
69 if (!IS_ARRAYBUFFER(result)) { 69 if (!IS_ARRAYBUFFER(result)) {
70 throw MakeTypeError(kIncompatibleMethodReceiver, 70 throw MakeTypeError(kIncompatibleMethodReceiver,
71 'ArrayBuffer.prototype.slice', result); 71 'ArrayBuffer.prototype.slice', result);
72 } 72 }
73 // TODO(littledan): Check for a detached ArrayBuffer 73 // Checks for detached source/target ArrayBuffers are done inside of
74 // %ArrayBufferSliceImpl; the reordering of checks does not violate
75 // the spec because all exceptions thrown are TypeErrors.
74 if (result === this) { 76 if (result === this) {
75 throw MakeTypeError(kArrayBufferSpeciesThis); 77 throw MakeTypeError(kArrayBufferSpeciesThis);
76 } 78 }
77 if (%_ArrayBufferGetByteLength(result) < newLen) { 79 if (%_ArrayBufferGetByteLength(result) < newLen) {
78 throw MakeTypeError(kArrayBufferTooShort); 80 throw MakeTypeError(kArrayBufferTooShort);
79 } 81 }
80 82
81 %ArrayBufferSliceImpl(this, result, first, newLen); 83 %ArrayBufferSliceImpl(this, result, first, newLen);
82 return result; 84 return result;
83 } 85 }
84 86
85 utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength", 87 utils.InstallGetter(GlobalArrayBuffer.prototype, "byteLength",
86 ArrayBufferGetByteLen); 88 ArrayBufferGetByteLen);
87 89
88 utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [ 90 utils.InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
89 "slice", ArrayBufferSlice 91 "slice", ArrayBufferSlice
90 ]); 92 ]);
91 93
92 }) 94 })
OLDNEW
« no previous file with comments | « no previous file | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698