Open Bug 1656756 Opened 4 years ago Updated 2 years ago

`tabs.executeScript` fails for newly created window

Categories

(WebExtensions :: General, defect, P3)

80 Branch
defect

Tracking

(firefox79 affected, firefox80 affected, firefox81 affected)

Tracking Status
firefox79 --- affected
firefox80 --- affected
firefox81 --- affected

People

(Reporter: juraj.masiar, Unassigned)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0

Steps to reproduce:

  1. load the extension
  2. open the background script console (from about:debugging page, click the Inspect button)

Actual results:

There is an error:
Uncaught (in promise) Error: Missing host permission for the tab

Expected results:

There should be no error.

The issue is, that creating new tab and executing script in it works fine, but creating new window with a tab and executing a script in it doesn't work.

Adding a delay after creating the new window will fix the problem. So it seems that the promise returned by the "browser.windows.create" is resolved sooner than it should be.

Thanks Juraj, do you know if this is a recent regression, or was it always like this?

Could you do a MozRegression? https://mozilla.github.io/mozregression/

I can't say if it worked before, I've just discovered it.
I've never used mozregression, but I will check it out later.

Hello,

I’ve managed to reproduce the issue on the latest Nightly (81.0a1/20200804091327), Beta (80.0b3/20200803045446) and Release (79.0/20200720193547) under Windows 10 Pro 64-bit and Ubuntu 16.40 LTS.

I’ve also searched for a regression window, running a bisection from 2018-01-01 until the present day and results show it was probably always this way, thus, most likely, not a regression. However, with the tested builds from 2018 and 2019, I did not get the Uncaught (in promise) Error: Missing host permission for the tab error but instead these:

  • 2019 builds: Error: No matching message handler undefined
  • 2018 builds: Error: Message manager disconnected undefined
Status: UNCONFIRMED → NEW
Has STR: --- → yes
Ever confirmed: true

The tabs API has special logic to support APIs such as tabs.executeScript (promiseTabWhenReady), which causes the API to wait for the tab to be ready before doing anything.

This is only implemented for tabs.create (in bug 1301862) and tabs.duplicate (bug 1559216), not windows.create ( windows.create implementation).

For extensions, a work-around is to use the tabs.onUpdated or one of the webNavigation events to wait for the newly created tab to be ready.

Severity: -- → S3
Priority: -- → P3
See Also: → 1813585
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: