Back out bug 653083 because of crashtest crashes (bug698862.html) in PluginInstanceParent::GetNPP for a crashed plugin

This commit is contained in:
Benjamin Smedberg
2011-06-16 13:22:24 -04:00
parent 2e43a3b279
commit db0bb30d65
18 changed files with 143 additions and 623 deletions

View File

@@ -39,16 +39,12 @@
#include "PluginScriptableObjectParent.h"
#include "PluginScriptableObjectUtils.h"
#include "nsNPAPIPlugin.h"
#include "mozilla/unused.h"
using namespace mozilla::plugins;
using namespace mozilla::plugins::parent;
namespace {
typedef PluginIdentifierParent::StackIdentifier StackIdentifier;
inline void
ReleaseVariant(NPVariant& aVariant,
PluginInstanceParent* aInstance)
@@ -59,6 +55,32 @@ ReleaseVariant(NPVariant& aVariant,
}
}
inline PPluginIdentifierParent*
GetIdentifier(PluginInstanceParent* aInstance,
NPIdentifier aIdentifier)
{
PluginModuleParent* module = aInstance->Module();
if (!module) {
NS_WARNING("Huh?!");
return false;
}
return module->GetIdentifierForNPIdentifier(aIdentifier);
}
inline PPluginIdentifierParent*
GetIdentifier(NPObject* aObject,
NPIdentifier aIdentifier)
{
PluginInstanceParent* instance = GetInstance(aObject);
if (!instance) {
NS_WARNING("Huh?!");
return false;
}
return GetIdentifier(instance, aIdentifier);
}
} // anonymous namespace
// static
@@ -132,7 +154,7 @@ PluginScriptableObjectParent::ScriptableHasMethod(NPObject* aObject,
return false;
}
StackIdentifier identifier(aObject, aName);
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
if (!identifier) {
return false;
}
@@ -172,7 +194,7 @@ PluginScriptableObjectParent::ScriptableInvoke(NPObject* aObject,
return false;
}
StackIdentifier identifier(aObject, aName);
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
if (!identifier) {
return false;
}
@@ -274,7 +296,7 @@ PluginScriptableObjectParent::ScriptableHasProperty(NPObject* aObject,
return false;
}
StackIdentifier identifier(aObject, aName);
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
if (!identifier) {
return false;
}
@@ -323,7 +345,7 @@ PluginScriptableObjectParent::ScriptableSetProperty(NPObject* aObject,
return false;
}
StackIdentifier identifier(aObject, aName);
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
if (!identifier) {
return false;
}
@@ -366,7 +388,7 @@ PluginScriptableObjectParent::ScriptableRemoveProperty(NPObject* aObject,
return false;
}
StackIdentifier identifier(aObject, aName);
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
if (!identifier) {
return false;
}
@@ -1074,23 +1096,8 @@ PluginScriptableObjectParent::AnswerEnumerate(InfallibleTArray<PPluginIdentifier
return true;
}
JSContext* cx = GetJSContext(instance->GetNPP());
JSAutoRequest ar(cx);
for (uint32_t index = 0; index < idCount; index++) {
// Because of GC hazards, all identifiers returned from enumerate
// must be made permanent.
if (_identifierisstring(ids[index])) {
JSString* str = NPIdentifierToString(ids[index]);
if (!JS_StringHasBeenInterned(cx, str)) {
JSString* str2 = JS_InternJSString(cx, str);
NS_ASSERTION(str2 == str, "Interning a JS string which is currently an ID should return itself.");
}
}
PluginIdentifierParent* id =
instance->Module()->GetIdentifierForNPIdentifier(instance->GetNPP(), ids[index]);
aProperties->AppendElement(id);
NS_ASSERTION(!id->IsTemporary(), "Should only have permanent identifiers!");
aProperties->AppendElement(GetIdentifier(instance, ids[index]));
}
npn->memfree(ids);
@@ -1261,7 +1268,7 @@ PluginScriptableObjectParent::GetPropertyHelper(NPIdentifier aName,
return JS_FALSE;
}
StackIdentifier identifier(GetInstance(), aName);
PPluginIdentifierParent* identifier = GetIdentifier(GetInstance(), aName);
if (!identifier) {
return JS_FALSE;
}