Bug 938907 - Get rid of the compile and go flag on ContextOptions; r=bholley
This commit is contained in:
@@ -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, ¶mName, bytes, strlen(bytes),
|
||||
"", 0));
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine("", 0)
|
||||
.setPrincipals(&system_principals);
|
||||
CHECK(fun = JS_CompileFunction(cx, global, "trusted", 1, ¶mName,
|
||||
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, ¶mName,
|
||||
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, ¶mName, bytes, strlen(bytes),
|
||||
"", 0));
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine("", 0)
|
||||
.setPrincipals(&system_principals);
|
||||
CHECK(fun = JS_CompileFunction(cx, global, "trusted", 1, ¶mName,
|
||||
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, ¶mName,
|
||||
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, ¶mName,
|
||||
bytes, strlen(bytes), "", 0));
|
||||
bytes, strlen(bytes), options));
|
||||
|
||||
JS::RootedValue arg(cx, JS::ObjectValue(*callTrusted));
|
||||
JS::RootedValue rval(cx);
|
||||
|
||||
Reference in New Issue
Block a user