Firefox 扩展开发 firefox4

发布于 2024-09-28 14:42:00 字数 1055 浏览 8 评论 0原文

因此,我一直在努力更新旧扩展以与 FF4 和 Gecko 2 一起使用,但我遇到了一些问题,我收到一条错误消息,提示组件的 classID 丢失或不正确......

还有其他人遇到类似问题吗?知道如何解决这个问题吗?

function jsshellClient() {
  this.classDescription = "sdConnector JavaScript Shell Service";
  this.classID = Components.ID("{54f7f162-35d9-524d-9021-965a3ba86366}");
  this.contractID = "@activestate.com/SDService?type=jsshell;1"
  this._xpcom_categories = [{category: "sd-service", entry: "jsshell"}];
  this.name = "jsshell";
  this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
      .getService(Components.interfaces.nsIPrefService)
      .getBranch("sdconnector.jsshell.");
  this.enabled = this.prefs.getBoolPref("enabled");
  this.port = this.prefs.getIntPref("port");
  this.loopbackOnly = this.prefs.getBoolPref("loopbackOnly");
  this.backlog = this.prefs.getIntPref("backlog");
}
jsshellClient.prototype = new session();
jsshellClient.prototype.constructor = jsshellClient;

当为此在原型上调用generateNSGetFactory时,它会在FF4的错误控制台中给出一个错误,抱怨classID。我很确定没有其他东西使用相同的 GUID,所以我没有看到问题。

So I've been working on updating old extensions for use with FF4 and Gecko 2 but I am having some issues where I am getting an error that says, classID missing or incorrect for component....

Has anyone else had a similar issue or know of how to get around this?

function jsshellClient() {
  this.classDescription = "sdConnector JavaScript Shell Service";
  this.classID = Components.ID("{54f7f162-35d9-524d-9021-965a3ba86366}");
  this.contractID = "@activestate.com/SDService?type=jsshell;1"
  this._xpcom_categories = [{category: "sd-service", entry: "jsshell"}];
  this.name = "jsshell";
  this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
      .getService(Components.interfaces.nsIPrefService)
      .getBranch("sdconnector.jsshell.");
  this.enabled = this.prefs.getBoolPref("enabled");
  this.port = this.prefs.getIntPref("port");
  this.loopbackOnly = this.prefs.getBoolPref("loopbackOnly");
  this.backlog = this.prefs.getIntPref("backlog");
}
jsshellClient.prototype = new session();
jsshellClient.prototype.constructor = jsshellClient;

When calling generateNSGetFactory on the prototype for this it gives an error in the Error Console in FF4 complaining about the classID. I'm pretty sure that nothing else is using the same GUID so I don't see the problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

成熟稳重的好男人 2024-10-05 14:42:00

Fx4 中 JS XPCOM 组件的一个重要变化是它们现在需要在 chrome.manifest 中注册,请参阅 有关更改的文档

An important change in JS XPCOM components in Fx4 is that they now need to be registered in the chrome.manifest, see this page of documentation on the changes.

橪书 2024-10-05 14:42:00

XPCOMUtils 使用的特殊属性,如 classID、contractID 等,必须在 Class.prototype 上定义,而不是像您那样在构造函数中定义: https://developer.mozilla.org/en/XPCOMUtils.jsm#Class_declaration

至于另一个问题,您在评论中发布了,请发布在另一个问题中,如果它仍然相关,并提供必要的代码。

The special properties used by XPCOMUtils, like classID, contractID, and so on, have to be defined on Class.prototype, not in the constructor function, as you did: https://developer.mozilla.org/en/XPCOMUtils.jsm#Class_declaration

As for the other question, you posted in a comment, please post it in a different question, if it's still relevant, with the necessary code provided.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文