diff options
author | sgjesse@chromium.org <sgjesse@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 09:26:58 +0000 |
---|---|---|
committer | sgjesse@chromium.org <sgjesse@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 09:26:58 +0000 |
commit | bc296f37929b762850ce2c3b317f8542bdace2a1 (patch) | |
tree | 7ae61fc12388c1c2cc8ae20974d1e78ecb94b45f /webkit/tools/npapi_layout_test_plugin/TestObject.cpp | |
parent | 9c5e417def0fef57d5dc79b0348dab9b0d354d42 (diff) | |
download | chromium_src-bc296f37929b762850ce2c3b317f8542bdace2a1.zip chromium_src-bc296f37929b762850ce2c3b317f8542bdace2a1.tar.gz chromium_src-bc296f37929b762850ce2c3b317f8542bdace2a1.tar.bz2 |
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
Diffstat (limited to 'webkit/tools/npapi_layout_test_plugin/TestObject.cpp')
-rw-r--r-- | webkit/tools/npapi_layout_test_plugin/TestObject.cpp | 38 |
1 files changed, 29 insertions, 9 deletions
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<int32_t>(reinterpret_cast<long long>(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; } |