Closed Bug 1370716 Opened 7 years ago Closed 7 years ago

Error on console when browserAction button is pressed with no background script

Categories

(WebExtensions :: General, defect, P5)

defect

Tracking

(firefox57 verified, firefox58 verified)

VERIFIED FIXED
mozilla57
Tracking Status
firefox57 --- verified
firefox58 --- verified

People

(Reporter: mkaply, Assigned: zombie)

Details

(Whiteboard: triaged)

Attachments

(2 files)

The following code in background.js should add a context menu to the toolbar button menu:

      chrome.contextMenus.create({
        "title": "Import Friends",
        "contexts": ["browser_action"],
        "id": "import_friends",
        "onclick": function(clickData) {
            alert('here');
        }
      });

When you right click on the button in the toolbar, you get an error in ext-contextMenus.js at line 130

item is undefined.
This line:

http://searchfox.org/mozilla-central/source/browser/components/extensions/ext-contextMenus.js#99

const root = gRootItems.get(contextData.extension);

in buildActionContextMenu is returning null.
Is this the only code in the whole extension?  (If not, can you attach a minimal STR extension please?)

Are you adding menu items from other contexts?
Sorry, I'm in mid development so I misunderstood what was happening here.

I don't have a background script added yet, but every time the button is pressed there is an error.

So the bug seems to be that if you don't have a background script, we still try to add context menus (and show an error on the console)

Sorry for the confusion.
Summary: Adding a context menu using the browser_action context doesn't work → Error on console when browserAction button is pressed with no background script
In that case, unless you are testing in Nightly, this is likely bug 1362445.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
or perhaps not.
Assignee: nobody → tomica
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Priority: -- → P5
Whiteboard: triaged
So the issue is when the extension doesn't use menus (doesn't ask for the permission), the menus initialization [1] never happens, so we shouldn't even try to add _action context menus in that case.

1) http://searchfox.org/mozilla-central/source/browser/components/extensions/ext-menus.js#621
Attachment #8894276 - Flags: review?(mixedpuppy)
Comment on attachment 8894276 [details]
Bug 1370716 - Only try to add _action menus if extension has permission

https://reviewboard.mozilla.org/r/165364/#review170838
Attachment #8894276 - Flags: review?(mixedpuppy) → review+
Pushed by tomica@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/6f41f31b5299
Only try to add _action menus if extension has permission r=mixedpuppy
https://hg.mozilla.org/mozilla-central/rev/6f41f31b5299
Status: REOPENED → RESOLVED
Closed: 7 years ago7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Attached file Bug1370716.zip
I can reproduce this issue on Firefox 55.0a1 (20170606030207) under Wind 7 64-bit.

This issue is verified as fixed on Firefox 57.0b14 (20171102181127) and Firefox 58.0a1 (2017-11-02) under Wind 7 64-bit and Mac OS X 10.13.

There is no error in the browser console when you right click on the browser_action that has no background script added.

Please see the attached video.
Status: RESOLVED → VERIFIED
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: