因此,我正在为 Firefox 开发下一个附加组件,但是,在阅读 ContextMenus 的文档时,似乎从未调用过 onMessage 事件,这是我的代码:
exports.main = function(){
var addonTab = require('addon-page');
var data = require('self').data;
var tabs = require('tabs');
var cm = require("context-menu");
cm.Item({
label: "Tag This Image",
context: cm.URLContext("*"),
contextSelector: "img",
contentScript:
'self.on("click", function(node, data){' +
' self.postMessage(node);' +
'});',
// nothing works...
onMessage: function(node){
openImageEditor(node.src);
alert("Message? It worked? No way!");
onTagImage(node);
}
});
var onTagImage = function(node){
alert("Image tagged!");
};
tabs.open({url: data.url('index.html'), isPinned:true});
};
所以我看了一下错误控制台,但这可能是我见过的最糟糕的错误格式......
时间戳:14/07/2012 3:21:44 错误:发生异常。Traceback(最近一次通话最后一次):文件“resource://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/addon-kit/lib/context-menu.js”,第 1310 行,在 CMP_handleEvent 中。处理点击(事件。目标);文件“资源://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/addon-kit/lib/context-menu.js”,第 1339 行,在 CMP_handleClick this.browserWin.fireClick(topLevelItem, popupNode, item.data); BW_fireClick worker.fireClick(popupNode, clickedItemData) 中的文件“resource://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/addon-kit/lib/context-menu.js”,第 1162 行;文件“resource://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/addon-kit/lib/context-menu.js”,第 663 行,在 CMW_fireClick this._contentWorker.emitSync("click", popupNode, clickedItemData); 文件“resource://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/api-utils/lib/content/worker.js”,第 71 行,在 emitSync return this._emitToContent(Array.slice(arguments)); 文件“resource://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/api-utils/lib/content/content-worker.js”,第 96 行,onChromeEvent 返回 emit.apply(null, args); 文件“resource://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/api-utils/lib/content/content-worker.js”,第 45 行,onEvent results.push(callback.apply(null, args)); 文件 "javascript:self.on("click", function(node, data){
self.postMessage(node);});”,第 1 行,在空文件“resource://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/api-utils/lib/content/content-worker.js”,第 81 行,在onEvent let str = JSON.stringify(args, replacer); [异常...“组件返回失败代码:0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIImageLoadingContent.loadingEnabled]”nsresult:“0x80040111 (NS_ERROR_NOT_AVAILABLE)”位置:“JS 框架 :: 资源://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/api-utils/lib/cuddlefish.js -> 资源://jid0-dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/api-utils/lib/sandbox.js -> 资源://jid0 -dxglsws2k0cubycbcn7cw5tcyqk-at-jetpack/api-utils/lib/content/content-worker.js :: onEvent :: line 81" data: no]
这是实际的线路,但这对我来说没有任何意义:
文件 "javascript:self.on("click", function(node, data){self.postMessage(node);});",第 1 行,为空
问题:这个错误是什么意思,或者说这行到底有什么问题?