Closed Bug 1591825 Opened 6 years ago Closed 6 years ago

WebExtensions' browser.tabs.executeScript "Missing host permission for the tab" when page is in Reader Mode

Categories

(WebExtensions :: Developer Tools, defect)

70 Branch
defect
Not set
normal

Tracking

(firefox70 affected, firefox71 affected, firefox72 affected)

RESOLVED DUPLICATE of bug 1371786
Tracking Status
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:

  1. 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!");
});
}

  1. Run the extension in Firefox and open this page (just an example supporting Reader Mode): https://developer.mozilla.org/docs/Learn

  2. Notice that "injected!" is printed in the console (and the Browser Toolbox).

  3. Now press the Reader Mode button in the Firefox URL field. The page reloads in Reader Mode.

  4. 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.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Product: Firefox → WebExtensions

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:

  1. 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.
  2. 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
Status: UNCONFIRMED → NEW
Component: Untriaged → Developer Tools
Ever confirmed: true
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: