Cannot access NPAPI functions in Firefox Extension

可紊 提交于 2020-01-17 04:05:29

问题


I'm having trouble getting an NPAPI plugin to load in a Firefox Extension. The way I'm doing it now is the plugin is already registered in Windows, so I load an embed element via an overlay which is injected into the chrome & accessed via window.onload. Apparently the NPAPI element is loaded but I cannot access any native functions.

Here is my main.xul:

<overlay ...>
  <window id="main-window">
    <embed type="application/x-myplugin" id="myplugin" width="300" height="300"></embed>
  </window>
</overlay>

I set the width/height values so I can see the embed inserted into the chrome.

Here is my js:

window.addEventListener("load", function () {  

  var plugin = document.getElementById("myplugin");
  dump(plugin + "\n");
  dump("version: " + plugin.version + "\n");

});

The dump:

[object XULElement]
undefined

If the same embed code was placed into an HTML document, plugin.version would return "1000". The NPAPI plugin is confirmed working as I can get it working in the HTML document and loaded in a Chrome Extension.

Is there something I'm doing wrong? Note that I have to load the NPAPI plugin inside the chrome as opposed to injecting it on demand into the page as properties will need to be retrieved from other dialog boxes separate from the web page. Perhaps there is another way to load an NPAPI plugin that can be loaded once per browser load which can be called from a Firefox Extension.

If it is any help, the NPAPI was built with the Firebreath framework.

Note: I've followed through this thread: link and obviously can get the plugin loaded but still cannot access any functions.

Thanks.


回答1:


There is no <embed> tag in XUL, you mean to use the HTML <embed> tag. Use the HTML namespace for this tag:

<embed xmlns="http://www.w3.org/1999/xhtml" ...></embed>

Additional information: https://developer.mozilla.org/en/Namespaces



来源:https://stackoverflow.com/questions/7458530/cannot-access-npapi-functions-in-firefox-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!