Bug 938907 - Get rid of the compile and go flag on ContextOptions; r=bholley

This commit is contained in:
Eddy Bruel
2013-11-19 12:41:42 +01:00
parent e5c35ae07a
commit 30cf82f074
14 changed files with 151 additions and 185 deletions

View File

@@ -64,9 +64,11 @@ BEGIN_TEST(testChromeBuffer)
const char *paramName = "x";
const char *bytes = "return x ? 1 + trusted(x-1) : 0";
JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&trusted_glob);
CHECK(fun = JS_CompileFunctionForPrincipals(cx, global, &system_principals,
"trusted", 1, &paramName, bytes, strlen(bytes),
"", 0));
JS::CompileOptions options(cx);
options.setFileAndLine("", 0)
.setPrincipals(&system_principals);
CHECK(fun = JS_CompileFunction(cx, global, "trusted", 1, &paramName,
bytes, strlen(bytes), options));
trusted_fun = JS_GetFunctionObject(fun);
if (!JS_AddNamedObjectRoot(cx, &trusted_fun, "trusted-function"))
return false;
@@ -85,8 +87,10 @@ BEGIN_TEST(testChromeBuffer)
" return -1; "
" } "
"} ";
JS::CompileOptions options(cx);
options.setFileAndLine("", 0);
CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName,
bytes, strlen(bytes), "", 0));
bytes, strlen(bytes), options));
JS::RootedValue rval(cx);
CHECK(JS_CallFunction(cx, nullptr, fun, 1, v.address(), rval.address()));
@@ -107,9 +111,11 @@ BEGIN_TEST(testChromeBuffer)
" return 'From trusted: ' + e; "
"} ";
JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&trusted_glob);
CHECK(fun = JS_CompileFunctionForPrincipals(cx, global, &system_principals,
"trusted", 1, &paramName, bytes, strlen(bytes),
"", 0));
JS::CompileOptions options(cx);
options.setFileAndLine("", 0)
.setPrincipals(&system_principals);
CHECK(fun = JS_CompileFunction(cx, global, "trusted", 1, &paramName,
bytes, strlen(bytes), options));
trusted_fun = JS_GetFunctionObject(fun);
}
@@ -122,8 +128,10 @@ BEGIN_TEST(testChromeBuffer)
"} catch (e) { "
" return trusted(untrusted); "
"} ";
JS::CompileOptions options(cx);
options.setFileAndLine("", 0);
CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName,
bytes, strlen(bytes), "", 0));
bytes, strlen(bytes), options));
JS::RootedValue rval(cx);
CHECK(JS_CallFunction(cx, nullptr, fun, 1, v.address(), rval.address()));
@@ -141,9 +149,11 @@ BEGIN_TEST(testChromeBuffer)
JSAutoCompartment ac(cx, trusted_glob);
const char *bytes = "return 42";
JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&trusted_glob);
CHECK(fun = JS_CompileFunctionForPrincipals(cx, global, &system_principals,
"trusted", 0, nullptr,
bytes, strlen(bytes), "", 0));
JS::CompileOptions options(cx);
options.setFileAndLine("", 0)
.setPrincipals(&system_principals);
CHECK(fun = JS_CompileFunction(cx, global, "trusted", 0, nullptr,
bytes, strlen(bytes), options));
trusted_fun = JS_GetFunctionObject(fun);
}
@@ -156,8 +166,10 @@ BEGIN_TEST(testChromeBuffer)
"} catch (e) { "
" return f(); "
"} ";
JS::CompileOptions options(cx);
options.setFileAndLine("", 0);
CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, &paramName,
bytes, strlen(bytes), "", 0));
bytes, strlen(bytes), options));
JS::RootedValue arg(cx, JS::ObjectValue(*callTrusted));
JS::RootedValue rval(cx);