Closed Bug 1287159 Opened 8 years ago Closed 8 years ago

onCommand listeners do not grant the activeTab permisson to the current tab

Categories

(WebExtensions :: Untriaged, defect, P1)

47 Branch
defect

Tracking

(firefox51 fixed)

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: zmstefan, Assigned: mattw)

References

Details

(Whiteboard: triaged)

Attachments

(2 files)

Attached file fillzToAmazon.xpi
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Steps to reproduce:

I'm creating an WebExtension. I want to inject javascript to two different urls, one .js file per URL.
I manage to do this with chrome.browserAction.onClicked, so when I click on button on toolbar it works correctly.
But when I assign an shortcut to extension, and assign the same code for injecting .js to the onCommand event listener, it does not work, and outputs "No matching window" error in Console. I inject javascript into active tab with executeScript function.


Actual results:

^^


Expected results:

^^
Added <"all_urls"> to permissions in manifest.json file, and it's working as it should!
Component: Untriaged → WebExtensions
Product: Firefox → Toolkit
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
I'm not sure if this should be made a duplicate of bug 1274871. I haven't confirmed this bug, but it looks as if what's happening is that Firefox is not treating a hotkey combination as an "explicit user action", that then lets the "activeTab" permission do its thing. That would explain why the same code worked with a browser action.

I would have expected that a hotkey combination *should* be treated as a user action, and the Chrome docs for activeTab confirm this: https://developer.chrome.com/extensions/activeTab.

In short: Stefan should be able to use "activeTab" here. Using "<all_urls>" is a workaround for that bug.
Ah, sorry, you're right
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: DUPLICATE → ---
Summary: "No matching window" error when trying to executeScript from onCommand event listener in background.js - WebExtension → onCommand listeners do not grant the activeTab permisson to the current tab
Assignee: nobody → mwein
Priority: -- → P1
Whiteboard: triaged
Comment on attachment 8774538 [details]
Bug 1287159 - Grant activeTab permission to the current tab when onCommand fires.

https://reviewboard.mozilla.org/r/66960/#review63828

This is a good start, but we also need tests. Please add at least one or two to browser_ext_tabs_executeScript_good.js, and probably one to browser_ext_tabs_executeScript_bad.js as well.
Attachment #8774538 - Flags: review?(kmaglione+bmo)
Comment on attachment 8774538 [details]
Bug 1287159 - Grant activeTab permission to the current tab when onCommand fires.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/66960/diff/1-2/
Attachment #8774538 - Flags: review?(kmaglione+bmo)
Comment on attachment 8774538 [details]
Bug 1287159 - Grant activeTab permission to the current tab when onCommand fires.

https://reviewboard.mozilla.org/r/66960/#review65128

Perfect. Thanks!
Attachment #8774538 - Flags: review?(kmaglione+bmo) → review+
Comment on attachment 8774538 [details]
Bug 1287159 - Grant activeTab permission to the current tab when onCommand fires.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/66960/diff/2-3/
Keywords: checkin-needed
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/fx-team/rev/9e0cbff9c4e1
Grant activeTab permission to the current tab when onCommand fires. r=kmag
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/9e0cbff9c4e1
Status: REOPENED → RESOLVED
Closed: 8 years ago8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
See Also: → 1387506
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: