Can't get "DOMContentLoaded" event from iframe inside a Firefox tab (XUL and chrome:// document)

Paul Rouget paul at mozilla.com
Tue Aug 20 13:57:45 UTC 2013


No. It doesn't. Still trying to figure out what I'm doing wrong.

----- Original Message -----
> Apparently, using <iframe type="chrome"> solves my issue.
> 
> ----- Original Message -----
> > A XUL document:
> > chrome://browser/content/devtools/framework/toolbox-window.xul
> > It contains many iframes. We listen to the DOMContentLoaded event from
> > these
> > iframes.
> > 
> > > let iframe = document.createElement("iframe");
> > > iframe.addEventListener("DOMContentLoaded", callback);
> > 
> > Event is received if toolbox-window.xul lives in its own window.
> > Event is NOT received if toolbox-window.xul lives in a Firefox tab (inside
> > <browser>).
> > 
> > ----
> > 
> > Here is a way to see this behavior:
> > 
> > In a Firefox tab, open
> > chrome://browser/content/devtools/framework/toolbox-window.xul
> > (page is grey, it's normal).
> > 
> > Open Scratchpad (Shift-F4), and run this code:
> > 
> > > let button = document.createElement("button");
> > > button.setAttribute("label", "CLICK");
> > > let iframe = document.createElement("iframe");
> > > iframe.setAttribute("src", "about:blank");
> > > 
> > > document.documentElement.appendChild(button);
> > > document.documentElement.appendChild(iframe);
> > > 
> > > button.addEventListener("click", function() {
> > >   iframe.addEventListener("DOMContentLoaded", function() {
> > >     alert(42);
> > >   } , true);
> > >   iframe.setAttribute("src",
> > >   "chrome://browser/content/devtools/profiler.xul");
> > > }, true);
> > 
> > No alert.
> > 
> > If this code runs in a window and not a tab, we see the alert.
> > 
> > How can I get the window behavior inside a tab?
> > 
> > Thanks,
> > 
> > -- Paul
> > _______________________________________________
> > firefox-dev mailing list
> > firefox-dev at mozilla.org
> > https://mail.mozilla.org/listinfo/firefox-dev
> > 
> _______________________________________________
> firefox-dev mailing list
> firefox-dev at mozilla.org
> https://mail.mozilla.org/listinfo/firefox-dev
> 



More information about the firefox-dev mailing list