[JAEGER] Merge from Tracemonkey.

This commit is contained in:
David Mandelin 2010-08-27 11:32:19 -07:00
commit c7756ac00b
4 changed files with 26 additions and 20 deletions

View File

@ -126,15 +126,12 @@ ArrayBuffer::create(JSContext *cx, JSObject *obj,
rval->setObject(*obj);
}
if (argc == 0) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_TYPED_ARRAY_BAD_ARGS);
return false;
int32_t nbytes = 0;
if (argc > 0) {
if (!ValueToECMAInt32(cx, argv[0], &nbytes))
return false;
}
int32_t nbytes;
if (!ValueToECMAInt32(cx, argv[0], &nbytes))
return false;
if (nbytes < 0) {
/*
* We're just not going to support arrays that are bigger than what will fit
@ -745,20 +742,17 @@ class TypedArrayTemplate
ThisTypeArray *tarray = 0;
// must have at least one arg
if (argc == 0) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_TYPED_ARRAY_BAD_ARGS);
return false;
}
// figure out the type of the first argument;
// no args is treated like an int arg of 0.
if (argc == 0 || argv[0].isInt32()) {
int32 len = 0;
if (argc != 0)
len = argv[0].toInt32();
// figure out the type of the first argument
if (argv[0].isInt32()) {
int32 len = argv[0].toInt32();
if (len < 0) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_BAD_ARRAY_LENGTH);
return false;
}

View File

@ -96,10 +96,25 @@ function test()
check(function() (new Int32Array(zerobuf)).length == 0);
checkThrows(function() new Int32Array(zerobuf, 1));
var zerobuf2 = new ArrayBuffer();
check(function() zerobuf2.byteLength == 0);
checkThrows(function() new ArrayBuffer(-100));
// this is using js_ValueToECMAUInt32, which is giving 0 for "abc"
checkThrows(function() new ArrayBuffer("abc"), TODO);
var zeroarray = new Int32Array(0);
check(function() zeroarray.length == 0);
check(function() zeroarray.byteLength == 0);
check(function() zeroarray.buffer);
check(function() zeroarray.buffer.byteLength == 0);
var zeroarray2 = new Int32Array();
check(function() zeroarray2.length == 0);
check(function() zeroarray2.byteLength == 0);
check(function() zeroarray2.buffer);
check(function() zeroarray2.buffer.byteLength == 0);
var a = new Int32Array(20);
check(function() a);
check(function() a.length == 20);

View File

@ -1,5 +1,3 @@
// |trace-test| error: invalid arguments
__defineGetter__('x', Float32Array);
with(this)
x;

View File

@ -1,4 +1,3 @@
// |trace-test| error: invalid arguments
__defineGetter__("x", Float64Array)
Function("\
with(this) {\