I am following an example from Mozilla Docs
tabs.on('activate', function(tab) {
tab.attach({
contentScript: 'self.postMessage(document.body.innerHTML);',
onMessage: function (message) {
console.log(message);
}
});
});
with a little modification like this.
var bodyHTML;
tabs.on('activate', function(tab) {
tab.attach({
contentScript: 'self.postMessage(document.body.innerHTML);',
onMessage: function (message) {
bodyHTML = message;
console.log("From attach : " + bodyHTML);
}
});
});
console.log("After tab : " + bodyHTML);
Now when I execute this addon, console.log("After tab : " + bodyHTML); is getting executed first and then console.log("From attach : " + bodyHTML);. What could be the issue and how can I order the sequence of execution?