2010-02-08 63 views
2

我正在测试包含Firefox扩展作为一个组件的应用程序。它最初是在FF3.5.5是最新版本时部署的,并在3.5.6和3.5.7中幸存下来。然而在FF3.6我得到我的错误控制台如下:Firefox 3.6中的Components.interfaces.nsIProcess2 - 它去了哪里?

Warning: reference to undefined property Components.interfaces.nsIProcess2 
Source file: chrome://overthewall/content/otwhelper.js 
Line: 55 

Error: Component returned failure code: 0x80570018 (NS_ERROR_XPC_BAD_IID) 
     [nsIJSCID.createInstance] 
Source file: chrome://overthewall/content/otwhelper.js 
Line: 55 

引发错误的功能是:

48 function otwRunHelper(cmd, aCallback) { 
49 var file = 
50  Components.classes["@mozilla.org/file/local;1"]. 
51  createInstance(Components.interfaces.nsILocalFile); 
52 file.initWithPath(otwRegInstallDir+'otwhelper.exe'); 
53 
54 otwProcess = Components.classes["@mozilla.org/process/util;1"] 
55     .createInstance(Components.interfaces.nsIProcess2); 
56 
57 otwProcess.init(file); 
58 var params = new Array(); 
59 params = cmd.split(' '); 
60 
61 otwNextCallback = aCallback; 
62 otwObserver = new otwHelperProcess(); 
63 otwProcess.runAsync(params, params.length, otwObserver, false); 
64 } 

正如你所看到的,这一切的功能并运行一个外部EXE帮助程序文件(通过注册表项定位)以及一些命令行参数,并设置Observer以异步等待响应并处理退出代码。

违规行意味着Components.interfaces.nsIProcess2不再在FF3.6中定义。它去了哪里?我在Mozilla文档中找不到任何内容,指出它在最新版本中已被更改。

回答

5

将nsIProcess2上的方法移至nsIProcess。为了您的代码在这两种版本,改变这一行:

otwProcess = Components.classes["@mozilla.org/process/util;1"] 
       .createInstance(Components.interfaces.nsIProcess2); 

这样:

otwProcess = Components.classes["@mozilla.org/process/util;1"] 
       .createInstance(Components.interfaces.nsIProcess2 || Components.interfaces.nsIProcess); 

你仍然会得到警告,但错误会消失,你的代码将只是工作在两个版本都很好。您还可以将接口iid存储在变量中并使用变量:

+0

太棒了。谢谢!!!我错过了Mozilla文档中的一行指出这一点。 – rwired 2010-02-09 07:11:18

+2

公平地说,你没有错过它。我刚刚告诉那个因为你的问题而做出改变以更新文档的人。 :) – sdwilsh 2010-02-09 15:39:27