Chromium Code Reviews| Index: src/js/arraybuffer.js |
| diff --git a/src/js/arraybuffer.js b/src/js/arraybuffer.js |
| index 1ee68ca291b0ccc6c6affc79af5c7bcc6b90c493..ddd3c2f3675fc75aa9cb9cb97a3fd3c4b6e3c043 100644 |
| --- a/src/js/arraybuffer.js |
| +++ b/src/js/arraybuffer.js |
| @@ -15,11 +15,13 @@ var GlobalArrayBuffer = global.ArrayBuffer; |
| var MakeTypeError; |
| var MaxSimple; |
| var MinSimple; |
| +var SpeciesConstructor; |
| utils.Import(function(from) { |
| MakeTypeError = from.MakeTypeError; |
| MaxSimple = from.MaxSimple; |
| MinSimple = from.MinSimple; |
| + SpeciesConstructor = from.SpeciesConstructor; |
| }); |
| // ------------------------------------------------------------------- |
| @@ -62,10 +64,20 @@ function ArrayBufferSlice(start, end) { |
| fin = first; |
| } |
| var newLen = fin - first; |
| - // TODO(dslomov): implement inheritance |
| - var result = new GlobalArrayBuffer(newLen); |
| + var constructor = SpeciesConstructor(this, GlobalArrayBuffer, true); |
| + var result = new constructor(newLen); |
| + if (!IS_ARRAYBUFFER(result)) { |
|
adamk
2016/01/12 00:11:00
Is this exercised in some test?
Dan Ehrenberg
2016/01/12 01:38:33
Test262, but that's not active yet so I wrote anot
|
| + throw MakeTypeError(kIncompatibleMethodReceiver, |
| + 'ArrayBuffer.prototype.slice', result); |
| + } |
| + if (%_ArrayBufferGetByteLength(result) < newLen) { |
|
adamk
2016/01/12 00:11:00
And this? Same question about most of these error
Dan Ehrenberg
2016/01/12 01:38:33
Oops, I forgot to add the file test/mjsunit/harmon
|
| + throw MakeTypeError(kArrayBufferTooShort); |
| + } |
| + if (result === this) { |
|
adamk
2016/01/12 00:11:00
FWIW this check precedes the byte length check in
Dan Ehrenberg
2016/01/12 01:38:33
Was in test262, added an mjsunit test for it.
|
| + throw MakeTypeError(kArrayBufferSpeciesThis); |
| + } |
| - %ArrayBufferSliceImpl(this, result, first); |
| + %ArrayBufferSliceImpl(this, result, first, newLen); |
| return result; |
| } |