From bc296f37929b762850ce2c3b317f8542bdace2a1 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Wed, 27 May 2009 09:26:58 +0000 Subject: Added support for constructor calls in the NPAPI. The LiveConnect test cases at http://java.sun.com/javase/6/webnotes/6u10/plugin2/liveconnect/LiveConnectTests/ now pass for Chromium. Parts of this change is rather mechanical, and leaves room for some refactoring afterwards. Merged the implementation of testConstruct and the "objectPointer" property from WebKit\WebKitTools\DumpRenderTree\TestNetscapePlugIn.subproj\TestObject.cpp to the Chromium TestObject.cpp for the layout test LayoutTests\plugins\netscape-construct.html pass. BUG=http://crbug.com/3285 BUG=http://crbug.com/10354 TEST=http://java.sun.com/javase/6/webnotes/6u10/plugin2/liveconnect/LiveConnectTests/ TEST=LayoutTests\plugins\netscape-construct.html Review URL: http://codereview.chromium.org/113823 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16979 0039d316-1c4b-4281-b951-d872f2087c98 --- .../tools/npapi_layout_test_plugin/TestObject.cpp | 38 +++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'webkit/tools/npapi_layout_test_plugin/TestObject.cpp') diff --git a/webkit/tools/npapi_layout_test_plugin/TestObject.cpp b/webkit/tools/npapi_layout_test_plugin/TestObject.cpp index 659da76..edf3a856 100644 --- a/webkit/tools/npapi_layout_test_plugin/TestObject.cpp +++ b/webkit/tools/npapi_layout_test_plugin/TestObject.cpp @@ -34,6 +34,8 @@ static bool testHasProperty(NPObject *obj, NPIdentifier name); static bool testGetProperty(NPObject *obj, NPIdentifier name, NPVariant *variant); static NPObject *testAllocate(NPP npp, NPClass *theClass); static void testDeallocate(NPObject *obj); +static bool testConstruct(NPObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result); + static NPClass testClass = { NP_CLASS_STRUCT_VERSION, @@ -47,7 +49,8 @@ static NPClass testClass = { testGetProperty, 0, 0, - testEnumerate + testEnumerate, + testConstruct }; NPClass *getTestClass(void) @@ -63,11 +66,14 @@ int getTestObjectCount(void) { static bool identifiersInitialized = false; -#define NUM_TEST_IDENTIFIERS 4 -#define ID_PROPERTY_FOO 0 -#define ID_PROPERTY_BAR 1 -#define ID_PROPERTY_TEST_OBJECT 2 -#define ID_PROPERTY_REF_COUNT 3 +#define NUM_ENUMERABLE_TEST_IDENTIFIERS 4 +#define NUM_TEST_IDENTIFIERS 5 + +#define ID_PROPERTY_FOO 0 +#define ID_PROPERTY_BAR 1 +#define ID_PROPERTY_TEST_OBJECT 2 +#define ID_PROPERTY_REF_COUNT 3 +#define ID_PROPERTY_OBJECT_POINTER 4 static NPIdentifier testIdentifiers[NUM_TEST_IDENTIFIERS]; static const NPUTF8 *testIdentifierNames[NUM_TEST_IDENTIFIERS] = { @@ -75,6 +81,7 @@ static const NPUTF8 *testIdentifierNames[NUM_TEST_IDENTIFIERS] = { "bar", "testObject", "refCount", + "objectPointer", }; static void initializeIdentifiers(void) @@ -144,17 +151,30 @@ static bool testGetProperty(NPObject *obj, NPIdentifier name, } else if (name == testIdentifiers[ID_PROPERTY_REF_COUNT]) { INT32_TO_NPVARIANT(obj->referenceCount, *variant); return true; + } else if (name == testIdentifiers[ID_PROPERTY_OBJECT_POINTER]) { + int32_t objectPointer = static_cast(reinterpret_cast(obj)); + INT32_TO_NPVARIANT(objectPointer, *variant); + return true; } return false; } static bool testEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count) { - *count = NUM_TEST_IDENTIFIERS; + *count = NUM_ENUMERABLE_TEST_IDENTIFIERS; + + *value = (NPIdentifier*)browser->memalloc(NUM_ENUMERABLE_TEST_IDENTIFIERS * sizeof(NPIdentifier)); + memcpy(*value, testIdentifiers, sizeof(NPIdentifier) * NUM_ENUMERABLE_TEST_IDENTIFIERS); - *value = (NPIdentifier*)browser->memalloc(NUM_TEST_IDENTIFIERS * sizeof(NPIdentifier)); - memcpy(*value, testIdentifiers, sizeof(NPIdentifier) * NUM_TEST_IDENTIFIERS); + return true; +} + +static bool testConstruct(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result) +{ + browser->retainobject(npobj); + // Just return the same object. + OBJECT_TO_NPVARIANT(npobj, *result); return true; } -- cgit v1.1