summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp')
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp
index 8946c0e..9e65f11 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp
@@ -59,6 +59,13 @@ NPClass *getTestClass(void)
return &testClass;
}
+static int testObjectCount = 0;
+
+int getTestObjectCount()
+{
+ return testObjectCount;
+}
+
typedef struct {
NPObject header;
NPObject* testObject;
@@ -73,6 +80,7 @@ enum {
ID_PROPERTY_BAR,
ID_PROPERTY_OBJECT_POINTER,
ID_PROPERTY_TEST_OBJECT,
+ ID_PROPERTY_REF_COUNT,
NUM_TEST_IDENTIFIERS,
};
@@ -82,6 +90,7 @@ static const NPUTF8 *testIdentifierNames[NUM_TEST_IDENTIFIERS] = {
"bar",
"objectPointer",
"testObject",
+ "refCount",
};
#define ID_THROW_EXCEPTION_METHOD 0
@@ -102,6 +111,7 @@ static NPObject* testAllocate(NPP /*npp*/, NPClass* /*theClass*/)
{
TestObject* newInstance = static_cast<TestObject*>(malloc(sizeof(TestObject)));
newInstance->testObject = 0;
+ ++testObjectCount;
if (!identifiersInitialized) {
identifiersInitialized = true;
@@ -116,6 +126,8 @@ static void testDeallocate(NPObject *obj)
TestObject* testObject = reinterpret_cast<TestObject*>(obj);
if (testObject->testObject)
browser->releaseobject(testObject->testObject);
+
+ --testObjectCount;
free(obj);
}
@@ -169,6 +181,10 @@ static bool testGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* resul
OBJECT_TO_NPVARIANT(testObject->testObject, *result);
return true;
}
+ if (name == testIdentifiers[ID_PROPERTY_REF_COUNT]) {
+ INT32_TO_NPVARIANT(npobj->referenceCount, *result);
+ return true;
+ }
return false;
}