Bug 978042 - Part 2: AutoPushJSContext in nsGlobalWindow::RunTimeoutHandler. r=bholley

This commit is contained in:
Bob Owen 2014-03-07 09:58:33 +00:00
parent 3fbc188f5e
commit db45c8c58e

View File

@ -11853,13 +11853,16 @@ nsGlobalWindow::RunTimeoutHandler(nsTimeout* aTimeout,
uint32_t lineNo = 0;
handler->GetLocation(&filename, &lineNo);
AutoPushJSContext cx(aScx->GetNativeContext());
JS::CompileOptions options(cx);
// New script entry point required, due to the "Create a script" sub-step of
// http://www.whatwg.org/specs/web-apps/current-work/#timer-initialization-steps
AutoEntryScript entryScript(this, true, aScx->GetNativeContext());
JS::CompileOptions options(entryScript.cx());
options.setFileAndLine(filename, lineNo)
.setVersion(JSVERSION_DEFAULT);
JS::Rooted<JSObject*> global(cx, FastGetGlobalJSObject());
aScx->EvaluateString(nsDependentString(script), global,
options, /*aCoerceToString = */ false, nullptr);
JS::Rooted<JSObject*> global(entryScript.cx(), FastGetGlobalJSObject());
nsJSUtils::EvaluateOptions evalOptions;
nsJSUtils::EvaluateString(entryScript.cx(), nsDependentString(script),
global, options, evalOptions, nullptr);
} else {
// Hold strong ref to ourselves while we call the callback.
nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this));