bug 479430 - adding mixing operation callback calls. r=gal

This commit is contained in:
Igor Bukanov 2009-03-02 14:32:27 +01:00
parent eb4d22fda5
commit 6146b86a19
4 changed files with 26 additions and 11 deletions

View File

@ -913,8 +913,10 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
// Check to see if we are running OOM
nsCOMPtr<nsIMemory> mem;
NS_GetMemoryManager(getter_AddRefs(mem));
if (!mem)
if (!mem) {
JS_ClearPendingException(cx);
return JS_FALSE;
}
PRBool lowMemory;
mem->IsLowMemory(&lowMemory);
@ -929,8 +931,10 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
mem->IsLowMemory(&lowMemory);
if (lowMemory) {
if (nsContentUtils::GetBoolPref("dom.prevent_oom_dialog", PR_FALSE))
if (nsContentUtils::GetBoolPref("dom.prevent_oom_dialog", PR_FALSE)) {
JS_ClearPendingException(cx);
return JS_FALSE;
}
nsCOMPtr<nsIPrompt> prompt = GetPromptFromContext(ctx);
@ -946,10 +950,12 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
//GetStringFromName can return NS_OK and still give NULL string
if (NS_FAILED(rv) || !title || !msg) {
NS_ERROR("Failed to get localized strings.");
JS_ClearPendingException(cx);
return JS_FALSE;
}
prompt->Alert(title, msg);
JS_ClearPendingException(cx);
return JS_FALSE;
}
}
@ -1141,6 +1147,7 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
}
}
JS_ClearPendingException(cx);
return JS_FALSE;
}

View File

@ -407,7 +407,7 @@ DOMWorkerOperationCallback(JSContext* aCx)
PRBool extraThreadAllowed = PR_FALSE;
jsrefcount suspendDepth = 0;
do {
for (;;) {
// Kill execution if we're canceled.
if (worker->IsCanceled()) {
LOG(("Forcefully killing JS for worker [0x%p]",
@ -420,7 +420,8 @@ DOMWorkerOperationCallback(JSContext* aCx)
JS_ResumeRequest(aCx, suspendDepth);
}
// Kill exectuion of the currently running JS.
// Kill execution of the currently running JS.
JS_ClearPendingException(aCx);
return JS_FALSE;
}
@ -440,6 +441,7 @@ DOMWorkerOperationCallback(JSContext* aCx)
// the worker was canceled since we checked above.
if (worker->IsCanceled()) {
NS_WARNING("Tried to suspend on a pool that has gone away");
JS_ClearPendingException(aCx);
return JS_FALSE;
}
@ -461,10 +463,7 @@ DOMWorkerOperationCallback(JSContext* aCx)
nsAutoMonitor mon(pool->Monitor());
mon.Wait();
} while (1);
NS_NOTREACHED("Shouldn't get here!");
return JS_FALSE;
}
}
void

View File

@ -2882,7 +2882,6 @@ js_Interpret(JSContext *cx)
ADD_EMPTY_CASE(JSOP_NOP)
ADD_EMPTY_CASE(JSOP_CONDSWITCH)
ADD_EMPTY_CASE(JSOP_TRY)
ADD_EMPTY_CASE(JSOP_FINALLY)
#if JS_HAS_XML_SUPPORT
ADD_EMPTY_CASE(JSOP_STARTXML)
ADD_EMPTY_CASE(JSOP_STARTXMLEXPR)
@ -2953,7 +2952,6 @@ js_Interpret(JSContext *cx)
END_CASE(JSOP_LEAVEWITH)
BEGIN_CASE(JSOP_RETURN)
CHECK_BRANCH();
fp->rval = POP_OPND();
/* FALL THROUGH */
@ -2964,6 +2962,7 @@ js_Interpret(JSContext *cx)
* will be false after the inline_return label.
*/
ASSERT_NOT_THROWING(cx);
CHECK_BRANCH();
if (fp->imacpc) {
/*
@ -6391,8 +6390,13 @@ js_Interpret(JSContext *cx)
JS_ASSERT(cx->throwing);
PUSH(cx->exception);
cx->throwing = JS_FALSE;
CHECK_BRANCH();
END_CASE(JSOP_EXCEPTION)
BEGIN_CASE(JSOP_FINALLY)
CHECK_BRANCH();
END_CASE(JSOP_FINALLY)
BEGIN_CASE(JSOP_THROWING)
JS_ASSERT(!cx->throwing);
cx->throwing = JS_TRUE;
@ -6401,6 +6405,7 @@ js_Interpret(JSContext *cx)
BEGIN_CASE(JSOP_THROW)
JS_ASSERT(!cx->throwing);
CHECK_BRANCH();
cx->throwing = JS_TRUE;
cx->exception = POP_OPND();
/* let the code at error try to catch the exception. */

View File

@ -302,7 +302,11 @@ GetContextData(JSContext *cx)
static JSBool
ShellOperationCallback(JSContext *cx)
{
return !gCanceled;
if (!gCanceled)
return JS_TRUE;
JS_ClearPendingException(cx);
return JS_FALSE;
}
static void