8066217: ArrayBuffer constructor was erroneous with zero args
Reviewed-by: sundar, hannesw
This commit is contained in:
parent
cf37646b3f
commit
999ce35e84
@ -26,7 +26,9 @@
|
||||
package jdk.nashorn.internal.objects;
|
||||
|
||||
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import jdk.nashorn.internal.objects.annotations.Attribute;
|
||||
import jdk.nashorn.internal.objects.annotations.Constructor;
|
||||
import jdk.nashorn.internal.objects.annotations.Function;
|
||||
@ -101,7 +103,7 @@ public final class NativeArrayBuffer extends ScriptObject {
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
throw new RuntimeException("missing length argument");
|
||||
return new NativeArrayBuffer(0);
|
||||
}
|
||||
|
||||
return new NativeArrayBuffer(JSType.toInt32(args[0]));
|
||||
|
@ -28,6 +28,17 @@
|
||||
* @run
|
||||
*/
|
||||
|
||||
//JDK-8066217, constructor for arraybuffer not behaving as per spec
|
||||
function checkLength(ab, l) {
|
||||
if (ab.byteLength != l) {
|
||||
throw "length error: " + ab.byteLength + " != " + l;
|
||||
}
|
||||
}
|
||||
checkLength(new ArrayBuffer(), 0);
|
||||
checkLength(new ArrayBuffer(0), 0);
|
||||
checkLength(new ArrayBuffer(1024), 1024);
|
||||
checkLength(new ArrayBuffer(1,2,3), 1);
|
||||
checkLength(new ArrayBuffer([17]), 17);
|
||||
|
||||
var typeDefinitions = [
|
||||
Int8Array,
|
||||
|
Loading…
Reference in New Issue
Block a user