Contextmenu img context does not work for tabs containing only the image itself

33 views
Skip to first unread message

Mingyi

unread,
Jun 27, 2011, 7:56:58 PM6/27/11
to mozilla-labs-jetpack
Say, you have a tab that has an URL http://domainname.com/imagename.png,
this tab is NOT an html file but containing only the image itself, a
menuitem with selectorcontext set to img would not show up. This is
the case when the URL is file:///c:/pathto/image.png as well.

But if you use event listener on mousedown you can see when the image
inside the tab is right clicked, event.target is an IMG node, but
contextmenu's img context does not work due to lack of worker for the
tab.

Is there any possibility to fix this, or maybe there's some other way
of making it work?

Thanks,

Mingyi

Drew Willcoxon

unread,
Jun 28, 2011, 2:17:29 PM6/28/11
to mozilla-la...@googlegroups.com
Thanks for reporting this. Your diagnosis about the worker is right on.
I filed a ticket and will try to fix it soon:

https://bugzilla.mozilla.org/show_bug.cgi?id=667957

Unfortunately I don't see a workaround.

Drew

Mingyi Liu

unread,
Jun 28, 2011, 9:11:07 PM6/28/11
to mozilla-la...@googlegroups.com
Thanks!

Mingyi

--
You received this message because you are subscribed to the Google Groups "mozilla-labs-jetpack" group.
To post to this group, send email to mozilla-labs-jetpack@googlegroups.com.
To unsubscribe from this group, send email to mozilla-labs-jetpack+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mozilla-labs-jetpack?hl=en.


Mingyi Liu

unread,
Jun 29, 2011, 12:37:03 PM6/29/11
to mozilla-la...@googlegroups.com
BTW I forgot to mention that in fact I found that this issue runs deeper than context-menu - for image-only tabs, not only that none of the context works for the context-menu, but also the tabs.on('ready' ... does not fire for image-only tabs (e.g., right click on any image and choose 'View Image', the tab doesn't fire 'ready' event), pageMod does not work for the tabs either (the content scripts are not attached).  That defeated most of my attempted nicer workarounds.  In the end I had to use tabs.on('activate', which does fire and is really not a good workaround for my Image2Icon extension.

I guess the ultimate reason might all be the same, related to the worker not created for such tabs.  But it's worth it to check other modules to see if they're all fixed once a fix is in place.

Thanks,

Mingyi

Drew Willcoxon

unread,
Jun 29, 2011, 1:53:33 PM6/29/11
to mozilla-la...@googlegroups.com
You're right, I've filed this ticket for the larger problem:

https://bugzilla.mozilla.org/show_bug.cgi?id=668258

I'm sorry for the trouble.

Drew

Mingyi Liu

unread,
Jun 29, 2011, 6:59:44 PM6/29/11
to mozilla-la...@googlegroups.com
Thanks! I viewed the bug report and indeed the DOM was complete on the image-only tab. My workaround using tabs.on('activate'... used a content script that worked on the DOM, checked that the document.body has only one childNode and it's an image worked fine for the image-only tabs.  It's just awkward that I had to ask the users to switch to a different tab first before coming back to the tab to use the image2icon conversion functionality (using double click not context-menu). :)

Thanks again for your quick responses!

Mingyi

Reply all
Reply to author
Forward
0 new messages