JavaScript doesn't run in Popup page in Temporary Extention

I’m trying to make a simple extension, but can’t get any of my JavaScript to run. Yes, I did put it in a .js file. Here is my code.

I install this using about:debugging, click Inspect, Disable Popup Auto-Hide, click on my extensions button, the popup shows up, so does it’s html in the Inspector. So far so good, but my console.log never prints to the console. The Debugger says This page has no sources.. If I right-click popup.js in Inspector and click Open File in Debugger., it opens in a new tab with a url like this view-source:moz-extension://73dc4249-14d4-4b56-9ffe-b39460fa969c/popup.js instead. So I can’t run any JavaScript, nor can I debug it, but the browser does find it at least. I tried this on a new Firefox profile on Firefox 101.

I’m probably missing something obvious, but can’t figure out what…

1 Like

First of all, thank you for linking to a complete version of your extension. Even if it’s just a small one.
Most newbies don’t realize that the best way to talk about code, is to post the (complete) code.
(plus, the “Upload” icon isn’t very prominent, and AFAIK you can’t upload anything in your first few posts)

When you add a background script to your extension (even if it contains no code), the console.log() messages from popup.js will get printed to the console.
I have no idea why.

popup.zip (1.0 KB)

That’s strange. You’re right that my logs appear in the console when I add a blank background script. Still, none of my scripts show up in the debugger. It just says This page has no sources. even when I switch to the popup.html page in the toolbox. Even though the script is right there in the inspector.

This is starting to seem like unintended behavior. Should I file a bug report or something?

Try to install Firefox ESR 91 to see if it works there.
There are some new bugs in the current debugger.

popup.js appears in the debugger after you click on the extension icon to open the popup.
But only in the updated version of your extension that contains a background script.
I’m using Firefox 101.0.

Hmm. It appears in the debugger, but if you switch your view to popup.html from _generated_background_page.html using the page selector, it disappears. Doesn’t reappear when switching back.

I’m installing Firefox ESR, will report back.

Alright so on ESR it appears that a background script isn’t necessary for the logs to appear, but the page selector still blanks the debugger.

You probably know from another thread, but you usually need to make popups sticky in order to interact with any of the developer tools while it’s open:

Fx101-extension-inspector-disable-popup-auto-hide