Last Comment Bug 714914 - Items of context-menu module appear only after successful page load
: Items of context-menu module appear only after successful page load
Status: RESOLVED FIXED
:
Product: Add-on SDK
Classification: Client Software
Component: General (show other bugs)
: unspecified
: All All
: P2 normal with 2 votes (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
:
Mentors:
https://groups.google.com/forum/#!top...
: 717645 835721 (view as bug list)
Depends on: 788324
Blocks: 762491
  Show dependency treegraph
 
Reported: 2012-01-03 12:21 PST by Siavash
Modified: 2013-01-29 08:36 PST (History)
10 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments

Description Siavash 2012-01-03 12:21:23 PST
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!)
https://groups.google.com/forum/#!topic/mozilla-labs-jetpack/M8CRdlLB-ps

I saw a similar report here(for selection event): https://bugzilla.mozilla.org/show_bug.cgi?id=661884
Comment 1 Wes Kocher (:KWierso) 2012-01-05 11:20:32 PST
Drew, is this something we can change so we do stuff earlier in the page-load process?
Comment 2 Drew Willcoxon :adw 2012-01-05 11:34:21 PST
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".
Comment 3 Wes Kocher (:KWierso) 2012-01-12 09:54:13 PST
*** Bug 717645 has been marked as a duplicate of this bug. ***
Comment 4 maddog 2012-01-19 15:58:55 PST
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 pritchard.adam 2012-05-19 14:33:34 PDT
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...
Comment 6 Matteo Ferretti [:zer0] [:matteo] 2012-07-20 07:23:46 PDT
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 pritchard.adam 2012-07-22 17:45:13 PDT
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:
https://github.com/adam-p/markdown-here/commit/d4f02418495d63a65ed1410625610bb66eb5bfee
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.
Comment 8 Matteo Ferretti [:zer0] [:matteo] 2012-08-02 06:57:19 PDT
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 pritchard.adam 2012-08-06 17:14:40 PDT
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 pritchard.adam 2012-08-06 17:43:56 PDT
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.
Comment 11 Dave Townsend [:mossop] 2013-01-02 14:00:04 PST
This should have been fixed by bug 788324.
Comment 12 Dave Townsend [:mossop] 2013-01-29 08:36:45 PST
*** Bug 835721 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.