I'm writing a WebExtension where a background script communicates between a popup window (UI script) and web pages (content script).
Using port = browser.runtime.connect({name: "ProjName"});
, the content script connects to the background script as soon as it loads.
The background script registers that:
function connected(p) {
...
console.log(p.sender.tab.id); // <-- works fine, gives me an integer Tab ID
browser.tabs.insertCSS(p.sender.tab.id, {file : "/css/stylesheetName.css"});
...
}
browser.runtime.onConnect.addListener(connected);
and tries to insertCSS()
, using the sending tab's ID.
I always get the Error: No window matching {"matchesHost":[]}
message.
I'm not sure what's happening here, I'm not sure what part of the script is now matching against a host...?!?
I can use browser.tabs.sendMessage(p.sender.tab.id, msg);
just fine in exactly the same place. Hell, if I knew how to reliably read the file from disk, I would send its contents over via sendMessage
at this point.
Where might this be coming from?
Edit: I've stripped it down to only the necessary code (and no page_Action, no popup, etc) and uploaded a .zip: [removed] Which you can Load as Temporary Add-On on the firefox about:debugging page.