How to debug a script

Hello there!

I am writing a new script to check email for my provider, which is based on XandMail (the same as Aruba). The following works but I got here by trial and error. I want to know if there is a possibility to debug the script by dumping it's internal variables at some stage. See comment below.

Can you help?

Script:

/**********************************************************
email-pro , da Aruba.it
**********************************************************/
var name="email-pro.eu";
var ver="2014-03-08-c";

function init(){
  this.loginData=["https://webmail.email-pro.eu/authenticate.php","login","password","lang=it&theme=ext_alicom%2Fclassic.share=&USEHTMLTPL="];
  //this.cookieDomain="email-pro.eu";
}
function getCount(aData){
  var fnd=aData.match(/b64name:"SU5CT1g=".+?unreadMsgs:"(\d+)"/);
  if(fnd){
    return fnd[1];
  }else{
    return -1;
  }
}
function process(aData,aHttp) {
  switch(this.stage){
  case ST_LOGIN_RES:
    var fnd=aData.match(/url:"(\S+?ID=(\S+?)&\S+?)"/);
    if(fnd){
      //I want to dump aData and fnd HERE
      this.dataURL="https://webmail.email-pro.eu/cgi-bin/ajaxmail?Act_Folders=1&ImapReq=0&fldinfo=1&Tpl=mailinfo&ID="+fnd[2];
      this.viewURL=fnd[1].replace("www1.dc.xandmail.com", "webmail.email-pro.eu");
      this.stage=ST_DATA;
    }
    break;
  }
  return this.baseProcess(aData,aHttp);
}

tobwithu's picture

'Components.utils.reportError' will show messages in Browser Console