WebExtensions' browser.tabs.executeScript "Missing host permission for the tab" when page is in Reader Mode
Categories
(WebExtensions :: Developer Tools, defect)
Tracking
(firefox70 affected, firefox71 affected, firefox72 affected)
People
(Reporter: daniel.rb.lobo, Unassigned)
Details
Attachments
(1 file)
|
859 bytes,
application/x-zip-compressed
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
Steps to reproduce:
- Create a WebExtension with manifest.json and background.js.
manifest.json is this:
{
"manifest_version": 2,
"name": "Reader Mode executeScript",
"version": "1.0.0",
"permissions": ["<all_urls>", "webNavigation"],
"background": {
"scripts": ["background.js"]
}
}
background.js is this:
browser.webNavigation.onDOMContentLoaded.addListener(onDOMContentLoaded);
function onDOMContentLoaded(details)
{
browser.tabs.executeScript(details.tabId, {
code: console.log("injected!");
});
}
-
Run the extension in Firefox and open this page (just an example supporting Reader Mode): https://developer.mozilla.org/docs/Learn
-
Notice that "injected!" is printed in the console (and the Browser Toolbox).
-
Now press the Reader Mode button in the Firefox URL field. The page reloads in Reader Mode.
-
Notice the console doesn't print anything and the Browser Toolbox prints "Error: Missing host permission for the tab".
Unfortunately, I cannot tell if this is a bug or intended (?) but I couldn't find anything anywhere, and it is a problem I'd like to solve in my actual WebExtension.
Actual results:
I have <all_urls> in the permissions but still the extension can't touch the Reader Mode page at all.
Expected results:
It should be able to successfully call executeScript, especially since the URL is the same as the original page. "Missing host permission for the tab" does not make it clear what the problem is.
Maybe this is intended, or has a solution, but I could find no explanation for this, and in my case I'd like to be able to add a popup to the page when text is selected.
Comment 1•6 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 2•6 years ago
|
||
I've tested in Windows 10 using the following FF versions: nightly 72.0a1, beta 71.0b4, release 70.0. In all FF versions, the issue can be reproduced, the error is displayed. Also, I have to mention two things:
- on the file background.js at line 7, it should be added "
" - backticks or grave accent like:console.log("injected!");` - please see the screenshot attached. - Consulting Host permissions I found that "bypass tracking protection if the host is a full domain without wildcards. Doesn't work with <all_urls>." - see the link: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions
Updated•6 years ago
|
Description
•