Bug 1312003 - Add some missing return value checks to JSAPI tests. r=arai
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 28 Oct 2016 12:09:24 +0200
changeset 319981 e2e3d6a007392ced30987f312d468dd37ea87528
parent 319980 d2f850fe57e1166ac9ac3bc3c59b2e79ee5a1017
child 319982 79635ac69f44a801eedf85c5c73cf9e7674e5b21
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1312003
milestone52.0a1
Bug 1312003 - Add some missing return value checks to JSAPI tests. r=arai
js/src/jsapi-tests/testArrayBuffer.cpp
js/src/jsapi-tests/testException.cpp
js/src/jsapi-tests/testForceLexicalInitialization.cpp
js/src/jsapi-tests/testTypedArrays.cpp
--- a/js/src/jsapi-tests/testArrayBuffer.cpp
+++ b/js/src/jsapi-tests/testArrayBuffer.cpp
@@ -18,34 +18,34 @@ BEGIN_TEST(testArrayBuffer_bug720949_ste
     uint32_t sizes[NUM_TEST_BUFFERS] = { sizeof(uint32_t), 200 * sizeof(uint32_t) };
     JS::HandleObject testBuf[NUM_TEST_BUFFERS] = { buf_len1, buf_len200 };
     JS::HandleObject testArray[NUM_TEST_BUFFERS] = { tarray_len1, tarray_len200 };
 
     // Single-element ArrayBuffer (uses fixed slots for storage)
     CHECK(buf_len1 = JS_NewArrayBuffer(cx, sizes[0]));
     CHECK(tarray_len1 = JS_NewInt32ArrayWithBuffer(cx, testBuf[0], 0, -1));
 
-    JS_SetElement(cx, testArray[0], 0, MAGIC_VALUE_1);
+    CHECK(JS_SetElement(cx, testArray[0], 0, MAGIC_VALUE_1));
 
     // Many-element ArrayBuffer (uses dynamic storage)
     CHECK(buf_len200 = JS_NewArrayBuffer(cx, 200 * sizeof(uint32_t)));
     CHECK(tarray_len200 = JS_NewInt32ArrayWithBuffer(cx, testBuf[1], 0, -1));
 
     for (unsigned i = 0; i < NUM_TEST_BUFFERS; i++) {
         JS::HandleObject obj = testBuf[i];
         JS::HandleObject view = testArray[i];
         uint32_t size = sizes[i];
         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);
+        CHECK(JS_GetProperty(cx, obj, "byteLength", &v));
         CHECK(v.isInt32(size));
-        JS_GetProperty(cx, view, "byteLength", &v);
+        CHECK(JS_GetProperty(cx, view, "byteLength", &v));
         CHECK(v.isInt32(size));
 
         // Modifying the underlying data should update the value returned through the view
         {
             JS::AutoCheckCannotGC nogc;
             bool sharedDummy;
             uint8_t* data = JS_GetArrayBufferData(obj, &sharedDummy, nogc);
             CHECK(data != nullptr);
--- a/js/src/jsapi-tests/testException.cpp
+++ b/js/src/jsapi-tests/testException.cpp
@@ -10,17 +10,17 @@
 BEGIN_TEST(testException_bug860435)
 {
     JS::RootedValue fun(cx);
 
     EVAL("ReferenceError", &fun);
     CHECK(fun.isObject());
 
     JS::RootedValue v(cx);
-    JS_CallFunctionValue(cx, global, fun, JS::HandleValueArray::empty(), &v);
+    CHECK(JS_CallFunctionValue(cx, global, fun, JS::HandleValueArray::empty(), &v));
     CHECK(v.isObject());
     JS::RootedObject obj(cx, &v.toObject());
 
-    JS_GetProperty(cx, obj, "stack", &v);
+    CHECK(JS_GetProperty(cx, obj, "stack", &v));
     CHECK(v.isString());
     return true;
 }
 END_TEST(testException_bug860435)
--- a/js/src/jsapi-tests/testForceLexicalInitialization.cpp
+++ b/js/src/jsapi-tests/testForceLexicalInitialization.cpp
@@ -17,17 +17,17 @@ BEGIN_TEST(testForceLexicalInitializatio
     JS::Rooted<js::LexicalEnvironmentObject*> env(
         cx, js::LexicalEnvironmentObject::createGlobal(cx, g));
 
     JS::RootedValue uninitialized(cx, JS::MagicValue(JS_UNINITIALIZED_LEXICAL));
     js::RootedPropertyName name(cx, Atomize(cx, "foopi", 4)->asPropertyName());
     JS::RootedId id(cx, NameToId(name));
     unsigned attrs = JSPROP_ENUMERATE | JSPROP_PERMANENT;
 
-    NativeDefineProperty(cx, env, id, uninitialized, nullptr, nullptr, attrs);
+    CHECK(NativeDefineProperty(cx, env, id, uninitialized, nullptr, nullptr, attrs));
 
     // Verify that "foopi" is uninitialized
     const JS::Value v = env->getSlot(env->lookup(cx, id)->slot());
     CHECK(v.isMagic(JS_UNINITIALIZED_LEXICAL));
 
     ForceLexicalInitialization(cx, env);
 
     // Verify that "foopi" has been initialized to undefined
--- a/js/src/jsapi-tests/testTypedArrays.cpp
+++ b/js/src/jsapi-tests/testTypedArrays.cpp
@@ -169,48 +169,48 @@ TestArrayFromBuffer(JSContext* cx)
 
     RootedObject ofsArray(cx, CreateWithBuffer(cx, buffer, nbytes / 2, -1));
     CHECK_EQUAL(JS_GetTypedArrayLength(ofsArray), elts / 2);
     CHECK_EQUAL(JS_GetTypedArrayByteOffset(ofsArray), nbytes / 2);
     CHECK_EQUAL(JS_GetTypedArrayByteLength(ofsArray), nbytes / 2);
 
     // Make sure all 3 views reflect the same buffer at the expected locations
     JS::RootedValue v(cx, JS::Int32Value(39));
-    JS_SetElement(cx, array, 0, v);
+    CHECK(JS_SetElement(cx, array, 0, v));
     JS::RootedValue v2(cx);
     CHECK(JS_GetElement(cx, array, 0, &v2));
     CHECK_SAME(v, v2);
     CHECK(JS_GetElement(cx, shortArray, 0, &v2));
     CHECK_SAME(v, v2);
     {
         JS::AutoCheckCannotGC nogc;
         Element* data;
         bool isShared;
         CHECK(data = GetData(array, &isShared, nogc));
         CHECK_EQUAL(Shared, isShared);
         CHECK_EQUAL(long(v.toInt32()), long(reinterpret_cast<Element*>(data)[0]));
     }
 
     v.setInt32(40);
-    JS_SetElement(cx, array, elts / 2, v);
+    CHECK(JS_SetElement(cx, array, elts / 2, v));
     CHECK(JS_GetElement(cx, array, elts / 2, &v2));
     CHECK_SAME(v, v2);
     CHECK(JS_GetElement(cx, ofsArray, 0, &v2));
     CHECK_SAME(v, v2);
     {
         JS::AutoCheckCannotGC nogc;
         Element* data;
         bool isShared;
         CHECK(data = GetData(array, &isShared, nogc));
         CHECK_EQUAL(Shared, isShared);
         CHECK_EQUAL(long(v.toInt32()), long(reinterpret_cast<Element*>(data)[elts / 2]));
     }
 
     v.setInt32(41);
-    JS_SetElement(cx, array, elts - 1, v);
+    CHECK(JS_SetElement(cx, array, elts - 1, v));
     CHECK(JS_GetElement(cx, array, elts - 1, &v2));
     CHECK_SAME(v, v2);
     CHECK(JS_GetElement(cx, ofsArray, elts / 2 - 1, &v2));
     CHECK_SAME(v, v2);
     {
         JS::AutoCheckCannotGC nogc;
         Element* data;
         bool isShared;
@@ -221,16 +221,16 @@ TestArrayFromBuffer(JSContext* cx)
 
     JS::RootedObject copy(cx, CreateFromArray(cx, array));
     CHECK(JS_GetElement(cx, array, 0, &v));
     CHECK(JS_GetElement(cx, copy, 0, &v2));
     CHECK_SAME(v, v2);
 
     /* The copy should not see changes in the original */
     v2.setInt32(42);
-    JS_SetElement(cx, array, 0, v2);
+    CHECK(JS_SetElement(cx, array, 0, v2));
     CHECK(JS_GetElement(cx, copy, 0, &v2));
     CHECK_SAME(v2, v); /* v is still the original value from 'array' */
 
     return true;
 }
 
 END_TEST(testTypedArrays)