I'm having problems with a very simple popup code in a Crossrider extension and Firefox (tested on 35.0.1 and 25.0.1 but I'm pretty sure it's the same thing on other versions as well).
Here's extension.js
appAPI.ready(function($) {
randNumber = Math.floor((Math.random() * 1000) + 1);
appAPI.message.toBackground({
msgRand: randNumber
});
});
And this is background.js
appAPI.ready(function($) {
appAPI.message.addListener(function(msg) {
randomNumber = msg.msgRand;
appAPI.browserAction.setResourceIcon('icon.png');
appAPI.browserAction.setPopup({
html: '<h1>' + randomNumber + '</h1>',
height: 300,
width: 300
});
});
});
The code above is supposed to display a random number between 1 and 1000 but it works only the first time the button is clicked and from then on it keeps showing the same number no matter whether I open a link in the same tab or in a new tab. The only time the number changes is when I open a new window (but if I open a new link in the same window or a new tab in that window the number is still the same as the one initially displayed for the window). For example if I open a site in window 1 and click the extension's button it could display 111. Every other link I open in this window will always display 111 when I click the button. If I open another window while window 1 is open it might show 555 when I click the button and that will be the number for every new tab in this window.
I've tried the same code in Chrome (SRWare Iron to be precise) and IE 11 and everything seems to work as expected.
I'm also pretty sure that the problem is coming from the setPopup portion of the code, because I've tried to display the value of randomNumber via alert and it was different every time (plus the code works in IE and Chrome (haven't tested it in Safari yet)).
Here's the extension ID in case it might help - 72164
P.S. My English skills are a bit rusty, so let me know if I haven't explained something correctly.