Bug 980180 - remove principals as an argument to compilation, part 2 (r=terrence)

--HG--
extra : rebase_source : 86791b50b4293ba5506f1e0f5c64730338f552e6
This commit is contained in:
Luke Wagner 2014-03-06 16:28:07 -06:00
Родитель 1f15bc50e0
Коммит 9d3664fd61
5 изменённых файлов: 12 добавлений и 145 удалений

Просмотреть файл

@ -63,12 +63,14 @@ eval(const char *asciiChars, JSPrincipals *principals, JSPrincipals *originPrinc
CHECK(global);
JSAutoCompartment ac(cx, global);
CHECK(JS_InitStandardClasses(cx, global));
bool ok = JS_EvaluateUCScriptForPrincipalsVersionOrigin(cx, global,
principals,
originPrincipals,
chars, len, "", 0,
rval,
JSVERSION_DEFAULT);
JS::CompileOptions options(cx);
options.setOriginPrincipals(originPrincipals)
.setFileAndLine("", 0);
bool ok = JS::Evaluate(cx, global, options, chars, len, rval.address());
delete[] chars;
return ok;
}

Просмотреть файл

@ -4884,55 +4884,6 @@ JS::Evaluate(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &opti
return Evaluate(cx, obj, options, buffer.begin(), buffer.length(), rval);
}
JS_PUBLIC_API(bool)
JS_EvaluateUCScriptForPrincipals(JSContext *cx, HandleObject obj,
JSPrincipals *principals,
const jschar *chars, unsigned length,
const char *filename, unsigned lineno,
MutableHandleValue rval)
{
JS_ASSERT(principals == cx->compartment()->principals);
CompileOptions options(cx);
options.setFileAndLine(filename, lineno);
return Evaluate(cx, obj, options, chars, length, rval.address());
}
JS_PUBLIC_API(bool)
JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, HandleObject obj,
JSPrincipals *principals,
const jschar *chars, unsigned length,
const char *filename, unsigned lineno,
MutableHandleValue rval, JSVersion version)
{
JS_ASSERT(principals == cx->compartment()->principals);
CompileOptions options(cx);
options.setFileAndLine(filename, lineno)
.setVersion(version);
return Evaluate(cx, obj, options, chars, length, rval.address());
}
extern JS_PUBLIC_API(bool)
JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, HandleObject obj,
JSPrincipals *principals,
JSPrincipals *originPrincipals,
const jschar *chars, unsigned length,
const char *filename, unsigned lineno,
MutableHandleValue rval, JSVersion version)
{
JS_ASSERT(principals == cx->compartment()->principals);
CompileOptions options(cx);
options.setOriginPrincipals(originPrincipals)
.setFileAndLine(filename, lineno)
.setVersion(version);
return Evaluate(cx, obj, options, chars, length, rval.address());
}
JS_PUBLIC_API(bool)
JS_EvaluateUCScript(JSContext *cx, HandleObject obj, const jschar *chars, unsigned length,
const char *filename, unsigned lineno, MutableHandleValue rval)
@ -4943,37 +4894,6 @@ JS_EvaluateUCScript(JSContext *cx, HandleObject obj, const jschar *chars, unsign
return Evaluate(cx, obj, options, chars, length, rval.address());
}
/* Ancient unsigned nbytes is part of API/ABI, so use size_t length local. */
JS_PUBLIC_API(bool)
JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *objArg, JSPrincipals *principals,
const char *bytes, unsigned nbytes,
const char *filename, unsigned lineno, jsval *rval)
{
JS_ASSERT(principals == cx->compartment()->principals);
RootedObject obj(cx, objArg);
CompileOptions options(cx);
options.setFileAndLine(filename, lineno);
return Evaluate(cx, obj, options, bytes, nbytes, rval);
}
JS_PUBLIC_API(bool)
JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *objArg, JSPrincipals *principals,
const char *bytes, unsigned nbytes,
const char *filename, unsigned lineno, jsval *rval,
JSVersion version)
{
JS_ASSERT(principals == cx->compartment()->principals);
RootedObject obj(cx, objArg);
CompileOptions options(cx);
options.setVersion(version)
.setFileAndLine(filename, lineno);
return Evaluate(cx, obj, options, bytes, nbytes, rval);
}
JS_PUBLIC_API(bool)
JS_EvaluateScript(JSContext *cx, JSObject *objArg, const char *bytes, unsigned nbytes,
const char *filename, unsigned lineno, jsval *rval)

Просмотреть файл

@ -3839,69 +3839,18 @@ extern JS_PUBLIC_API(bool)
JS_ExecuteScriptVersion(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval,
JSVersion version);
/*
* Execute either the function-defining prolog of a script, or the script's
* main body, but not both.
*/
typedef enum JSExecPart { JSEXEC_PROLOG, JSEXEC_MAIN } JSExecPart;
extern JS_PUBLIC_API(bool)
JS_EvaluateScript(JSContext *cx, JSObject *obj,
const char *bytes, unsigned length,
const char *filename, unsigned lineno,
jsval *rval);
extern JS_PUBLIC_API(bool)
JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj,
JSPrincipals *principals,
const char *bytes, unsigned length,
const char *filename, unsigned lineno,
jsval *rval);
extern JS_PUBLIC_API(bool)
JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
JSPrincipals *principals,
const char *bytes, unsigned length,
const char *filename, unsigned lineno,
jsval *rval, JSVersion version);
extern JS_PUBLIC_API(bool)
JS_EvaluateUCScript(JSContext *cx, JS::Handle<JSObject*> obj,
const jschar *chars, unsigned length,
const char *filename, unsigned lineno,
JS::MutableHandle<JS::Value> rval);
extern JS_PUBLIC_API(bool)
JS_EvaluateUCScriptForPrincipals(JSContext *cx, JS::Handle<JSObject*> obj,
JSPrincipals *principals,
const jschar *chars, unsigned length,
const char *filename, unsigned lineno,
JS::MutableHandle<JS::Value> rval);
extern JS_PUBLIC_API(bool)
JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JS::Handle<JSObject*> obj,
JSPrincipals *principals,
const jschar *chars, unsigned length,
const char *filename, unsigned lineno,
JS::MutableHandle<JS::Value> rval, JSVersion version);
/*
* JSAPI clients may optionally specify the 'originPrincipals' of a script.
* A script's originPrincipals may be retrieved through the debug API (via
* JS_GetScriptOriginPrincipals) and the originPrincipals are transitively
* assigned to any nested scripts (including scripts dynamically created via
* eval and the Function constructor). If originPrincipals is null, then the
* value of principals is used as origin principals for the script.
*/
extern JS_PUBLIC_API(bool)
JS_EvaluateUCScriptForPrincipalsVersionOrigin(JSContext *cx, JS::Handle<JSObject*> obj,
JSPrincipals *principals,
JSPrincipals *originPrincipals,
const jschar *chars, unsigned length,
const char *filename, unsigned lineno,
JS::MutableHandle<JS::Value> rval,
JSVersion version);
namespace JS {
extern JS_PUBLIC_API(bool)

Просмотреть файл

@ -1155,9 +1155,8 @@ ProcessArgs(JSContext *cx, JS::Handle<JSObject*> obj, char **argv, int argc, XPC
return usage();
}
JS_EvaluateScriptForPrincipals(cx, obj, gJSPrincipals, argv[i],
strlen(argv[i]), "-e", 1,
rval.address());
JS_EvaluateScript(cx, obj, argv[i], strlen(argv[i]), "-e", 1,
rval.address());
isInteractive = false;
break;

Просмотреть файл

@ -2207,11 +2207,8 @@ nsCryptoRunnable::Run()
JSAutoCompartment ac(cx, m_args->m_scope);
bool ok =
JS_EvaluateScriptForPrincipals(cx, m_args->m_scope,
nsJSPrincipals::get(m_args->m_principals),
m_args->m_jsCallback,
strlen(m_args->m_jsCallback),
nullptr, 0, nullptr);
JS_EvaluateScript(cx, m_args->m_scope, m_args->m_jsCallback,
strlen(m_args->m_jsCallback), nullptr, 0, nullptr);
return ok ? NS_OK : NS_ERROR_FAILURE;
}