Help needed with LiveConnect and JS/Java communication

"[email protected]" <[email protected]> Thu, 10 Jan 2008 14:45:24 -0800 (PST)
Newsgroups gmane.comp.mozilla.devel.java
Organization http://groups.google.com
Message-ID <5ab553ae-9d0e-4949-9d5b-0261273f5b62__27618.1370988072$1200005447$gmane$org@v29g2000hsf.googlegroups.com>
GOAL:

To pass the window handle returned by window.open from JS to Java so
that I can work with browser windows from Java.

SCENARIO (as a proof-of-concept - the real scenario is not so back-and-
forth) :

//this tests JS calling Java without params...
HTML body.onload calls PreviewApplet.testOnLoad()

//this tests Java calling JS and passing a parameter from Java
PreviewApplet.testOnLoad() calls JS method openPreview(url) in the
same HTML page


//openPreview calls back to the Applet with a handle to the opened
window
function openPreview(url) {
	openedWindow = window.open(url);
        this.document.applets.PreviewApplet.test(openedWindow);
}

PreviewApplet is supposed to store the handle to the opened window and
manipulate JSObjects.

IE 6:
Works well.

I am able to call JS methods, use getMember/setMember, change the
title of the openedWindow, get a reference to the opener of
openedWindow, etc, etc. When I debug the applet, I see that
openedWindow is a sun.plugin.javascript.ocx.JSObject and that object
has a sun.plugin.com.DispatchObject and a
sun.plugin.view.context.IExplorerAppletContext.

FIREFOX 2.0.0.11:
Does not work.

I am able to pass an object from JS to Java but I cannot call any JS
methods or use getMember/setMember to query/modify the object. When I
debug the applet, I see that openedWindow is a
sun.plugin.javascript.navig5.JSObject but the only interesting info is
a nativeJSObject field with a number & a jsThreadID with a number. Is
it possible to pass the window handle from JS to Java so I can use it
in the same way I use it in IE6? Or given the object that I am getting
from Firefox, is it possible to get a usable JSObject from that?

APPLET DECLARATION:
<applet id="PreviewApplet"
                 code="PreviewApplet.class"
                 codebase="."
                 width="300" height="300"
                 alt="Is this applet on?"
                 type="application/x-java-applet"
                 mayscript="true"
                 scriptable="true">
            <param name="mayscript" value="true"/>
         </applet>