Bug 838014 - Rooting in jsapi-tests/. r=terrence. Landing again.

--HG--
extra : rebase_source : d42fbf0161f4c9758ada38d1d08a2583ab111376
This commit is contained in:
Steve Fink 2013-02-07 13:32:00 -08:00
parent 423e542891
commit 10cc6ef8e7
4 changed files with 19 additions and 18 deletions

View File

@ -33,21 +33,21 @@ BEGIN_TEST(testArrayBuffer_bug720949_steal)
JS::HandleObject obj = testBuf[i];
JS::HandleObject view = testArray[i];
uint32_t size = sizes[i];
jsval v;
js::RootedValue v(cx);
// Byte lengths should all agree
CHECK(JS_IsArrayBufferObject(obj));
CHECK_EQUAL(JS_GetArrayBufferByteLength(obj), size);
JS_GetProperty(cx, obj, "byteLength", &v);
JS_GetProperty(cx, obj, "byteLength", v.address());
CHECK_SAME(v, INT_TO_JSVAL(size));
JS_GetProperty(cx, view, "byteLength", &v);
JS_GetProperty(cx, view, "byteLength", v.address());
CHECK_SAME(v, INT_TO_JSVAL(size));
// Modifying the underlying data should update the value returned through the view
uint8_t *data = JS_GetArrayBufferData(obj);
CHECK(data != NULL);
*reinterpret_cast<uint32_t*>(data) = MAGIC_VALUE_2;
CHECK(JS_GetElement(cx, view, 0, &v));
CHECK(JS_GetElement(cx, view, 0, v.address()));
CHECK_SAME(v, INT_TO_JSVAL(MAGIC_VALUE_2));
// Steal the contents
@ -58,17 +58,17 @@ BEGIN_TEST(testArrayBuffer_bug720949_steal)
// Check that the original ArrayBuffer is neutered
CHECK_EQUAL(JS_GetArrayBufferByteLength(obj), 0);
CHECK(JS_GetProperty(cx, obj, "byteLength", &v));
CHECK(JS_GetProperty(cx, obj, "byteLength", v.address()));
CHECK_SAME(v, INT_TO_JSVAL(0));
CHECK(JS_GetProperty(cx, view, "byteLength", &v));
CHECK(JS_GetProperty(cx, view, "byteLength", v.address()));
CHECK_SAME(v, INT_TO_JSVAL(0));
CHECK(JS_GetProperty(cx, view, "byteOffset", &v));
CHECK(JS_GetProperty(cx, view, "byteOffset", v.address()));
CHECK_SAME(v, INT_TO_JSVAL(0));
CHECK(JS_GetProperty(cx, view, "length", &v));
CHECK(JS_GetProperty(cx, view, "length", v.address()));
CHECK_SAME(v, INT_TO_JSVAL(0));
CHECK_EQUAL(JS_GetArrayBufferByteLength(obj), 0);
v = JSVAL_VOID;
JS_GetElement(cx, obj, 0, &v);
JS_GetElement(cx, obj, 0, v.address());
CHECK_SAME(v, JSVAL_VOID);
// Transfer to a new ArrayBuffer
@ -83,7 +83,7 @@ BEGIN_TEST(testArrayBuffer_bug720949_steal)
data = JS_GetArrayBufferData(dst);
CHECK(data != NULL);
CHECK_EQUAL(*reinterpret_cast<uint32_t*>(data), MAGIC_VALUE_2);
CHECK(JS_GetElement(cx, dstview, 0, &v));
CHECK(JS_GetElement(cx, dstview, 0, v.address()));
CHECK_SAME(v, INT_TO_JSVAL(MAGIC_VALUE_2));
}
@ -162,8 +162,8 @@ BEGIN_TEST(testArrayBuffer_bug720949_viewList)
}
bool isNeutered(JS::HandleObject obj) {
JS::Value v;
return JS_GetProperty(cx, obj, "byteLength", &v) && v.toInt32() == 0;
js::RootedValue v(cx);
return JS_GetProperty(cx, obj, "byteLength", v.address()) && v.toInt32() == 0;
}
END_TEST(testArrayBuffer_bug720949_viewList)

View File

@ -10,11 +10,11 @@
BEGIN_TEST(testDeepFreeze_bug535703)
{
jsval v;
EVAL("var x = {}; x;", &v);
js::RootedValue v(cx);
EVAL("var x = {}; x;", v.address());
js::RootedObject obj(cx, JSVAL_TO_OBJECT(v));
CHECK(JS_DeepFreezeObject(cx, obj)); // don't crash
EVAL("Object.isFrozen(x)", &v);
EVAL("Object.isFrozen(x)", v.address());
CHECK_SAME(v, JSVAL_TRUE);
return true;
}

View File

@ -53,8 +53,8 @@ BEGIN_TEST(testExtendedEq_bug530489)
CHECK(JS_DefineObject(cx, global, "obj1", clasp, NULL, 0));
CHECK(JS_DefineObject(cx, global, "obj2", clasp, NULL, 0));
jsval v;
EVAL("(function() { var r; for (var i = 0; i < 10; ++i) r = obj1 == obj2; return r; })()", &v);
js::RootedValue v(cx);
EVAL("(function() { var r; for (var i = 0; i < 10; ++i) r = obj1 == obj2; return r; })()", v.address());
CHECK_SAME(v, JSVAL_TRUE);
return true;
}

View File

@ -184,10 +184,11 @@ class JSAPITest
return false; \
} while (false)
bool checkSame(jsval actual, jsval expected,
bool checkSame(jsval actualArg, jsval expectedArg,
const char *actualExpr, const char *expectedExpr,
const char *filename, int lineno) {
JSBool same;
js::RootedValue actual(cx, actualArg), expected(cx, expectedArg);
return (JS_SameValue(cx, actual, expected, &same) && same) ||
fail(JSAPITestString("CHECK_SAME failed: expected JS_SameValue(cx, ") +
actualExpr + ", " + expectedExpr + "), got !JS_SameValue(cx, " +