Detect page load in active/foreground tab with e10s

Discuss building things with or for the Mozilla Platform.
Locked
Ede_123
Posts: 44
Joined: March 6th, 2013, 7:47 pm

Detect page load in active/foreground tab with e10s

Post by Ede_123 »

Hi all,

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:
  1. If e10s is enabled, the listener for "DOMContentLoaded" does not work directly after installing the extension - a restart is required.
  2. 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...
Ede_123
Posts: 44
Joined: March 6th, 2013, 7:47 pm

Re: Detect page load in active/foreground tab with e10s

Post by Ede_123 »

Sorry, wrong forum, correct thread is here:
viewtopic.php?f=19&t=2923745
User avatar
LIMPET235
Moderator
Posts: 39932
Joined: October 19th, 2007, 1:53 am
Location: The South Coast of N.S.W. Oz.

Re: Detect page load in active/foreground tab with e10s

Post by LIMPET235 »

Duplicate, X post, locking. Continue the discussion here: viewtopic.php?f=19&t=2923745
[Ancient Amateur Astronomer.]
Win-10-H/64 bit/500G SSD/16 Gig Ram/450Watt PSU/350WattUPS/Firefox-115.0.2/T-bird-115.3.2./SnagIt-v10.0.1/MWP-7.12.125.

(Always choose the "Custom" Install.)
Locked