我已經在Firefox擴展開發近日,並且遇到了一些問題:如何調試Firefox擴展
所以,在browser.xul我定義了這些線:
<overlay id="sample" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="jquery.js" />
<script src="global.js" />
</overlay>
所以,在全球.js文件我可以訪問所有的jQuery的東西,並試圖加載有一個簡單的腳本:
var inner = null;
var o = function() {
var prefManager = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
return {
init : function() {
alert('here loading inner..');
$.get('http://www.example.com/script.js', function(d) {
alert('loaded inner script!');
inner = d;
gBrowser.addEventListener("load", function() {
alert('onload');
}, false);
}).error(function(e) { alert('error loading inner..'); setTimeout(o.init,1000); });
$(this).ajaxError(function() { alert('ajaxError'); });
}
}
}
window.addEventListener("load", o.init, false);
但也不是我收到一個「裝內腳本」,也不是「錯誤加載內部」警告..我不要看不到錯誤c鞋墊記錄擴展中的任何錯誤...我假設$.get
由於某些限制可能會導致默認失敗,但是有沒有適當的方法來正常調試錯誤?錯誤控制檯是沉默的擴展,只顯示網頁錯誤
亞歷克斯,我真的希望你不是實際評估這XHR結果得到的腳本,對不對? –
是的,但主要是因爲插件被製成「autoupdatable」 - 我知道這是不好的,我從來沒有這樣做在日常生活中,但在這個特定的項目,我不得不 –
的一點是,如果你這樣做,那麼您正在向瀏覽器引入安全漏洞。例如,任何人在不受信任的WiFi連接上使用這樣的瀏覽器,都允許wifi路由器將任意腳本注入到Chrome中。至少在這裏使用SSL! –