diff --git a/js/src/xpconnect/src/XPCDispTearOff.cpp b/js/src/xpconnect/src/XPCDispTearOff.cpp index c0cdcb7ae2e4..ca090c3c83c9 100644 --- a/js/src/xpconnect/src/XPCDispTearOff.cpp +++ b/js/src/xpconnect/src/XPCDispTearOff.cpp @@ -486,9 +486,15 @@ pre_call_clean_up: JS_smprintf_free(sz); } + // Get this right away in case we do something below to cause JS code + // to run on this JSContext. And get it whether success or not so that + // scriptable methods that must return NS_COMFALSE or another non-NS_OK + // success code can do so when implemented by JS. + pending_result = xpcc->GetPendingResult(); + if (!success) { - retval = nsXPCWrappedJSClass::CheckForException(ccx, name.get(), "IDispatch"); + retval = nsXPCWrappedJSClass::CheckForException(ccx, name.get(), "IDispatch", pending_result); goto done; } diff --git a/js/src/xpconnect/src/xpcprivate.h b/js/src/xpconnect/src/xpcprivate.h index 07f0f81f7589..bd894c15728e 100644 --- a/js/src/xpconnect/src/xpcprivate.h +++ b/js/src/xpconnect/src/xpcprivate.h @@ -2054,7 +2054,8 @@ public: static nsresult CheckForException(XPCCallContext & ccx, const char * aPropertyName, - const char * anInterfaceName); + const char * anInterfaceName, + nsresult aPendingResult); private: nsXPCWrappedJSClass(); // not implemented nsXPCWrappedJSClass(XPCCallContext& ccx, REFNSIID aIID, diff --git a/js/src/xpconnect/src/xpcwrappedjsclass.cpp b/js/src/xpconnect/src/xpcwrappedjsclass.cpp index 9175e15b0563..bbd2563d26f5 100644 --- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp +++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp @@ -802,7 +802,8 @@ nsXPCWrappedJSClass::CleanupPointerTypeObject(const nsXPTType& type, nsresult nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx, const char * aPropertyName, - const char * anInterfaceName) + const char * anInterfaceName, + nsresult aPendingResult) { XPCContext * xpcc = ccx.GetXPCContext(); JSContext * cx = ccx.GetJSContext(); @@ -813,10 +814,6 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx, if(xpc_exception) xpcc->SetException(nsnull); - // get this right away in case we do something below to cause JS code - // to run on this JSContext - nsresult pending_result = xpcc->GetPendingResult(); - jsval js_exception; /* JS might throw an expection whether the reporter was called or not */ if(JS_GetPendingException(cx, &js_exception)) @@ -934,9 +931,9 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx, else { // see if JS code signaled failure result without throwing exception - if(NS_FAILED(pending_result)) + if(NS_FAILED(aPendingResult)) { - return pending_result; + return aPendingResult; } } return NS_ERROR_FAILURE; @@ -1368,9 +1365,16 @@ pre_call_clean_up: } } + // Get this right away in case we do something below to cause JS code + // to run on this JSContext. And get it whether success or not so that + // scriptable methods that must return NS_COMFALSE or another non-NS_OK + // success code can do so when implemented by JS. + pending_result = xpcc->GetPendingResult(); + if (!success) { - retval = CheckForException(ccx, name, GetInterfaceName()); + retval = CheckForException(ccx, name, GetInterfaceName(), + pending_result); goto done; }