如何测试我的 npapi 代码(即 xpcom 到我的 firefox 插件的 npruntime 更改)?
我已经通过从 xpcom 迁移到 npruntime 更新了我的 Firefox 插件,以便与最新版本的 Firefox(3.6 及更高版本)配合使用。
在这样做的同时,我编写了几个包装器,测试我的代码的唯一方法似乎是通过 javascript。
有人可以建议另一种方法来测试我的辅助对象吗?还有其他类型的测试可能有用吗?
I have updated my firefox plugin to work with latest versions of firefox (3.6 and higher) by moving from xpcom to npruntime.
While doing this I have written several wrappers and the only way to test my code seems to be through javascript.
Could someone suggest another way to test my helper objects? Are there any other types of tests that may be useful here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将重复我在回答您的其他问题时给您的建议,建议您考虑使用 FireBreath 来实现此目的插件;它已经有了使 NPObjects 正常工作的包装器,并且作为 Windows 上的额外好处,您也可以在 IE 上使用您的插件。
也就是说,为 NPAPI 插件编写单元测试相当困难。根据代码的编写方式,您可以“伪造”一些重要的函数——例如内存管理函数 NPN_MemAlloc 和 NPN_MemFree——然后使用它们来编写单元测试,或者您可以编写使用网络浏览器。
FireBreath 包含一个 NPAPIHost 项目,旨在协助单元测试 NPAPI 插件,但尚未完全完成。不过,如果您愿意,您可以将其作为起点。
不过,老实说,我只想使用 FireBreath,然后您就可以专注于自己的代码,而不是尝试编写和维护自己的脚本系统抽象。
I will repeat the advice I gave you in my answer to your other question by suggesting that you look at using FireBreath for this plugin; it already has the wrappers to make NPObjects work well and as an added bonus on windows you can use your plugin on IE also.
That said, writing unit tests for a NPAPI plugin is fairly difficult. Depending on how your code is written you could "fake out" a few of the important functions -- such as the memory management functions NPN_MemAlloc and NPN_MemFree -- and then use those to write unit tests, or you could write automated tests that use a web browser.
FireBreath includes a NPAPIHost project that was designed to assist with unit testing NPAPI plugins, but it has not been fully completed. Still, you could use it as a starting point if you want.
Honestly, though, I would just use FireBreath and then you can focus on your own code instead of trying to write and maintain your own abstraction for the scripting system.