【发布时间】:2014-11-01 10:55:47
【问题描述】:
我正在使用 Addon SDK 创建我的第一个 Firefox 扩展,但我无法让我通过 console.log() 传递的消息出现在我的调试器中。
我在 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 开发者工具的控制台中都没有出现日志消息。
我在这里做错了什么?日志消息在哪里?
【问题讨论】:
标签: firefox firefox-addon firefox-addon-sdk