Items of context-menu module appear only after successful page load



Add-on SDK
6 years ago
5 years ago


(Reporter: Siavash, Unassigned)


Firefox Tracking Flags

(Not tracked)





6 years ago
User Agent: Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
Build ID: 20111228084940

Steps to reproduce:

Items of context-menu module appear when page is fully loaded.
When loading of a page takes some time or when I stop a page context menu items do not show up. They will appear only after the page is fully loaded.

I tried a simple code(Add-on SDK 1.3, 1.4b):

var contextMenu = require("context-menu");
var anItem = contextMenu.Item({
     label: "Show an alert!",
     contentScript: 'self.on("click", function (node, data) {' +
                          'alert("Hi!");' +

An item with the label 'Show an alert!' should appear in the context menu and show an alert when clicked, but this item will appear only after successful page load.

I tested it on Ubuntu 11.10 and Windows 7 using Firefox 8 and 9.

I posted it on the Jetpack group but there was no response, so I decided to report it here.(I spent(wasted?!) too much time on this, thats why I'm reporting it again!)!topic/mozilla-labs-jetpack/M8CRdlLB-ps

I saw a similar report here(for selection event):


6 years ago
Drew, is this something we can change so we do stuff earlier in the page-load process?
Priority: -- → P2

Comment 2

6 years ago
This behavior is by design because the worker for an item-window pair is created when the window finishes loading.  Until a worker is created, context-menu can't tell whether the item should be shown or not, so the item isn't shown until the worker is created.

If context-menu supported contentScriptWhen like page-mod does, this could probably be done by setting it to "start".  Right now consumers are effectively locked in to "ready".
Ever confirmed: true


6 years ago
Duplicate of this bug: 717645

Comment 4

6 years ago
I just about to open the same bug. then I found this bug. contentScriptWhen for the content-menu is very important. When this will be fixed?

Comment 5

5 years ago
To add an impact anecdote: I'm not 100% certain, but I believe that this bug is responsible for my context menu item *never* showing up on Gmail, since it never stops "loading"(?). Going to rewrite using an old-style extension...
Blocks: 762491
pritchard.adam, could you try now that the bug 665386 is fixed? In my case the context menu is displayed correctly on GMail. Not sure actually if it is related, but at least the context menu is displayed in my case (where I have a selection's context).

Comment 7

5 years ago
zer0: Seems to still not work. The context menu doesn't show up in Gmail or Yahoo, but does show up in Hotmail and my very simple test page. IIRC, this is what I saw before as well.

The last rev of my extension where I used Jetpack can be found here, if you're interested in trying it:
You should see a "Markdown Toggle" menu item when right-clicking in a rich edit email compose box.

Or just let me know if/when you'd like me to try again.
adam: have you tried the simple add-on mentioned by Siavash? On Gmail the context-menu item is displayed properly, during my test. If that add-on doesn't work for you, we need have to investigate why. Otherwise, it's probably something in your add-on. Notice that without any `context` option the item will be added for the page's context, so not for textareas.

Comment 9

5 years ago
zer0: First of all, something seems to be pretty wrong with Gmail+addons-sdk (Win7, head addons-sdk; but okay on OSX). Every time I `cfx run` and log into Gmail -- even with a totally email main.js -- Firefox hangs for about 5 minutes (redraws, but unresponsive). This doesn't happen with Hotmail. So testing was super painful...

Siavash's simple extension (with `context: contextMenu.URLContext('*')` added) doesn't entirely work -- the context menu item shows up when right-clicking in the "To" box or the plain-text compose box, but not in the rich-text compose box (which is in an iframe, unlike the plain-text compose box).

My extension behaves the same (after I disable the check that causes the context menu item to only show in rich-compose controls). 

So... maybe the problem doesn't have to do with page loading and instead has something to do with iframes? Maybe an iframe with no src doesn't get matched by URLContext('*')? I tried using SelectorContext('iframe') or 'html', but no dice. I tried PageContext as well; again no.

Comment 10

5 years ago
A couple of other data points: 

- Hotmail (with the new Outlook interface): the rich compose iframe uses has a real src attribute. The context item shows properly.

- Yahoo: the rich compose iframe has a src attribute of "javascript:;". The context item does not show.

Or this src thing may be a wild goose chase.
Depends on: 788324
This should have been fixed by bug 788324.
Last Resolved: 5 years ago
Resolution: --- → FIXED
Duplicate of this bug: 835721
You need to log in before you can comment on or make changes to this bug.