Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6738770

REGRESSION:JSException throws when use LiveConnect javascript facility to navigate HTML elements

    Details

    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b03
    • CPU:
      x86
    • OS:
      windows_xp

      Backports

        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 netscape.javascript.JSException;
        import netscape.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: [object HTMLDocument]
        documentElement = [object 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=[object 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: [object]
        documentElement = [object]
        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=[object]
        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
        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)

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  hdongorcl Hao Dong (Inactive)
                  Reporter:
                  tyao Ting-Yun Ingrid Yao (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: