I need to detect whenever a page in a active/foreground tab is loaded. In principle it works with something along the lines of
Code: Select all
function onPageLoad(event) {
// check if the event was dispatched from a background tab
if (event.target != window.gBrowser.selectedBrowser.contentDocument)
return;
// otherwise do something
}
window.gBrowser.addEventListener("DOMContentLoaded", onPageLoad, false);
So far so good BUT I need to do this in a restartless extension in e10s Firefox (in other words in bloody hell!)
Does anyone know how to do that? With above code I'm already facing two problems:
- If e10s is enabled, the listener for "DOMContentLoaded" does not work directly after installing the extension - a restart is required.
- The condition to check if the event target is the contentDocument of the currently selected Browser does not work. There are two issues I faced with all variations I tried so far: Either a) The check works, but I get an "unsafe CPOW" warning because I'm accessing the content document from my add-ons chrome environment, or b) The check always evaluates to "false" with e10s enabled because different objects are compared (that would be equal with e10s disabled though).
Any idea on how to do this? I'm also open to different approaches, we don't have to stick to my example above...