This test was build for unix and was only tested in Fedora 20 but it should work on other distros as well. 1. Dependencies: - scons - NPAPI headers (Package xulrunner-devel, npapi-sdk or firefox-dev depending of the distro) 2. Compile sources Run command: scons 3. Install plugin Copy the shared library to /usr/lib/mozilla/plugins or use other described ways to install NPAPI plugins. 4. Test the plugin There is a file test.html which reproduces the test case. 5. Issue description I have one plugin which can create two types of instances and I can add one to another using JavaScript. I create one in HTML and the other one in JS. Example:
The problem which I am having is that NPN_Invoke for object a is called before NPP_New for object b. This is also visible in the invoke function because the _class member of the object which is given in the add function still has the default values. If I call getId function of b than the NPP_New for object b is called before NPN_Invoke of object a. The id association is done by trying to call a function of the object with NPN_Invoke: C++: NPIdentifier identifier = NPN_GetStringIdentifier(GETID); if (!NPN_Invoke(npp, object, identifier, 0, 0, &variant)) { return 0; } obj = Manager.get(NPVARIANT_TO_INT32(variant); The problem disappears when dom.ipc.plugins.enabled is set to false. 6. C++ implementation description Classes: *BasicScriptableObject* Abstract implementation of a scriptable object and sets the class attribute of the NPObject. Used to make NPAPI easier to use in OOP. *Manger* Creates instances of of type application/x-a and application/x-b. In development it also maintains an id association which is removed here to simplify the test. *PluginA* Contains the implementation of a application/x-a type plugin. The only method which can be called on the object is "add". *PluginB* Contains the implementation of a application/x-b type plugin. The only method which can be called on the object is "getId". Other files: NpapiPluginFunctions.cpp NpapiEntryPoint.cpp NpapiNetscapeFunctions.cpp This 3 files contain the implementation of the NPAPI interface.