Hi,
We’re planning to move parts of an existing XUL-based addon to e10s so it works properly with new FF versions. We managed to find info about most of parts that need to be changed, but haven’t found some clear explanation about how context menu with access to content document should work.
We add new items to standard context menu that need to either modify the target node (set value or attribute) or get information about the node (ID, class, etc.). In current version it is done using logic that looks like the following (irrelevant code dropped for clarity):
Overlay part for menu items
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
...
<popup id="contentAreaContextMenu">
...
<menuitem
id="my-addon-new-item"
label="&myAddonNewItem.label;"
accesskey="&myAddonNewItem.accesskey;"
insertafter="context-selectall"
class="menuitem-iconic"
/>
...
</popup>
...
Listening and reacting to context menu events:
// Run on browser window 'load' event
function initOverlay() {
...
document.getElementById('my-addon-new-item').on('command', onMyItemClick);
...
}
// Runs when user clicks my addon item
//after opening context menu on e.g. some input element
function onMyItemClick(event) {
var elem = gContextMenu.target;
// Here I can modify or check input element's properties
var id = elem.id;
elem.value = 'New value';
...
}
In e10s gContextMenu.target
is not available since context menu handlers live in chrome process. But some things are not very clear:
- how do we send information (ID, class, value) about the node to
onMyItemClick
now? - how do we send command to do something with the context target (set new value, add attribute)?
I’ve found some info here about context menu usage with Addon SDK but our addon doesn’t use it so we want to avoid rewriting it from scratch just to use custom context menu items.
SO answer here shows there’s also gContextMenuContentData.event.target
value but it reports “unsafe/forbidden CPOW usage” to the console when retrieved.
There’s also an MDN page about some new notification we can observe, but it’s not clear how exactly it should be used with context menu item listeners.
Thanks you in advance for your answers.