I've got an addon with a working callback construct:
lib/main.js:
function myLogin(loginname,loginfield) {
var pageUrl = tabs.activeTab.url;
var data = require("sdk/self").data;
var worker=tabs.activeTab.attach({
contentScriptFile: data.url("content.js"),
onAttach: function(worker) {
console.log("pageMod.onAttach");
}
});
worker.port.emit("doLogin", loginfield);
}
data/content.js:
self.port.on("doLogin", function(loginfield) {
document.getElementById(loginfield).value="moo";
document.getElementById(loginfield).focus();
showSignInCaptcha();
});
I've got that all triggered by a button click in a sidebar.html which is not described here, I'll end up calling myLogin(). loginfield is a field on a website that is open in a tab. showSignInCaptcha() is a Javascript routine that is provided by the website open in the tab.
What is working / not working:
- I can fill the login field with "moo"
- I cannot call the function showSignInCaptcha()
How can I make that function call work?