Message manager is the e10s safe way and recommended way if you can do it. If not observers are e10s ok, it is usable in the parent process.
No Control
If you don’t have control you can tap into it with some not recommended methods, as your addon will likely be rejected. It uses some internal stuff so these things can change at any time. Here is how though:
I’ll look at these when I get the time.
To clarify: I have access to my own add-on source and the other add-on allows me to execute javascript code, but I don’t have access to the add-on source itself.
So I’ll check out if it’s possible to use the message manager using old xul javascript.
I currently tap into my addons bootstrap scope with this code, but only for testing, they change the path to the XPIProvider.jsm all the time and mess around with it internally. I don’t think this method works on nightly. I use it on beta and release.
var getScope = function() { var XPIScope = Cu.import('resource://gre/modules/addons/XPIProvider.jsm'); return XPIScope.XPIProvider.bootstrapScopes['MouseControl@jetpack']; };
a = getScope();
TypeError: XPIScope.XPIProvider.bootstrapScopes is undefined
I tried messagemanager, but aside from the fact that I’m confused which message manager to use, most of them don’t even work.
I’ve tried calling addMessageListener and after that send/broadcastAsyncMessage right after it for these:
browser.messageManager;
Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
(window)messageManager
Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIMessageBroadcaster);
Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsISyncMessageSender);
Only the last two received the message.
But when I try to call these any of the above from the other add-on, I’m unsure how to catch them from my add-on.
Currently I do this:
pageMod.PageMod({
include: "*",
contentScriptWhen: 'start',
contentScriptFile: self.data.url("pagemod.js"),
attachTo: ["existing", "top", "frame"],
onAttach: function (worker) {
var lowLevelTab = core.viewFor(worker.tab);
var browser = tabUtils.getBrowserForTab(lowLevelTab);
browser.messageManager.addMessageListener("searchdictcc@roughael:handleMouseGesture", function (message) {
console.log(message.data)
});
}
});
It doesn’t work for any of them.
I’ve tried registering with the CC message managers using require("chrome), but no success either.
I’ve tried using postMessage and Dom-Events as described here:
Which works for scripts running in the webpage I’m on, but for some reason not when I do it from the fire-gestures add-on.
Things changed drastically in Firefox 47. This is the new way to access it.
var XPIScope = Cu.import('resource://gre/modules/addons/XPIProvider.jsm');
var addonid = 'Profilist@jetpack';
var scope = XPIScope.XPIProvider.activeAddons.get(addonid).bootstrapScope