Name: gm110360 Date: 03/25/2003
FULL PRODUCT VERSION :
JAVA_HOME=C:\j2sdk1.4.1_01;
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
FULL OPERATING SYSTEM VERSION :
Windows NT Version 4.0
A DESCRIPTION OF THE PROBLEM :
When I try to access a property or a method of an applet
which is not completely loaded by the plug-in, my
javascript instruction never returns. Not even an exception
or a null. The CPU is 100% busy with the netscape.exe for
ever. When I close the browser, I get a Dr. Watson.
Context :
Netscape 6.2, plug-in 1.3.1 or
Netscape 7.0, plug-in 1.4.0
My purpose is to call the applet just after everything is
put in place: the applet is loaded, ready is work and laid
out on screen. So I do the call on the BODY onload event.
It's fine with NN4.7 or IE5.5 and their internal JVM
because when the event fires, the applet is ready.
The problem is with the plug-in. I know that the onload
event fires as soon as the HTML is ready, independently
from the applet which is taken in charge by the plug-in.
The availability of the applet takes some time because it
comes from a signed Jar from a protected area of the web
server. So you have to walk through two additional steps:
authentify yourself with the server (first popup) and grant
session privileges to the applet code (second popup).
During this time, onload has been executed. I know I have
to check if the applet is up and if not try again later
with a setTimeout().
But how to check the readiness of the applet? When I try to
read whatever from it too soon, the code will never return !
To demonstrate the no-return, just put an alert and wait
for the applet to be loaded and fully active. Then you can
have a return from it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: access from JS to a property or method of the
applet should return whatever, but something.
Actual: the JS instruction never returns.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
<HTML>
<HEAD>
<SCRIPT>
function initApplet() {
// If you uncomment the following alert() and wait
// for the applet to be fully loaded and running, it will be OK.
// If you don't, "document.applets[0].isActive" or anything like
// "document.applets[0].XXX" will never return.
// alert("wait")
if (document.applets.length != 0
&& document.applets[0].isActive
&& document.applets[0].isActive()) updateApplet()
else setTimeout("initApplet()",1000)
}
function updateApplet() {
alert("call the applet")
}
</SCRIPT>
</HEAD>
<BODY onload="initApplet()">
<APPLET code="test.class" width="760" height="220" name="theApplet"
archive="theSignedJar.jar" MAYSCRIPT>
</APPLET>
</BODY>
</HTML>
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
1. Add a JS variable:
var appletReady = false;
2. Change the test with:
if (appletReady) updateApplet()
3. In the applet:
public void start() {
JSObject.getWindow(this).eval("appletReady = true;");
}
(Review ID: 180615)
======================================================================