This source file includes following definitions.
- hasProperty
- getProperty
- NPP_New
- NPP_GetValue
- shutdown
#include "PluginTest.h"
using namespace std;
static bool wasShutdownCalled = false;
class NPDeallocateCalledBeforeNPShutdown : public PluginTest {
public:
NPDeallocateCalledBeforeNPShutdown(NPP npp, const string& identifier)
: PluginTest(npp, identifier)
{
}
private:
class TestObject : public Object<TestObject> {
public:
virtual ~TestObject()
{
if (wasShutdownCalled)
indicateTestFailure();
}
};
class ScriptableObject : public Object<ScriptableObject> {
public:
bool hasProperty(NPIdentifier propertyName)
{
return propertyName == pluginTest()->NPN_GetStringIdentifier("testObject");
}
bool getProperty(NPIdentifier propertyName, NPVariant* result)
{
if (propertyName != pluginTest()->NPN_GetStringIdentifier("testObject"))
return false;
NPObject* testObject = TestObject::create(pluginTest());
OBJECT_TO_NPVARIANT(testObject, *result);
return true;
}
};
virtual NPError NPP_New(NPMIMEType pluginType,
uint16_t mode,
int16_t argc,
char* argn[],
char* argv[],
NPSavedData* saved) OVERRIDE {
registerNPShutdownFunction(shutdown);
return NPERR_NO_ERROR;
}
virtual NPError NPP_GetValue(NPPVariable variable, void *value) OVERRIDE
{
if (variable != NPPVpluginScriptableNPObject)
return NPERR_GENERIC_ERROR;
*(NPObject**)value = ScriptableObject::create(this);
return NPERR_NO_ERROR;
}
static void shutdown()
{
wasShutdownCalled = true;
}
};
static PluginTest::Register<NPDeallocateCalledBeforeNPShutdown> npRuntimeObjectFromDestroyedPlugin("np-deallocate-called-before-np-shutdown");