Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Running JS code in extension's window from XPCOM

43 views
Skip to first unread message

Ondřej Doněk

unread,
Aug 17, 2012, 6:50:42 AM8/17/12
to
Hello,
I want to ask if there is something special about accessing JS code in Firefox's extension from the XPCOM component (also written in JS).

I working on custom mime-type-handler and what I want is
1) open tab with my extension when handler is started
2) pass some data when parser is stopped

While at 1) I have no problem I can not pass 2). I'm using this code (which I tested in Scratchpad and there works well but in my component not):

function executeCsvViewerTab()
{
var url = "chrome://csvviewer/content/csvtab.xul",
wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
getService(Components.interfaces.nsIWindowMediator);
var e = wm.getEnumerator("navigator:browser");
while(e.hasMoreElements()){
var tb = e.getNext().gBrowser;
for(var i=0; i<tb.browsers.length; i++) {
var cb = tb.getBrowserAtIndex(i);
if(url == cb.currentURI.spec){
var csvviewerTab = tb.tabContainer.childNodes[i];
if(csvviewerTab){
var win = tb.getBrowserForTab(csvviewerTab).contentWindow;
with(win){
CV_TabController.openCsvFromMimeHandler("...");
}
}
}
}
}
}

Thanks for any answers.

Regards,
Ondrej Donek
0 new messages