1

I have successfully compiled and created npapi dll in MS based on mozilla npruntime project. Reference from: https://developer.mozilla.org/en-US/docs/Compiling_The_npruntime_Sample_Plugin_in_Visual_Studio. Starting mozilla and open about:plugins shows the plugin. But when I open "test.html" the plugin does'nt come up.

I have tested the dll by making a separate test app, where i can access the entry point functions through NP_INIT l_pInit= (NP_INIT)GetProcAddress(hModule, "NP_Initialize"); and i am able to step into my plugin dll function.

But with mozilla it doesn't work. Please suggest.

Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
manav
  • 53
  • 5
  • If it doesn't show up in about:plugins (does it?) you might be missing the resource file entries or they might be incorrect (e.g. [using the wrong locale](http://stackoverflow.com/questions/13859882/npapi-plugin-does-not-get-loaded-in-firefox)). – Georg Fritzsche May 31 '13 at 17:31

3 Answers3

0

You can debug directly the mozilla process. Just attach to the process. However, modern browsers uses separate process for loading the third party plugins, so you will have to attach to that process. Than you can set breakpoints to loading routine (NP_GetEntryPoints, NP_Initialize) and see what is happening in there.

Also, if you have trouble with attaching to the process, you can simply show debug dialogs from your code and narrow the problem area.

UPDATE 1:

It seems like the browser does nto know that it should use the plugin. Did you specify the MIME type of hwat your plugin is for? If so, run the following script in an HTML page:

   <embed type="application/x-my-extension" id="pluginId">
   <script>
    var plugin = document.getElementById("pluginId");
    var result = plugin.myPluginMethod();  // call a method in your plugin
    console.log("my plugin returned: " + result);
   </script>

x-my-extensionreplace with your extension which you used in NP_GetMimeDescription. You shoudl check in about:plugins if the browser registered your plugin correctly for correct MIME type. enter image description here

Ondrej Peterka
  • 3,349
  • 4
  • 35
  • 49
  • Mozilla has plugin-container.exe that loads plugin. But when i run mozilla browser, i cannot see it running in the process list. Attaching to firefox.exe does'nt work nor debugging through command and argument option in VS. Debug messages appears when using my test application but not with mozilla. – manav May 31 '13 at 08:53
0

Sounds like there is most likely something wrong in your plugin initialization; you might try using FireBreath to create a npapi plugin, as it will be a lot less work and work on IE as well. If you don't like that idea, you could look at other npapi plugins (including FireBreath) to make sure you're doing things correctly. Add logging (of whichever type you like) to the main entrypoints and see which point it fails at.

Another trick is to go to about:config and find the plugins ipc settings and disable them; then you can attach to the main firefox process and it should hit your breakpoints if they are being called.

See the FireBreath Debugging Plugins page for other ideas.

taxilian
  • 14,229
  • 4
  • 34
  • 73
0

Thanks guyz. Finally i am able to load and access the functionality of my plugin in the browser. Following are the findings:- 1. Even though my plugin's MIME type in resource file was 'application/mozilla-npruntime-scriptable-plugin'. But i need to access it from javascript embed element through 'application/x-npruntime-scriptable-plugin'. After this step the debugger started breaking on my plugin's break points. 2. The check of size of NPPluginFuncs and NPNetscapeFuncs was failing, may be because of different version of NPAPI implemented in my firefox. At the end i got startup and thank you all for your support.

manav
  • 53
  • 5