"Error: Missing host permission for the tab" on view-source: URLs
Asked Answered
B

4

10

I rewrote my extension to WebExtensions for Firefox and Google Chrome, and it works fine for HTTP/HTTPS. However, it no longer works on URLs with the view-source: scheme. (These URLs are the HTML source code of web pages shown by CTRL+U.)

Firefox 57 gives this error

Error: Missing host permission for the tab

Google Chrome 62 does apparently nothing.

There is no documentation about the view-source scheme. Is there a way to enable the extension for view-source?

Burress answered 27/11, 2017 at 4:11 Comment(0)
C
3

I haven't dabbled too much in extensions but since the error involves Host permissions in firefox, check the Host permissions:

In Firefox, from version 56 onwards, extensions automatically get host permissions for their own origin, which is of the form:

moz-extension://60a20a9b-1ad4-af49-9b6c-c64c98c37920/
where 60a20a9b-1ad4-af49-9b6c-c64c98c37920 is the extension's internal ID. The extension can get this URL programmatically by

calling extension.getURL():

browser.extension.getURL("");
// moz-extension://60a20a9b-1ad4-af49-9b6c-c64c98c37920/
Crunode answered 28/11, 2017 at 16:32 Comment(5)
As I mentioned, the documentation is incomplete. It mentions HTTP/HTTPS schemes (which work fine), but it doesn't mention view-source schemes. My extension already requests permission <all_urls>, so it seems this is a limitation of the extension system and not an issue of the extensionBurress
I got "<all_urls>" too in permissions, but still get this error in my bg script when inserting a script or css. We should enter a bug reportEyla
Hmmm.. it dissappears after a re-installing the webextension. Maybe the manifest permissions don't overwrite untill you remove and re-install the extension? Still a buig, just different. (I am talking about Firefox developer edition BTW)Eyla
Anyone file a bug on the latter? In the debugger, I'm getting the error with executeScript (even on http) despite working on the active tab and with the activeTab permission...Unreel
I forgot that the activeTab permission also requires "user interaction" as per developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/… in order to grant the executeScript and other permissions for the tab.Unreel
K
0

I see the same error in a different situation:

  1. epub file opened with EPUBreader fine, but opening 'Read Aloud' extension after that results in the same error message: "missing host permission for the tab"

  2. Separately, both extensions work fine, error appear only when data are passed from the first to the second Firefox extension.

Kieffer answered 7/12, 2019 at 5:53 Comment(0)
P
0

For me, this was caused by my code trying to interact with the tab before the user had interacted with my extension.

Per the doc for activeTab:

This permission is specified as "activeTab". If an extension has the activeTab permission, then when the user interacts with the extension, the extension is granted extra privileges for the active tab only.

Pentheam answered 20/1, 2020 at 18:24 Comment(0)
C
0

I didn't get this error on a view-source URL however, like Igor Zvorygin above, I got this error when using the Read Aloud extension while attempting to open a pdf. This is abnormal behavior for the extension. Normally, the extension prompts the user to upload the pdf instead of using the already opened version. In this case, even without the user prompt, downloading and then "uploading" (it doesn't actually upload it to a server, merely to the extension itself) the pdf fixed the problem.

Cathleencathlene answered 10/11, 2022 at 20:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.