MV3 browser.scripting.executeScript throws Missing host permission for the tab

Hey, I’m trying to execute this script on Firefox 110:

browser.runtime.onMessage.addListener((id, info, tab) => {
if (info.status === 'loading') {
    target: {tabId: id},
    func: () =>
        url: window.location.href,
        header: document.contentType,
        loaded: !!window.state,
  }, (res) => {

but no matter what I try I cannot make it to believe me that the access to that origin was enabled. The error states that Missing host permission for the tab which could have been helpful if it was true. So I tried any combination that I can think of: enabling the specific origin in host_permissions, enabling all, adding *://*/ to optional_permissions instead and then asking the user explicitly for access to that origin using the browser.permissions.request API, and even if after all of that the permissions tab for the extension is clearly telling me that the access to that origin was enabled I just keep getting the Missing host permission for the tab error.

So at this point I’m wondering if this API works in MV3 as it is stated in the official docs: ?


Wait, it seems to be working on gitlab and bitbucket, but not on so maybe it is a CSP issue, though interestingly that same code works on Chromium as it is.

This is a known issue, not specific to MV3. Follow for updates.

1 Like

Has the issue been addressed? Wouldn’t this break all of the addons running executeScript?

1 Like

@simovelichkov out of curiosity, how did you address this issue? Thanks!

1 Like

By documenting that the extension won’t work on because of CSP limitations. Not really a solution, but since the extension can be used on other origins it sort of works, right …