Closed Bug 683289 Opened 13 years ago Closed 13 years ago

Context menu items not showing

Categories

(Add-on SDK Graveyard :: General, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: jeffdoubleyou, Assigned: adw)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0) Gecko/20100101 Firefox/6.0
Build ID: 20110812234425

Steps to reproduce:

I upgraded my add-on builder SDK from 1.0 to 1.1b2.


Actual results:

Any time that I run a test or build an XPI using the new 1.1b2 builder, my context menu that is working fine in 1.0 will not open.

Here is the code:

var contexts  = require("context-menu");

var menu = contexts.Menu({
  label: "MyAPP",
        contentScript: 'self.on("click", function (node, data) {' +
                 '  console.log("context menu clicked " + data);' +
                 '  self.postMessage(data);' +
                 '});',
        items: [
                contexts.Item({ label: "Call History", data: "history" }),
                contexts.Item({ label: "Account Settings", data: "auth" }),
                contexts.Item({ label: "Phonebook", data: "phonebook" }),
                contexts.Item({ label: "About MyAPP", data: "about" })
        ],
        onMessage: function(option)
        {
                if(option == 'history')
                {
                        history_panel.show();
                }
                else if(option == 'auth')
                {
                        settings_panel.show();
                }
                else if(option == 'phonebook')
                {
                        phonebook_panel.show();
                }
                else if(option == 'about')
                {
                        about_panel.show();
                }
                else if(option == 'toggle')
                {
                        var en = toggle_enabled();
                        settings_widget.contentURL = en ? data.url('MyAppEnabled.png') : data.url('MyAppDisabled.png');
                        console.log(toggle_menu_item.label);
                }
        }
});



Expected results:

The context menu should have continued working as before.  I've tried making some changes but cannot get it working.
System Info:

Firefox: 6.0+build1+nobinonly-0ubuntu0.11.04.1 (firefox)


(addon-sdk-1.1b2)jeffdoubleyou@jeffdoubleyou-Vostro-3500:~/mozilla/addon-sdk-1.1b2/addons/FONcall$ uname -a
Linux jeffdoubleyou-Vostro-3500 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:05:14 UTC 2011 i686 i686 i386 GNU/Linux



Also, I don't see any exceptions or anything at all when I click my context menu.
Alex: can you confirm this?

Drew: might this be related to your recent context menu changes?
Assignee: nobody → poirot.alex
Priority: -- → P1
Target Milestone: --- → 1.1
Jeffrey, what do you mean by your "context menu" "will not open"?  By "context menu" do you mean the "MyApp" Menu that you add to the context menu?  Can you be more specific about what you mean by "will not open"?

I can't reproduce with Firefox 6.0.1 on OS X and SDK 1.1b2.  I did these steps:

1. Copied and pasted the code from comment 0 into my main.js.
2. Built an XPI with SDK 1.1b2.
3. Created a new profile in Firefox 6.0.1, started Firefox, and dragged the XPI to the about:addons tab to install it.
4. Right-clicked some web pages that were already open and that I opened after installing the XPI.  The "MyAPP" menu appeared in the context menu as expected, and when I highlighted it, it opened to reveal the submenu as expected.
5. Restarted Firefox and right-clicked the about:home page that came up.  This time the "MyAPP" menu *did not appear* in the context menu, which is a bug.  Is that what you mean?
6. Then I opened some web pages and right-clicked, and the "MyApp" menu appeared in the context menu as expected, and when I highlighted it, it opened to reveal the submenu as expected.

Re: step 5, it seems that the context-menu module isn't catching the "content-document-global-created" notification fired for about:home on Firefox startup, if it's fired at all.  If I open a new tab and navigate to about:home after startup, the notification is caught as expected.  Also, if I set my home page to google.com or about:blank instead of about:home, the notification is caught as expected on startup.
Priority: P1 → --
Target Milestone: 1.1 → ---
Priority: -- → P1
Target Milestone: --- → 1.1
Hi Drew,

When I install the XPI or use cfx run ( either using an existing profile or blank profile ), the MyApp menu shows up when I right click and has an arrow indicating that it should have sub menu items ( mine actually shows on my home page about:blank and if I go to about:home ).

However, clicking / highlighting the menu produces nothing at all, meaning the menu doesn't expand to show me the items.  There is no output on the console either.

When I use this same code and build it with version 1.0, it works just fine.
Attached patch diagnostic patchSplinter Review
Jeffrey, thanks for the additional info, but I can't reproduce on Linux either, so I'm not sure what the problem is (Firefox 6.0.2, 2.6.38-10-generic-pea #46-Ubuntu).

Could you apply this diagnostic patch to the context-menu.js file in your addon-sdk-1.1b2 tree?  After you apply it, please cfx run with the add-on you pasted in comment 0, right-click to bring up the context menu, and then try to open your MyAPP menu.  The patch dumps some output to your terminal.  Please copy and paste it into a new file and attach that file to this bug.

If you need help applying the patch, try this, assuming the addon-sdk-1.1b2 tree and the patch are both in your home directory:

$ cd ~/addon-sdk-1.1b2/packages/addon-kit/lib
$ patch -p1 context-menu.js < ~/bug683289.diff
I'm sorry.  Before actually installing the diagnostic patch, I just found the actual problem.

In my code, there was some code that I didn't see because of some odd tabs...long story.

Basically, it looks like there was actually a bug in 1.0 that was allowing my code to work properly even though it shouldn't have ( I think ).

So, way off to the right off my screen...I found this:

menu.items = [];


Which was clearing out my menu items ( as I would expect ).  Apparently, this wasn't the behavior in 1.0.


Sorry for the confusion.
Ah, yeah, SDK 1.1 lets you set your Menus' items by assigning an array to the items property.  1.0 just ignored such an assignment.  Glad you found the problem.

Thanks for reporting the bug, even if it turned out not to be a bug, and please don't hesitate to let us know if you find more.
Assignee: poirot.alex → adw
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: