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; uint32_t lineNo = 0;
handler->GetLocation(&filename, &lineNo); handler->GetLocation(&filename, &lineNo);
AutoPushJSContext cx(aScx->GetNativeContext()); // New script entry point required, due to the "Create a script" sub-step of
JS::CompileOptions options(cx); // 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) options.setFileAndLine(filename, lineNo)
.setVersion(JSVERSION_DEFAULT); .setVersion(JSVERSION_DEFAULT);
JS::Rooted<JSObject*> global(cx, FastGetGlobalJSObject()); JS::Rooted<JSObject*> global(entryScript.cx(), FastGetGlobalJSObject());
aScx->EvaluateString(nsDependentString(script), global, nsJSUtils::EvaluateOptions evalOptions;
options, /*aCoerceToString = */ false, nullptr); nsJSUtils::EvaluateString(entryScript.cx(), nsDependentString(script),
global, options, evalOptions, nullptr);
} else { } else {
// Hold strong ref to ourselves while we call the callback. // Hold strong ref to ourselves while we call the callback.
nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this)); nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this));