Bug 1047509 - Part 1: Replace nsCxPusher in nsJSNPRuntime.cpp doInvoke. r=bholley

This commit is contained in:
Bob Owen 2014-08-08 09:01:45 +01:00
Родитель 36eb73ceed
Коммит 3e1c0c8724
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -12,6 +12,7 @@
#include "nsJSNPRuntime.h"
#include "nsNPAPIPlugin.h"
#include "nsNPAPIPluginInstance.h"
#include "nsIGlobalObject.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsDOMJSUtils.h"
@ -608,12 +609,17 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
uint32_t argCount, bool ctorCall, NPVariant *result)
{
NPP npp = NPPStack::Peek();
JSContext *cx = GetJSContext(npp);
if (!cx) {
nsCOMPtr<nsIGlobalObject> globalObject = GetGlobalObject(npp);
if (NS_WARN_IF(!globalObject)) {
return false;
}
// We're about to run script via JS_CallFunctionValue, so we need an
// AutoEntryScript. NPAPI plugins are Gecko-specific and not in any spec.
dom::AutoEntryScript aes(globalObject);
JSContext *cx = aes.cx();
if (!npobj || !result) {
ThrowJSException(cx, "Null npobj, or result in doInvoke!");
@ -625,8 +631,6 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
nsCxPusher pusher;
pusher.Push(cx);
JS::Rooted<JSObject*> jsobj(cx, npjsobj->mJSObj);
JSAutoCompartment ac(cx, jsobj);
JS::Rooted<JS::Value> fv(cx);