[The following Firefox tests were on Windows 7]
As fyi... I copied your code and it does not work in Firefox 68.0.2. The browser does nothing. I also made sure of the settings[0] in about:config and browser.urlbar.filter.javascript=false -- and it still doesn't work.
As a lark, I also tried it on an older 57.0.1 and it works fine there. (Dialog popup appears to let you enter a number.) To add to the strangeness, it works even though browser.urlbar.filter.javascript=true
So something changed (security setting?) in Firefox between 57.0.1 and 68.0.2. Whatever the magic incantation is to make javascript bookmarklets work in the latest Firefox the same way it does in Chrome, my google-fu hasn't found it. Until then, I have to use Chrome.
(Other Firefox users said they had to install a browser extension to make javascript work in the url bar. I'd rather run plain Firefox instead of installing any extra extensions.)
[0] https://n8henrie.com/2017/11/how-to-open-javascript-bookmark...