我使用Addon SDK创建了我的第一个Firefox扩展,但是我无法获取与console.log()一起传递的消息以显示在我的调试器中。console.log()消息不会从Firefox插件中显示
我在Firefox 33中创建了一个新的配置文件,并安装了最新版本的Firebug。当我使用cfx run -p <My_Profile_Directory>
启动插件时,我可以看到Firebug和我的插件,并且插件做它应该做的事情。不过,我没有看到任何地方的消息我写了使用console.log()
命令
这里是我的main.js至今登录:
function loginToSite(user, password) {
var Request = require("sdk/request").Request;
var doLogin = Request(
{
url: "https://website.com/login/index.php",
contentType: "application/x-www-form-urlencoded",
content: "username=xxxx&password=xxxx&remember=1",
onComplete: function(response) {
console.log(response.text);
}
}
);
doLogin.post();
}
function checkLoginStatus(tab) {
//TODO Actually check if the tab is logged in, currently assume it's not
loginToSite(0,0);
}
// Listens for tabs and checks each loaded tab if it's the website
tabs.on("ready", function(tab) {
var tabUrl = tab.url.toLowerCase();
if(tabUrl.contains("website.com")) {
console.log("Not connected to website.com, running login procedure");
checkLoginStatus(tab);
}
});
就像我说的,我确实被自动登录,但Firebug或Firefox Developer Tools控制台中不会显示日志消息。
我在这里做错了什么?日志消息在哪里?