Commit cfa91762 authored by dslomov@chromium.org's avatar dslomov@chromium.org

Allow parameterless typed array constructors.

ES6 spec tacitly allows them, and they are allowed in Firefox and in
WebKit/Blink.

R=bmeurer@chromium.org,rossberg@chromium.org

Review URL: https://codereview.chromium.org/18769005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15579 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5eeed463
......@@ -104,8 +104,6 @@ var kMessages = {
observe_perform_non_function: ["Cannot perform non-function"],
observe_notify_non_notifier: ["notify called on non-notifier object"],
proto_poison_pill: ["Generic use of __proto__ accessor not allowed"],
parameterless_typed_array_constr:
["%0"," constructor should have at least one argument."],
not_typed_array: ["this is not a typed array."],
invalid_argument: ["invalid_argument"],
data_view_not_array_buffer: ["First argument to DataView constructor must be an ArrayBuffer"],
......
......@@ -89,12 +89,11 @@ function CreateTypedArrayConstructor(name, elementSize, arrayId, constructor) {
if (%_IsConstructCall()) {
if (IS_ARRAYBUFFER(arg1)) {
ConstructByArrayBuffer(this, arg1, arg2, arg3);
} else if (IS_NUMBER(arg1) || IS_STRING(arg1) || IS_BOOLEAN(arg1)) {
} else if (IS_NUMBER(arg1) || IS_STRING(arg1) ||
IS_BOOLEAN(arg1) || IS_UNDEFINED(arg1)) {
ConstructByLength(this, arg1);
} else if (!IS_UNDEFINED(arg1)){
ConstructByArrayLike(this, arg1);
} else {
throw MakeTypeError("parameterless_typed_array_constr", [name]);
ConstructByArrayLike(this, arg1);
}
} else {
throw MakeTypeError("constructor_not_function", [name])
......
......@@ -219,7 +219,6 @@ function TestTypedArray(proto, elementSize, typicalElement) {
assertThrows(function() { new proto(unalignedArrayBuffer)}, RangeError);
assertThrows(function() { new proto(unalignedArrayBuffer, 5*elementSize)},
RangeError);
assertThrows(function() { new proto() }, TypeError);
}
var aFromString = new proto("30");
......@@ -250,6 +249,12 @@ function TestTypedArray(proto, elementSize, typicalElement) {
assertSame(0, aOverAbLen0.length);
assertSame(0, aOverAbLen0.byteLength);
assertSame(0, aOverAbLen0.byteOffset);
var aNoParam = new proto();
assertSame(elementSize, aNoParam.BYTES_PER_ELEMENT);
assertSame(0, aNoParam.length);
assertSame(0, aNoParam.byteLength);
assertSame(0, aNoParam.byteOffset);
}
TestTypedArray(Uint8Array, 1, 0xFF);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment