Name: gm110360 Date: 07/19/2004
FULL PRODUCT VERSION :
Java(TM) Plug-in: Version 1.4.2_04
Using JRE version 1.5.0-beta Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\amilkowski
Proxy Configuration: No proxy
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
test case contains two (2) applets, first applet does liveconnect call
to a script that writes an IFRAME in a span (_openSpan)
that IFRAME contains html containing second applet that does
another live connect call to a script (_test()) that in turn calls applet method (appletMethod()) that then makes a third live connect call to a script (_test2() )
third live connect call (to a script function: _test2()) never completes and instead browser freezes (requiring alt-ctrl-del)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. load test.html page
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
all liveconnect calls should complete with stable behaviour and
not freeze browser
ACTUAL -
Applet2 attempt to make liveconnect call to _test2() fails,
browser freezes
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
1. source code for Applet1:
import java.applet.*;
import netscape.javascript.*;
public class Applet1 extends Applet {
private JSObject window = null;
public void init() {
StaticClass.register(StaticClass.C_APPLET1, this);
window = StaticClass.getJSObjectWindow(this);
}
public void start() {
System.out.println("Applet1 start(), open span via liveconnect");
try {
Object args[] = {};
window.eval("var u_spn = window.document.createElement('span');");
window.eval("document.body.insertAdjacentElement('afterBegin', u_spn);");
window.eval("_openSpan('#000000', 'test2.html','window','height='+(screen.availHeight-36)+',width='+(screen.availWidth-10)+',menubar=0,resizable=0,titlebar=0,toolbar=0,status=0,scrollbars=0,left=0,top=0');");
} catch(Exception e) {
System.out.println("Exception: " + e.getMessage());
}
}
public void run() {
}
public void stop() {
}
public void destroy() {
}
}
2. source code for Applet2:
import java.applet.*;
import netscape.javascript.*;
public class Applet2 extends Applet {
private static final int C_JSOBJECT_WINDOW_MAX_RETRY = 5;
private static final int C_JSOBJECT_WINDOW_MAX_SLEEP = 10;
private JSObject window = null;
public void init() {
StaticClass.register(StaticClass.C_APPLET2, this);
window = StaticClass.getJSObjectWindow(this);
}
public void start() {
System.out.println("Applet2 start() call");
try {
Object args[] = {""};
window.call("_test", args);
} catch(Exception e) {
System.out.println("Exception: " + e.getMessage());
}
}
public void stop() {
}
public void destroy() {
}
public void appletMethod() {
System.out.println("Applet2 appletMethod() call");
StaticClass.showStatus("Applet2 appletMethod called");
try {
Object args[] = {""};
window.call("_test2", args);
} catch(Exception e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
3. source code for helper class StaticClass:
import java.applet.*;
import netscape.javascript.*;
import java.util.Hashtable;
public class StaticClass {
public static final String C_APPLET1 = "Applet1";
public static final String C_APPLET2 = "Applet2";
private static Hashtable registry = new Hashtable();
private static final int C_JSOBJECT_WINDOW_MAX_RETRY = 5;
private static final int C_JSOBJECT_WINDOW_MAX_SLEEP = 10;
static public JSObject getJSObjectWindow(Applet applet) {
JSObject window = null;
for (int i = 0; i < C_JSOBJECT_WINDOW_MAX_RETRY; i++) {
try {
window = (JSObject) JSObject.getWindow(applet);
} catch (Exception e) {}
if (window != null)
break;
sleep(C_JSOBJECT_WINDOW_MAX_SLEEP);
}
return window;
}
static public void sleep(long msecs) {
long now = System.currentTimeMillis();
long end = now + msecs;
while (now < end) {
try {
Thread.sleep(end-now);
}
catch (InterruptedException ie) {
}
now = System.currentTimeMillis();
}
}
static public void register(String key, Object entry) {
registry.put( key, entry );
}
static public Object lookup(String key) {
Object result = null;
result = registry.get( key );
return result;
}
static public void showStatus(String status) {
try {
Applet applet = (Applet) lookup(C_APPLET1);
if (applet == null)
applet = (Applet) lookup(C_APPLET2);
if (applet != null)
applet.showStatus(status);
} catch(Exception e) {
}
}
}
4. test.html source code:
<HTML>
<BODY>
<script>
function _openSpan(bgColor, url, name, style) {
if (document.body && document.body.readyState!="complete") {
setTimeout("_openSpan("+bgColor+", "+url+", "+name+", "+style+");", 10);
return;
}
var u_data = 'name="u_winAd" src="'+url+'" height=1 width=1';
_dwSpn('<iframe '+u_data+' scrolling=no frameborder=0 marginheight=1 marginwidth=1></iframe>');
function _dwSpn(html){u_spn.innerHTML=html;}
}
</script>
<applet code=Applet1 codebase=http://localhost.unicast.com/Project1 name=Applet1 width=0 height=0 align=baseline mayscript></applet>
</BODY>
</HTML>
5. source code for test2.html:
<HTML>
<BODY>
<script>
function _test() {
alert('_test() called');
appletMethod();
}
function _test2() {
alert('_test2() called');
}
var u_t1;
function appletMethod() {
if(appletReady()) document.applets["Applet2"].appletMethod(); else u_t1=setTimeout(appletMethod, 50);
}
function appletReady(){
var js='return(typeof document.applets["Applet2"] !="undefined" && document.applets["Applet2"].readyState>3 && document.applets["Applet2"].isActive());';
return _try(js,false);
}
function _try(js,rc){return _eJS("try {"+js+"}catch(e){return "+rc+";}");}
function _eJS(js){var func=new Function(js);return func();}
function _dw(string) {document.write(string);}
</script>
<applet code=Applet2 codebase=http://localhost.unicast.com/Project1 name=Applet2 width=0 height=0 align=baseline mayscript></applet>
</BODY>
</HTML>
---------- END SOURCE ----------
(Incident Review ID: 286337)
======================================================================