mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-01 21:07:30 +09:00
Issue #2686 - Don't rely on return value of ExecutionContext::Compile when the context may forbid running scripts
This is relevant if scripting is terminated due to execution timeout but there are setTimeout/Interval callbacks pending or if scripting is disabled altogether.
This commit is contained in:
parent
77728935ef
commit
0590764f1f
4 changed files with 12 additions and 8 deletions
|
|
@ -12941,10 +12941,11 @@ nsGlobalWindow::RunTimeoutHandler(Timeout* aTimeout,
|
||||||
nsJSUtils::ExecutionContext exec(aes.cx(), global);
|
nsJSUtils::ExecutionContext exec(aes.cx(), global);
|
||||||
rv = exec.Compile(options, handler->GetHandlerText());
|
rv = exec.Compile(options, handler->GetHandlerText());
|
||||||
|
|
||||||
if (rv == NS_OK) {
|
JS::Rooted<JSScript*> script(aes.cx(), exec.GetScript());
|
||||||
|
if (script) {
|
||||||
LoadedScript* initiatingScript = handler->GetInitiatingScript();
|
LoadedScript* initiatingScript = handler->GetInitiatingScript();
|
||||||
if (initiatingScript) {
|
if (initiatingScript) {
|
||||||
initiatingScript->AssociateWithScript(exec.GetScript());
|
initiatingScript->AssociateWithScript(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = exec.ExecScript();
|
rv = exec.ExecScript();
|
||||||
|
|
|
||||||
|
|
@ -315,8 +315,11 @@ nsJSUtils::ExecutionContext::JoinDecode(void **aOffThreadToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
JSScript* nsJSUtils::ExecutionContext::GetScript() {
|
JSScript* nsJSUtils::ExecutionContext::GetScript() {
|
||||||
|
if (mSkip) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
MOZ_ASSERT(!mSkip);
|
|
||||||
MOZ_ASSERT(mScript);
|
MOZ_ASSERT(mScript);
|
||||||
mScriptUsed = true;
|
mScriptUsed = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,10 @@ public:
|
||||||
// thread.
|
// thread.
|
||||||
nsresult JoinDecode(void** aOffThreadToken);
|
nsresult JoinDecode(void** aOffThreadToken);
|
||||||
|
|
||||||
// Get a successfully compiled script.
|
// Get the compiled script if present, or nullptr.
|
||||||
|
//
|
||||||
|
// Compilation may succeed without producing a script when scripting is disabled for the global. Causes for this can
|
||||||
|
// be the global pref or dynamic change when script execution in a global is terminated due to max_script_run_time.
|
||||||
JSScript* GetScript();
|
JSScript* GetScript();
|
||||||
|
|
||||||
// Execute the compiled script and ignore the return value.
|
// Execute the compiled script and ignore the return value.
|
||||||
|
|
|
||||||
|
|
@ -2377,10 +2377,7 @@ ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest)
|
||||||
rv = exec.Compile(options, srcBuf);
|
rv = exec.Compile(options, srcBuf);
|
||||||
}
|
}
|
||||||
if (rv == NS_OK) {
|
if (rv == NS_OK) {
|
||||||
JS::Rooted<JSScript*> script(cx);
|
JS::Rooted<JSScript*> script(cx, exec.GetScript());
|
||||||
script = exec.GetScript();
|
|
||||||
|
|
||||||
// With scripts disabled GetScript() will return nullptr
|
|
||||||
if (script) {
|
if (script) {
|
||||||
// Create a ClassicScript object and associate it with the
|
// Create a ClassicScript object and associate it with the
|
||||||
// JSScript.
|
// JSScript.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue