Closed Bug 1654355 Opened 4 years ago Closed 3 years ago

activeTab doesn't work with middle click on browserAction

Categories

(WebExtensions :: General, enhancement, P3)

78 Branch
x86_64
Linux
enhancement

Tracking

(firefox78 wontfix, firefox79 wontfix, firefox80 wontfix, firefox101 fixed)

RESOLVED FIXED
101 Branch
Tracking Status
firefox78 --- wontfix
firefox79 --- wontfix
firefox80 --- wontfix
firefox101 --- fixed

People

(Reporter: mad1ost, Assigned: kernp25, Mentored)

References

Details

(Keywords: good-first-bug)

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

Steps to reproduce:

I have my own webExtension with permission "activeTab" and page_action and browser_action icons.

Actual results:

When I click on the page_action or browser_action icon with the middle mouse button I get the next error in Console:
Uncaught (in promise) Error: Missing host permission for the tab undefined
apply self-hosted:1870
applySafeWithoutClone resource://gre/modules/ExtensionCommon.jsm:614
wrapPromise resource://gre/modules/ExtensionCommon.jsm:889

Expected results:

If I first click with left mouse button and then with the middle one - no error appears even If I click by middle button again until I reload the page. It seems that "activeTab" permission allows only left mouse click. As workaround I use host permission instead of "activeTab", for ex. "<all_urls>"

Component: Untriaged → General
OS: Unspecified → Linux
Product: Firefox → WebExtensions
Hardware: Unspecified → x86_64

Hi,

Thank you for taking the time to submit this bug report. Can you give us a test extension and also a screencast, to better understand the issue?

Flags: needinfo?(mad1ost)

You can install apply-css then open http://example.com and click the middle mouse button on the icon of the extension in the address bar. Nothing will change, only an error will appear in the Console (about:debugging#/runtime/this-firefox -> apply-css -> Inspect -> Console). When you will click the left mouse button, the red border will appear and then the middle mouse button will also work.

Flags: needinfo?(mad1ost)

Hi again,

Thank you for the provided information, it was really helpful. After testing on Windows 10 x64-bit and MacOS 10.14 with Nightly 80.0a1 (20200724093206), Beta 79 (20200720193547) and Release 78.0.2 (20200708170202) I managed to reproduce the issue that you described.

I tried to find a regression range, but from 2018-01-01 to 2019-10-27 the middle click doesn't seems to be implemented, only the left click, meaning that no error was displayed when the extension icon was clicked with the middle mouse button, but also nothing happened on the example.com page when I tried to do the same thing. I found the issue to be reproducing from 2019-10-28 running on Nightly 72.0a1 (20191028215046) and sadly I can't be more specific on what exactly caused the problem, since the bisection application was having problems finding builds between 2019-10-27 and 2019-10-28.

2019-10-28 pushlog: https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=3d0acce0b1de3581e0c584dd37be696f4bf1bb52&tochange=c65ef27b6fc78ec5140068913209bad3b55f1139

Status: UNCONFIRMED → NEW
Ever confirmed: true

The severity field is not set for this bug.
:mixedpuppy, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(mixedpuppy)
Severity: -- → N/A
Type: defect → enhancement
Priority: -- → P3
Summary: activeTab Uncaught (in promise) Error: Missing host permission for the tab undefined → activeTab doesn't work with middle click on browserAction
Flags: needinfo?(mixedpuppy)
Mentor: rob
Keywords: good-first-bug
See Also: → 1405031

(In reply to Rob Wu [:robwu] from comment #5)

I'll mentor this as a good-first-bug. To get started, see https://wiki.mozilla.org/WebExtensions/Contribution_Onramp

Usually the activeTab bit is activated at https://searchfox.org/mozilla-central/rev/919607a3610222099fbfb0113c98b77888ebcbfb/browser/components/extensions/parent/ext-browserAction.js#266

When middle-click is used, a different code path is taken, however:
https://searchfox.org/mozilla-central/rev/919607a3610222099fbfb0113c98b77888ebcbfb/browser/components/extensions/parent/ext-browserAction.js#472-488

To fix this bug, addActiveTabPermission should be called in the auxclick case, and a unit test should be added. You can add/modify a new test task to https://searchfox.org/mozilla-central/source/browser/components/extensions/test/browser/browser_ext_browserAction_click_types.js

Similarly, this should also be fixed for the pageAction API at https://searchfox.org/mozilla-central/rev/165e8d8f80c02605c2f3e89c5de462abfce91c32/browser/components/extensions/parent/ext-pageAction.js#104-123, with unit tests in https://searchfox.org/mozilla-central/source/browser/components/extensions/test/browser/browser_ext_pageAction_click_types.js

(In case you need more context; middle-click support for this API was added in bug 1405031.)

Hello Rob,
I'm from outreachy and I would like to work on this issue.

Looking forward to your patch. Feel free to ask questions, here or in the #addons room at chat.mozilla.org.

Hello, I am new to contributing to Bugzilla can you assigned me to this issue so that I can learn to fix these bugs and also suggest to me how can Is start working on this bug to fix it

(In reply to Falguni Islam from comment #8)

Hello, I am new to contributing to Bugzilla can you assigned me to this issue so that I can learn to fix these bugs and also suggest to me how can Is start working on this bug to fix it

Hi there, I have posted some comments above that provides some pointers.
I've also seen some of your other comments on other bugs. Rather than commenting on many, I suggest that you choose one that interests you most and work on that bug.

Can you tell how the test should look like?

Flags: needinfo?(rob)

(In reply to kernp25 from comment #10)

Can you tell how the test should look like?

Comment 5 already provides these details, which links to existing tests (including some from the patch to bug 1405031, i.e. at https://hg.mozilla.org/mozilla-central/rev/317bf7c3f39c).

The new test should have an extension with (and without) the activeTab permission, trigger a middle-click on the extension button, and verify that the extension has permissions when needed:

  • without activeTab: tab.url not available, executeScript in the tab fails with a specific error.
  • with activeTab permission: tab.url is available, executeScript succeeds.
Flags: needinfo?(rob)

Should i use this code to middle-clicking the browser action?

clickBrowserAction(extension, window, { button: 1 });
Flags: needinfo?(rob)
Assignee: nobody → kernp25
Status: NEW → ASSIGNED
Flags: needinfo?(rob)
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: