Bug 831386 - GC: ChromeBuffer jsapi test fails under rooting analysis r=terrence

This commit is contained in:
Jon Coppeard 2013-01-16 18:42:04 +00:00
parent 75b3c1b66e
commit 4a0db26bd0

View File

@ -32,7 +32,7 @@ CallTrusted(JSContext *cx, unsigned argc, jsval *vp)
JSBool ok = JS_FALSE;
{
JSAutoCompartment ac(cx, trusted_glob);
ok = JS_CallFunctionValue(cx, NULL, OBJECT_TO_JSVAL(trusted_fun),
ok = JS_CallFunctionValue(cx, NULL, JS::ObjectValue(*trusted_fun),
0, NULL, vp);
}
JS_RestoreFrameChain(cx);
@ -70,8 +70,8 @@ BEGIN_TEST(testChromeBuffer)
trusted_fun = JS_GetFunctionObject(fun);
}
jsval v = OBJECT_TO_JSVAL(trusted_fun);
CHECK(JS_WrapValue(cx, &v));
js::RootedValue v(cx, JS::ObjectValue(*trusted_fun));
CHECK(JS_WrapValue(cx, v.address()));
const char *paramName = "trusted";
const char *bytes = "try { "
@ -83,7 +83,7 @@ BEGIN_TEST(testChromeBuffer)
bytes, strlen(bytes), "", 0));
jsval rval;
CHECK(JS_CallFunction(cx, NULL, fun, 1, &v, &rval));
CHECK(JS_CallFunction(cx, NULL, fun, 1, v.address(), &rval));
CHECK(JSVAL_TO_INT(rval) == 100);
}
@ -107,8 +107,8 @@ BEGIN_TEST(testChromeBuffer)
trusted_fun = JS_GetFunctionObject(fun);
}
jsval v = OBJECT_TO_JSVAL(trusted_fun);
CHECK(JS_WrapValue(cx, &v));
js::RootedValue v(cx, JS::ObjectValue(*trusted_fun));
CHECK(JS_WrapValue(cx, v.address()));
const char *paramName = "trusted";
const char *bytes = "try { "
@ -120,7 +120,7 @@ BEGIN_TEST(testChromeBuffer)
bytes, strlen(bytes), "", 0));
jsval rval;
CHECK(JS_CallFunction(cx, NULL, fun, 1, &v, &rval));
CHECK(JS_CallFunction(cx, NULL, fun, 1, v.address(), &rval));
JSBool match;
CHECK(JS_StringEqualsAscii(cx, JSVAL_TO_STRING(rval), "From trusted: InternalError: too much recursion", &match));
CHECK(match);
@ -142,7 +142,7 @@ BEGIN_TEST(testChromeBuffer)
}
JSFunction *fun = JS_NewFunction(cx, CallTrusted, 0, 0, global, "callTrusted");
JS::Anchor<JSObject *> callTrusted(JS_GetFunctionObject(fun));
js::RootedObject callTrusted(cx, JS_GetFunctionObject(fun));
const char *paramName = "f";
const char *bytes = "try { "
@ -153,9 +153,9 @@ BEGIN_TEST(testChromeBuffer)
CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName,
bytes, strlen(bytes), "", 0));
jsval arg = OBJECT_TO_JSVAL(callTrusted.get());
js::RootedValue arg(cx, JS::ObjectValue(*callTrusted));
jsval rval;
CHECK(JS_CallFunction(cx, NULL, fun, 1, &arg, &rval));
CHECK(JS_CallFunction(cx, NULL, fun, 1, arg.address(), &rval));
CHECK(JSVAL_TO_INT(rval) == 42);
}