Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6738770
Votes 0
Synopsis REGRESSION:JSException throws when use LiveConnect javascript facility to navigate HTML elements
Category java_plugin:plugin2
Reported Against b33
Release Fixed 6u11(b03)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6765658 , 6766056 , 6770914
Submit Date 19-AUG-2008
Description
J2SE Version (please include all output from java -version flag):

java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)


Does this problem occur on J2SE 1.3, 1.4.x or 1.5?  Yes / No (pick one)

No. 1.6.0_07 is fine.

Operating System Configuration Information (be specific):

Windows XP SP2, IE7


Hardware Configuration Information (be specific):

Standard desktop

Bug Description:

When we use LiveConnect javascript facility to navigate HTML elements using document.all.item, it would cause an JSException when it evalute attributes of an applet tag. I have reduce our production applet into a smaller test case and you can easily catch the exception but using our production applet it crashes the Internet Explorer.

Steps to Reproduce (be specific):

1) Install the following test cases:

TestJSObject.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TestJSObject</title>
</head>
<body>
<applet alt="Java not installed properly" code="TestJSObject" codebase="bin/" width="640" height="480" MAYSCRIPT></applet>
<table>
<TR bgcolor="#123456">
<TD>Testing 1</TD>
<TD>Testing 2</TD>
</TR>
</table>
</body>
</html>

TestJSObject.java:

import javax.swing.JApplet;
import javax.swing.JTextArea;

import  customer .javascript.JSException;
import  customer .javascript.JSObject;


public class TestJSObject extends JApplet {

	@Override
	public void init() {
		JTextArea area = new JTextArea(100,100);
		JSObject appletWindow = JSObject.getWindow(this);
		JSObject document = (JSObject) appletWindow.getMember("document");  
		if( document == null) {
			area.append("Document is null!!!!");
		} else {
			area.append("Document is: "+document);
		}
		area.append("\n");
		
		JSObject documentElement = (JSObject) document.getMember("documentElement");
		area.append("documentElement = "+documentElement);
		area.append("\n");
			
		String innerHTML = (String) documentElement.getMember("innerHTML");
		area.append("innerHTML = "+innerHTML);
		area.append("\n");
		
		JSObject allItem = (JSObject) document.getMember("all");
		area.append("all element="+allItem);
		area.append("\n");
		area.append("item length="+allItem.getMember("length"));
		
		int length = (Integer) allItem.getMember("length");
		area.append("\n");
		
		
		for(int i=0; i<length; i++) {
			try {
				JSObject element = (JSObject) allItem.call("item", new Object[] {i});
				area.append("item "+i+" = "+ element.getMember("tagName")+".localName=s"+element.call("getAttribute",new Object[] {"GSLinkElement"}));
				area.append("\n");
			} catch (JSException jse) {
				area.append("Exception occured\n");
				area.append("Exception = "+jse.getLocalizedMessage());
			}		
		} 
		
		add(area);
		setVisible(true);
		
	}
}

2) When you run this applet, with Java 6 update 7 it will show this:

Document is: [ customer  HTMLDocument]
documentElement = [ customer  HTMLElement]
innerHTML = <HEAD><TITLE>TestJSObject</TITLE>
<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1"></HEAD>
<BODY><!-- 

--><APPLET codeBase=bin/ height=480 alt="Java not installed properly" width=640 code=TestJSObject MAYSCRIPT><PARAM NAME="_cx" VALUE="16933"><PARAM NAME="_cy" VALUE="12700"></APPLET> 
<TABLE>
<TBODY>
<TR bgColor=#123456>
<TD>Testing 1</TD>
<TD>Testing 2</TD></TR></TBODY></TABLE></BODY>
all element=[ customer  HTMLCollection]
item length=13
item 0 = !.localName=snull
item 1 = HTML.localName=snull
item 2 = HEAD.localName=snull
item 3 = TITLE.localName=snull
item 4 = META.localName=snull
item 5 = BODY.localName=snull
item 6 = !.localName=snull
item 7 = APPLET.localName=snull
item 8 = TABLE.localName=snull
item 9 = TBODY.localName=snull
item 10 = TR.localName=snull
item 11 = TD.localName=snull
item 12 = TD.localName=snull

When you run this applet under Java 6 Update 10, it will show this:


Document is: [ customer ]
documentElement = [ customer ]
innerHTML = <HEAD><TITLE>TestJSObject</TITLE>
<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1"></HEAD>
<BODY><!-- 

--><APPLET codeBase=bin/ height=480 alt="Java not installed properly" width=640 code=TestJSObject MAYSCRIPT><PARAM NAME="_cx" VALUE="16933"><PARAM NAME="_cy" VALUE="12700"></APPLET> 
<TABLE>
<TBODY>
<TR bgColor=#123456>
<TD>Testing 1</TD>
<TD>Testing 2</TD></TR></TBODY></TABLE></BODY>
all element=[ customer ]
item length=13
item 0 = !.localName=snull
item 1 = HTML.localName=snull
item 2 = HEAD.localName=snull
item 3 = TITLE.localName=snull
item 4 = META.localName=snull
item 5 = BODY.localName=snull
item 6 = !.localName=snull
Exception occured
Exception = ??o?????o?o??:item 8 = TABLE.localName=snull
item 9 = TBODY.localName=snull
item 10 = TR.localName=snull
item 11 = TD.localName=snull
item 12 = TD.localName=snull
Posted Date : 2008-08-19 16:37:16.0

This is the exception.printStackTrace() output from our production application.
 
netscape.javascript.JSException: ?????????????:
 at sun.plugin2.main.client.MessagePassingJSObject.newJSException(MessagePassingJSObject.java:227)
 at sun.plugin2.main.client.MessagePassingJSObject.waitForReply(MessagePassingJSObject.java:141)
 at sun.plugin2.main.client.MessagePassingJSObject.call(MessagePassingJSObject.java:67)
 at com.gs.eq.csc.merch.LiveBrowser.JSObjectHelper.getStringElementAttribute(JSObjectHelper.java:92)
 at com.gs.eq.csc.merch.LiveBrowser.GSLinkController.processDocument(GSLinkController.java:157)
 at com.gs.eq.csc.merch.LiveBrowser.LiveBrowserApplet.run(LiveBrowserApplet.java:464)
 at java.lang.Thread.run(Thread.java:619)
Posted Date : 2008-08-19 16:55:59.0
Work Around
N/A
Evaluation
There are two differences between the new plugin and the old plugin:

1. When call method on <applet> element, the new plugin actually try to call the method on the applet class. getAttribute method is mapped to get the filed of java class. Since the java applet class has no such field, a JSException is thrown.  The old plugin simply looks for the attribute of the <applet> HTML element.

2. JavaScript toString.

in new plugin the IExplorerPlugin.javaScriptToString() is different than the original code. It is just calling toString() on the JavaScript object. It is simpler,  but causes the difference in the string representations of html elements.

Need investigate further about the above compatibility issues.
Posted Date : 2008-10-08 00:13:29.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang