我用
Components.classes["@mozilla.org/network/cache-service;1"].getService(Components.interfaces.nsICacheService);
在开发Firefox扩展时操作http缓存。
但是在我升级到Firefox 38 esr之后,这个界面在调用它的函数时会抛出错误
[Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsICacheService.visitEntries]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)"
我在MDN中没有发现它已经过时了,所以谁知道为什么?非常感谢。
答案 0 :(得分:1)
http://code.metager.de/source/xref/mozilla/firefox/netwerk/cache/nsICacheService.idl
这看起来像一个暗示 *当优先使用缓存v2时,@throws NS_ERROR_NOT_IMPLEMENTED。
https://bugzilla.mozilla.org/show_bug.cgi?id=913807
我认为我们需要做的就是在
中的这一行改变1到2var cacheService = cc [“@ mozilla.org/network/cache-service;1”] .getService(ci.nsICacheService);
答案 1 :(得分:0)
我尝试了这段代码并抛出:(在浏览器环境中使用scratchcpad复制粘贴 - https://www.youtube.com/watch?v=oo4STWceGTM)
var cacheService = Cc["@mozilla.org/network/cache-service;1"].getService(Ci.nsICacheService);
console.log('cacheService:', cacheService);
function CacheVisitor(){}
CacheVisitor.prototype = {
QueryInterface : function(iid)
{
if (iid.equals(Ci.nsICacheVisitor))
return this;
throw Components.results.NS_NOINTERFACE;
},
visitDevice : function(deviceID, deviceInfo)
{
console.log("[visiting device (deviceID = ", deviceID ,", description = ", deviceInfo.description ,")]");
return true;
},
visitEntry : function(deviceID, entryInfo)
{
console.log("[visiting entry (clientID = ", entryInfo.clientID, "key = ", entryInfo.key, ")]");
return true;
}
};
var visitor = new CacheVisitor();
cacheService.visitEntries(visitor); // throws on this line here!!!
它抛出行cacheService.visitEntries(visitor); // throws on this line here!!!
它会抛出这个:
/*
Exception: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsICacheService.visitEntries]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: Scratchpad/1 :: <TOP_LEVEL> :: line 27" data: no]
*/
这是你看起来像的问题。你可以验证一下,我看不到你的可重复代码。