Document.addEventListener will be deprecated in new addon API?

Hi,

I am using an addon that blocks specific JavaScript functions on a website. Whether a function should be blocked or not will be determined by the name of the function. (Black-list approach)

Here is the code that is used for this:

...
document.addEventListener('beforescriptexecute', onBeforeScriptExecuteHandler);
...
var onBeforeScriptExecuteHandler = function(ev) {
  if ( myTestFunction(ev.target.textContent) ) {
    ev.preventDefault();
    ev.stopPropagation();
  }
};

This code works fine, but my question is:
I heard through the grapevine that within this new WebExtentions / Electrolysis stuff, using document.addEventListener resp. listening to ‘beforescriptexecute’ in an addon will not be possible any more, hence I cannot stop specific scripts from executing on a webseite. Is this correct?

WebExtensions (WEAPI) is nothing to do with Electrolysis (aka e10s). It is simply (another!) new API for writing addons. Electrolysis is multi-process Firefox. WEAPI addons are automatically multi-process compatible. Others may need changes.

WEAPI does not prevent event listeners in general. Some of them will work for sure, for example click events in content scripts. WEAPI prevents much of the interaction with chrome by locking you inside a set of high level APIs, but you have much more freedom inside the content scripts that you can include in pages. The beforescriptexecute is a tricky one because it will depend on the timing of your script insertion whether you see it or not. I would expect that it should still be possible. Note that WEAPI on Firefox is still at a very early stage and many (most) of the APIs are missing or incomplete. For more details what WEAPI can, become, look at Google Chrome.