зеркало из https://github.com/mozilla/gecko-dev.git
Bug 978042 - Part 6: AutoPushJSContext in nsNPAPIPlugin.cpp _evaluate. r=bholley
This commit is contained in:
Родитель
7742334529
Коммит
8488284f48
|
@ -63,6 +63,7 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsJSNPRuntime.h"
|
||||
#include "nsIHttpAuthManager.h"
|
||||
#include "nsICookieService.h"
|
||||
|
@ -1484,11 +1485,13 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
|
|||
nsIDocument *doc = GetDocumentFromNPP(npp);
|
||||
NS_ENSURE_TRUE(doc, false);
|
||||
|
||||
AutoPushJSContext cx(GetJSContextFromDoc(doc));
|
||||
NS_ENSURE_TRUE(cx, false);
|
||||
nsGlobalWindow* win = static_cast<nsGlobalWindow*>(doc->GetInnerWindow());
|
||||
if (NS_WARN_IF(!win || !win->FastGetGlobalJSObject())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptContext> scx = GetScriptContextFromJSContext(cx);
|
||||
NS_ENSURE_TRUE(scx, false);
|
||||
AutoSafeJSContext cx;
|
||||
JSAutoCompartment ac(cx, win->FastGetGlobalJSObject());
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, nsNPObjWrapper::GetNewOrUsed(npp, cx, npobj));
|
||||
|
||||
|
@ -1553,9 +1556,9 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
|
|||
options.setFileAndLine(spec, 0)
|
||||
.setVersion(JSVERSION_DEFAULT);
|
||||
JS::Rooted<JS::Value> rval(cx);
|
||||
nsresult rv = scx->EvaluateString(utf16script, obj, options,
|
||||
/* aCoerceToString = */ false,
|
||||
rval.address());
|
||||
nsJSUtils::EvaluateOptions evalOptions;
|
||||
nsresult rv = nsJSUtils::EvaluateString(cx, utf16script, obj, options,
|
||||
evalOptions, rval.address());
|
||||
|
||||
return NS_SUCCEEDED(rv) &&
|
||||
(!result || JSValToNPVariant(npp, cx, rval, result));
|
||||
|
|
Загрузка…
Ссылка в новой задаче