mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 699974 - Plug several holes that prevent stopping slow scripts (r=jst)
--HG-- extra : rebase_source : 220a804295ee3b5fc00c6a23769f05731560c8fe
This commit is contained in:
parent
a5fc0b3da5
commit
c9889b4f09
@ -718,7 +718,7 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
|
||||
// we'll tell the user about this and we'll give the user the option
|
||||
// of stopping the execution of the script.
|
||||
nsCOMPtr<nsIPrompt> prompt = GetPromptFromContext(ctx);
|
||||
NS_ENSURE_TRUE(prompt, JS_TRUE);
|
||||
NS_ENSURE_TRUE(prompt, JS_FALSE);
|
||||
|
||||
// Check if we should offer the option to debug
|
||||
JSStackFrame* fp = ::JS_GetScriptedCaller(cx, NULL);
|
||||
@ -1302,6 +1302,14 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
|
||||
// tricky...
|
||||
}
|
||||
else {
|
||||
// If there is an outer script running, propagate the error upwards.
|
||||
// Otherwise we may lose, e.g., the fact that an inner script evaluation
|
||||
// was killed for taking too long and allow the outer script evaluation to
|
||||
// continue.
|
||||
if (mExecuteDepth > 0 || JS_IsRunning(mContext)) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aIsUndefined) {
|
||||
*aIsUndefined = true;
|
||||
}
|
||||
@ -1501,6 +1509,14 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
||||
rv = JSValueToAString(mContext, val, aRetValue, aIsUndefined);
|
||||
}
|
||||
else {
|
||||
// If there is an outer script running, propagate the error upwards.
|
||||
// Otherwise we may lose, e.g., the fact that an inner script evaluation
|
||||
// was killed for taking too long and allow the outer script evaluation to
|
||||
// continue.
|
||||
if (mExecuteDepth > 1 || JS_IsRunning(mContext)) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aIsUndefined) {
|
||||
*aIsUndefined = true;
|
||||
}
|
||||
@ -1639,6 +1655,14 @@ nsJSContext::ExecuteScript(JSScript* aScriptObject,
|
||||
} else {
|
||||
ReportPendingException();
|
||||
|
||||
// If there is an outer script running, propagate the error upwards.
|
||||
// Otherwise we may lose, e.g., the fact that an inner script evaluation
|
||||
// was killed for taking too long and allow the outer script evaluation to
|
||||
// continue.
|
||||
if (mExecuteDepth > 1 || JS_IsRunning(mContext)) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aIsUndefined) {
|
||||
*aIsUndefined = true;
|
||||
}
|
||||
@ -3115,7 +3139,10 @@ nsJSContext::ScriptEvaluated(bool aTerminated)
|
||||
|
||||
JS_MaybeGC(mContext);
|
||||
|
||||
if (aTerminated) {
|
||||
// Be careful to not reset the operation callback if some outer script is
|
||||
// still running. This would allow a script to bypass the slow script check
|
||||
// simply by invoking nested scripts (e.g., through a plugin).
|
||||
if (aTerminated && mExecuteDepth == 0 && !JS_IsRunning(mContext)) {
|
||||
mOperationCallbackTime = 0;
|
||||
mModalStateTime = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user