Closed Bug 646357 Opened 14 years ago Closed 10 years ago

using context menu is unnecessarily difficult sometimes

Categories

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

defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1070952

People

(Reporter: dietrich, Unassigned)

Details

i want a context menu that does something when clicked, and i have to do this:

contextMenu.Item({
  label: 'do something with a selection',
  context: contextMenu.SelectionContext(),
  contentScript: 'on("click", postMessage);',
  onMessage: function (node, data) {
    doSomething(node.innerHTML);
  }
}

see how i have to hack a content script to auto-postMessage when i just want a basic click handler?

while the content-script plumbing is super powerful, it's not necessary for simple cases. i should be able to do this:

contextMenu.Item({
  label: 'do something with a selection',
  context: contextMenu.SelectionContext(),
  onClick: function() {
    doSomething(require('selection').text);
  }
}
context-menu forces you to use a content script because there's no legitimate use of the page context menu that doesn't interact with the page in some way.

But, the content-related Jetpack APIs (like selection) complicate the picture...
(In reply to comment #1)
> context-menu forces you to use a content script because there's no legitimate
> use of the page context menu that doesn't interact with the page in some way.
> 
> But, the content-related Jetpack APIs (like selection) complicate the
> picture...

Yep, any API that touches content on behalf of the caller, without requiring them to write a content script themselves, presents a legitimate use-case like the scenario I hit. These types of APIs will be even more common once content and chrome and jetpack code each runs in a separate process.

Also, note the hacky workaround with postMessage. That's the kind of implementation-exposure cruft that current XUL extension devs have to deal with all the time, and that Jetpack was designed to avoid.
OS: Mac OS X → All
Priority: -- → P2
Hardware: x86 → All
Target Milestone: --- → Future
(Pushing all open bugs to the --- milestone for the new triage system)
Target Milestone: 1.3 → ---
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.