4

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?

1 Answer 1

2

Figured it out:

        unsafeWindow.showSignInCaptcha();

does the job. Found that in the SDK docs: Access objects defined by page scripts

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.