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') {
  chrome.scripting.executeScript({
    target: {tabId: id},
    func: () =>
      JSON.stringify({
        url: window.location.href,
        header: document.contentType,
        loaded: !!window.state,
      })
  }, (res) => {
    console.log(chrome.runtime.lastError)
  })
}

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: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript ?

Thanks.

Wait, it seems to be working on gitlab and bitbucket, but not on rawgithubusercontent.com 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 https://bugzilla.mozilla.org/show_bug.cgi?id=1411641 for updates.