mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 917798 - Handlify JS exception APIs r=terrence r=bz
This commit is contained in:
parent
619203e6aa
commit
38b602931b
@ -3530,7 +3530,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
// Trust the JS engine (or the script security manager) to set
|
||||
// the exception in the JS engine.
|
||||
|
||||
if (!JS_GetPendingException(my_cx, exn.address())) {
|
||||
if (!JS_GetPendingException(my_cx, &exn)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,11 @@ nsJSUtils::EvaluateString(JSContext* aCx,
|
||||
} else {
|
||||
rv = JS_IsExceptionPending(aCx) ? NS_ERROR_FAILURE
|
||||
: NS_ERROR_OUT_OF_MEMORY;
|
||||
JS_GetPendingException(aCx, aRetValue);
|
||||
JS::RootedValue exn(aCx);
|
||||
JS_GetPendingException(aCx, &exn);
|
||||
if (aRetValue) {
|
||||
*aRetValue = exn;
|
||||
}
|
||||
JS_ClearPendingException(aCx);
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,8 @@ ErrorResult::ReportJSException(JSContext* cx)
|
||||
MOZ_ASSERT(!mMightHaveUnreportedJSException,
|
||||
"Why didn't you tell us you planned to handle JS exceptions?");
|
||||
if (JS_WrapValue(cx, &mJSException)) {
|
||||
JS_SetPendingException(cx, mJSException);
|
||||
JS::RootedValue exception(cx, mJSException);
|
||||
JS_SetPendingException(cx, exception);
|
||||
}
|
||||
// If JS_WrapValue failed, not much we can do about it... No matter
|
||||
// what, go ahead and unroot mJSException.
|
||||
|
@ -186,7 +186,7 @@ CallbackObject::CallSetup::~CallSetup()
|
||||
mErrorResult.MightThrowJSException();
|
||||
if (JS_IsExceptionPending(mCx)) {
|
||||
JS::Rooted<JS::Value> exn(mCx);
|
||||
if (JS_GetPendingException(mCx, exn.address()) &&
|
||||
if (JS_GetPendingException(mCx, &exn) &&
|
||||
ShouldRethrowException(exn)) {
|
||||
mErrorResult.ThrowJSException(mCx, exn);
|
||||
JS_ClearPendingException(mCx);
|
||||
|
@ -71,7 +71,8 @@ ThrowExceptionObject(JSContext* aCx, nsIException* aException)
|
||||
return false;
|
||||
}
|
||||
|
||||
JS_SetPendingException(aCx, OBJECT_TO_JSVAL(obj));
|
||||
JS::RootedValue exn(aCx, JS::ObjectOrNullValue(obj));
|
||||
JS_SetPendingException(aCx, exn);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -457,7 +457,8 @@ ThrowJSException(JSContext *cx, const char *message)
|
||||
ucex.Length());
|
||||
|
||||
if (str) {
|
||||
::JS_SetPendingException(cx, STRING_TO_JSVAL(str));
|
||||
JS::RootedValue exn(cx, JS::StringValue(str));
|
||||
::JS_SetPendingException(cx, exn);
|
||||
}
|
||||
|
||||
PopException();
|
||||
|
@ -118,7 +118,7 @@ JavaScriptChild::fail(JSContext *cx, ReturnStatus *rs)
|
||||
// to the IPC code, and we don't want a JS failure to cause the death
|
||||
// of the child process.
|
||||
|
||||
jsval exn;
|
||||
RootedValue exn(cx);
|
||||
if (!JS_GetPendingException(cx, &exn))
|
||||
return true;
|
||||
|
||||
|
@ -80,7 +80,7 @@ jsd_DebuggerHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
|
||||
JSTrapStatus
|
||||
jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
jsval *rval, void *closure)
|
||||
jsval *rvalArg, void *closure)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
@ -107,10 +107,13 @@ jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
if( ! jsdscript )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
JS_GetPendingException(cx, rval);
|
||||
JS::RootedValue rval(cx);
|
||||
JS_GetPendingException(cx, &rval);
|
||||
|
||||
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_THROW,
|
||||
hook, hookData, rval);
|
||||
JSTrapStatus result = jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_THROW,
|
||||
hook, hookData, rval.address());
|
||||
*rvalArg = rval;
|
||||
return result;
|
||||
}
|
||||
|
||||
JSTrapStatus
|
||||
|
@ -544,7 +544,7 @@ JSDValue*
|
||||
jsd_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
|
||||
{
|
||||
JSContext* cx;
|
||||
jsval val;
|
||||
JS::RootedValue val(cx);
|
||||
|
||||
if(!(cx = _getContextForThreadState(jsdc, jsdthreadstate)))
|
||||
return NULL;
|
||||
@ -563,10 +563,12 @@ jsd_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate,
|
||||
if(!(cx = _getContextForThreadState(jsdc, jsdthreadstate)))
|
||||
return false;
|
||||
|
||||
if(jsdval)
|
||||
JS_SetPendingException(cx, JSD_GetValueWrappedJSVal(jsdc, jsdval));
|
||||
else
|
||||
if(jsdval) {
|
||||
JS::RootedValue exn(cx, JSD_GetValueWrappedJSVal(jsdc, jsdval));
|
||||
JS_SetPendingException(cx, exn);
|
||||
} else {
|
||||
JS_ClearPendingException(cx);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* nameStr)
|
||||
{
|
||||
if (JS_IsExceptionPending(cx))
|
||||
{
|
||||
if (!JS_GetPendingException(cx, propValue.address()))
|
||||
if (!JS_GetPendingException(cx, &propValue))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ jsds_ErrorHookProc (JSDContext *jsdc, JSContext *cx, const char *message,
|
||||
|
||||
nsCOMPtr<jsdIValue> val;
|
||||
if (JS_IsExceptionPending(cx)) {
|
||||
jsval jv;
|
||||
JS::RootedValue jv(cx);
|
||||
JS_GetPendingException(cx, &jv);
|
||||
JSDValue *jsdv = JSD_NewValue (jsdc, jv);
|
||||
val = dont_AddRef(jsdValue::FromPtr(jsdc, jsdv));
|
||||
@ -1999,7 +1999,7 @@ jsdStackFrame::Eval (const nsAString &bytes, const nsACString &fileName,
|
||||
line, &jv);
|
||||
if (!*_rval) {
|
||||
if (JS_IsExceptionPending(cx))
|
||||
JS_GetPendingException (cx, jv.address());
|
||||
JS_GetPendingException (cx, &jv);
|
||||
else
|
||||
jv = JSVAL_NULL;
|
||||
}
|
||||
|
@ -2590,7 +2590,7 @@ ExplicitConvert(JSContext* cx, HandleValue val, HandleObject targetType, void* b
|
||||
// hard failure (out of memory, or some other similarly serious condition).
|
||||
// We store any pending exception in case we need to re-throw it.
|
||||
RootedValue ex(cx);
|
||||
if (!JS_GetPendingException(cx, ex.address()))
|
||||
if (!JS_GetPendingException(cx, &ex))
|
||||
return false;
|
||||
|
||||
// Otherwise, assume soft failure. Clear the pending exception so that we
|
||||
|
@ -209,7 +209,7 @@ class JSAPITest
|
||||
if (JS_IsExceptionPending(cx)) {
|
||||
js::gc::AutoSuppressGC gcoff(cx);
|
||||
JS::RootedValue v(cx);
|
||||
JS_GetPendingException(cx, v.address());
|
||||
JS_GetPendingException(cx, &v);
|
||||
JS_ClearPendingException(cx);
|
||||
JSString *s = JS_ValueToString(cx, v);
|
||||
if (s) {
|
||||
|
@ -5924,21 +5924,20 @@ JS_IsExceptionPending(JSContext *cx)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_GetPendingException(JSContext *cx, jsval *vp)
|
||||
JS_GetPendingException(JSContext *cx, MutableHandleValue vp)
|
||||
{
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
if (!cx->isExceptionPending())
|
||||
return false;
|
||||
*vp = cx->getPendingException();
|
||||
assertSameCompartment(cx, *vp);
|
||||
vp.set(cx->getPendingException());
|
||||
assertSameCompartment(cx, vp);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetPendingException(JSContext *cx, jsval valueArg)
|
||||
JS_SetPendingException(JSContext *cx, HandleValue value)
|
||||
{
|
||||
RootedValue value(cx, valueArg);
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
@ -5975,7 +5974,8 @@ JS_SaveExceptionState(JSContext *cx)
|
||||
CHECK_REQUEST(cx);
|
||||
state = cx->pod_malloc<JSExceptionState>();
|
||||
if (state) {
|
||||
state->throwing = JS_GetPendingException(cx, &state->exception);
|
||||
state->throwing =
|
||||
JS_GetPendingException(cx, MutableHandleValue::fromMarkedLocation(&state->exception));
|
||||
if (state->throwing && JSVAL_IS_GCTHING(state->exception))
|
||||
AddValueRoot(cx, &state->exception, "JSExceptionState.exception");
|
||||
}
|
||||
@ -5989,7 +5989,7 @@ JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state)
|
||||
CHECK_REQUEST(cx);
|
||||
if (state) {
|
||||
if (state->throwing)
|
||||
JS_SetPendingException(cx, state->exception);
|
||||
JS_SetPendingException(cx, HandleValue::fromMarkedLocation(&state->exception));
|
||||
else
|
||||
JS_ClearPendingException(cx);
|
||||
JS_DropExceptionState(cx, state);
|
||||
@ -6011,9 +6011,8 @@ JS_DropExceptionState(JSContext *cx, JSExceptionState *state)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSErrorReport *)
|
||||
JS_ErrorFromException(JSContext *cx, jsval valueArg)
|
||||
JS_ErrorFromException(JSContext *cx, HandleValue value)
|
||||
{
|
||||
RootedValue value(cx, valueArg);
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, value);
|
||||
|
@ -4128,10 +4128,10 @@ extern JS_PUBLIC_API(bool)
|
||||
JS_IsExceptionPending(JSContext *cx);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_GetPendingException(JSContext *cx, jsval *vp);
|
||||
JS_GetPendingException(JSContext *cx, JS::MutableHandleValue vp);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_SetPendingException(JSContext *cx, jsval v);
|
||||
JS_SetPendingException(JSContext *cx, JS::HandleValue v);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ClearPendingException(JSContext *cx);
|
||||
@ -4167,7 +4167,7 @@ JS_DropExceptionState(JSContext *cx, JSExceptionState *state);
|
||||
* of the exception object.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSErrorReport *)
|
||||
JS_ErrorFromException(JSContext *cx, jsval v);
|
||||
JS_ErrorFromException(JSContext *cx, JS::HandleValue v);
|
||||
|
||||
/*
|
||||
* Given a reported error's message and JSErrorReport struct pointer, throw
|
||||
|
@ -981,7 +981,8 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp,
|
||||
return false;
|
||||
}
|
||||
|
||||
JS_SetPendingException(cx, OBJECT_TO_JSVAL(errObject));
|
||||
RootedValue errValue(cx, OBJECT_TO_JSVAL(errObject));
|
||||
JS_SetPendingException(cx, errValue);
|
||||
|
||||
/* Flag the error report passed in to indicate an exception was raised. */
|
||||
reportp->flags |= JSREPORT_EXCEPTION;
|
||||
@ -1019,7 +1020,7 @@ js_ReportUncaughtException(JSContext *cx)
|
||||
return true;
|
||||
|
||||
RootedValue exn(cx);
|
||||
if (!JS_GetPendingException(cx, exn.address()))
|
||||
if (!JS_GetPendingException(cx, &exn))
|
||||
return false;
|
||||
|
||||
AutoValueVector roots(cx);
|
||||
|
@ -850,7 +850,7 @@ class AutoNewContext
|
||||
RootedValue exc(oldcx);
|
||||
bool throwing = JS_IsExceptionPending(newcx);
|
||||
if (throwing)
|
||||
JS_GetPendingException(newcx, exc.address());
|
||||
JS_GetPendingException(newcx, &exc);
|
||||
newCompartment.destroy();
|
||||
newRequest.destroy();
|
||||
if (throwing)
|
||||
|
@ -967,7 +967,7 @@ mozJSComponentLoader::ObjectForLocation(nsIFile *aComponentFile,
|
||||
// exception on this context.
|
||||
JS_SetOptions(cx, oldopts);
|
||||
if (!script && !function && aPropagateExceptions) {
|
||||
JS_GetPendingException(cx, aException.address());
|
||||
JS_GetPendingException(cx, aException);
|
||||
JS_ClearPendingException(cx);
|
||||
}
|
||||
}
|
||||
@ -1020,7 +1020,7 @@ mozJSComponentLoader::ObjectForLocation(nsIFile *aComponentFile,
|
||||
|
||||
if (!ok) {
|
||||
if (aPropagateExceptions) {
|
||||
JS_GetPendingException(cx, aException.address());
|
||||
JS_GetPendingException(cx, aException);
|
||||
JS_ClearPendingException(cx);
|
||||
}
|
||||
*aObject = nullptr;
|
||||
|
@ -62,7 +62,8 @@ NS_IMPL_ISUPPORTS1(mozJSSubScriptLoader, mozIJSSubScriptLoader)
|
||||
static nsresult
|
||||
ReportError(JSContext *cx, const char *msg)
|
||||
{
|
||||
JS_SetPendingException(cx, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, msg)));
|
||||
RootedValue exn(cx, JS::StringValue(JS_NewStringCopyZ(cx, msg)));
|
||||
JS_SetPendingException(cx, exn);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1552,7 +1552,7 @@ xpc::EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& sour
|
||||
}
|
||||
|
||||
// If the sandbox threw an exception, grab it off the context.
|
||||
if (JS_GetPendingException(sandcx, exn.address())) {
|
||||
if (JS_GetPendingException(sandcx, &exn)) {
|
||||
MOZ_ASSERT(!ok);
|
||||
JS_ClearPendingException(sandcx);
|
||||
if (returnStringOnly) {
|
||||
|
@ -255,7 +255,7 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
|
||||
if (!success && JS_IsExceptionPending(cx)) {
|
||||
RootedValue jsexception(cx, NullValue());
|
||||
|
||||
if (JS_GetPendingException(cx, jsexception.address())) {
|
||||
if (JS_GetPendingException(cx, &jsexception)) {
|
||||
nsresult rv;
|
||||
if (jsexception.isObject()) {
|
||||
// XPConnect may have constructed an object to represent a
|
||||
@ -941,7 +941,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
||||
nsresult pending_result = xpcc->GetPendingResult();
|
||||
|
||||
RootedValue js_exception(cx);
|
||||
bool is_js_exception = JS_GetPendingException(cx, js_exception.address());
|
||||
bool is_js_exception = JS_GetPendingException(cx, &js_exception);
|
||||
|
||||
/* JS might throw an expection whether the reporter was called or not */
|
||||
if (is_js_exception) {
|
||||
|
Loading…
Reference in New Issue
Block a user