From 4a0db26bd00d89632735dcb98617f086461ea963 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Wed, 16 Jan 2013 18:42:04 +0000 Subject: [PATCH] Bug 831386 - GC: ChromeBuffer jsapi test fails under rooting analysis r=terrence --- js/src/jsapi-tests/testChromeBuffer.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/js/src/jsapi-tests/testChromeBuffer.cpp b/js/src/jsapi-tests/testChromeBuffer.cpp index 98e1237f7ee..b7cf6a050f1 100644 --- a/js/src/jsapi-tests/testChromeBuffer.cpp +++ b/js/src/jsapi-tests/testChromeBuffer.cpp @@ -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 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, ¶mName, 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); }