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

JSException when APPLET tag is written dynamically to HTML document inside FRAME

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.4.2, 1.4.2_03
    • Fix Version/s: 1.4.2_06
    • Component/s: deploy
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      06
    • CPU:
      x86
    • OS:
      windows_2000
    • Verification:
      Verified

      Backports

        Description

        This bug appears to be related to bug 4751259, which was fixed in 1.4.1_07 and 1.4.2_02. The attached test case demonstrates the same behavior as reported in bug 4751259 in all versions prior to the integration of the fix for that bug. The test case is different from bug 4751259, however, in that the HTML page which writes the APPLET tag dynamically is inside the FRAME of another HTML page. With 1.4.1_07, 1.4.2_02 - 1.4.2_03, and 1.5.0-beta, running this test case with IE on Windows fails with the error:

        "Before call - watch for alert.
        the function name is openHTMLTool
        document.location.href: http://dtstest15.east:8080/plugintest/mrfrm.htm
        JavaScript: Javascript exception
        netscape.javascript.JSException: Unknown name.
        After call"


        There is no problem with Mozilla 1.6 or Netscape 7.1. The test case output with those browsers is:

        "Before call - watch for alert.
        the function name is openHTMLTool
        document.location.href: http://dtstest15.east:8080/plugintest/mr_ie.htm
        After call"

        Note the difference in the document.location.href.

        There is also no problem with IE on the later plugin versions if the HTML page which writes the APPLET tag dynamically is NOT contained inside a FRAME, or if the HTML page contained inside the frame has the APPLET tag written explicitly inside the HTML instead of being generated dynamically.


        Test Case:


        mrfrm.htm:
        -----------------------------------------------------------------
        <HTML>
        <HEAD>
        <TITLE>I GOT FRAMED.</TITLE>
        </HEAD>
        <FRAMESET ROWS="90,*" FRAMEBORDER="NO" BORDER=0 FRAMESPACING=0>
        <FRAME NAME="MRETOP" SRC="hhh.htm" SCROLLING="NO" MARGINWIDTH=0 MARGINHEIGHT=0 MARGINHEIGHT=0>
        <FRAME NAME="MRERIGHT" SRC="mr_ie.htm" SCROLLING="YES" MARGINWIDTH=0 NORESIZE MARGINHEIGHT=0 MARGINHEIGHT=0>
        </FRAMESET>
        </HTML>
        -----------------------------------------------------------------


        hhh.htm:
        -----------------------------------------------------------------
        <HTML>
        <title> Top Frame </title>
        <body bgcolor=lime>
        <h1>I got framed.</h1>
        </body>
        </HTML>
        ------------------------------------------------------------------


        mr_ie.htm:
        ------------------------------------------------------------------
        <HTML>
        <HEAD>
        <TITLE>Logon to WebFOCUS MRE</TITLE>
        <SCRIPT LANGUAGE="JavaScript">

        function openHTMLTool()
        { alert("HELLO, I am in the openHTMLTool");
        }

        function ibilangtransonload()
        { alert("DEBUG");
           var innerHTML = "<APPLET CODE='PanelTest2.class' MAYSCRIPT NAME='PanelTest2' ID='PanelTest2' HEIGHT=475 WIDTH=700>";
           innerHTML += "</APPLET>";
           document.getElementById("layerDomainAdmin").innerHTML = innerHTML;
           return;
        }
        </SCRIPT>
        </HEAD>
        <BODY ONLOAD="ibilangtransonload()">
        <DIV ID="layerDomainAdmin" STYLE="display=block"></DIV>
        </BODY>
        </HTML>
        --------------------------------------------------------------------


        PanelTest2.java:
        --------------------------------------------------------------------
        import java.applet.Applet;
        import java.applet.AppletContext;
        import java.awt.*;
        import java.awt.event.*;
        import java.util.*;
        import netscape.javascript.JSObject;
        import netscape.javascript.JSException;

        public class PanelTest2 extends Applet{
            Vector bloppo = new Vector();
            JavaScript jscript;
            public void init()
            {
             Button eButton = new Button("GOFORIT");
             Panel center = new Panel();
             center.add(eButton);
             add(center);
             jscript = new JavaScript(this);
             System.out.println("Before call - watch for alert.");
              jscript.call("openHTMLTool",bloppo);
              System.out.println("After call ");
            }
        }// end of class
        --------------------------------------------------------------------


        JavaScript.java:
        --------------------------------------------------------------------
        import java.applet.Applet;
        import java.applet.AppletContext;
        import java.util.Vector;
        import netscape.javascript.JSObject;
        import netscape.javascript.JSException;

        public class JavaScript extends Object {
            private Applet applet;
            
            public JavaScript(Applet inApplet) {
               this.applet = inApplet;
            }
          
            public boolean call(String functionName,Vector arguments) {
                String [] args;
                System.out.println("the function name is " + functionName);
                JSObject window=null;
                try {
                    window = JSObject.getWindow(applet);
                    JSObject doc = (JSObject)window.getMember("document");
                    JSObject loc = (JSObject) doc.getMember("location");
                    String s = (String)loc.getMember("href");
                    System.out.println("document.location.href: " + s);

                    if (arguments == null) {
                        args=null;
                    }
                    else {
                        int size=arguments.size();
                        args=new String[size];
                        for (int index=0;index<size;index++) {
                            args[index]=(String) arguments.elementAt(index);
                        }
                    }
                    window.call(functionName,args);
                }
                catch (netscape.javascript.JSException ex) {
                    System.out.println("Javascript exception");
                    ex.printStackTrace();
                    return false;
                }
                return true;
            }
        }
        ----------------------------------------------------------------------



        Steps to reproduce:

        1. Place all above files in web server doc root, e.g. C:\Program Files\Apache Group\Apache2\htdocs\plugintest.
        2. Compile Java source. (need to include plugin.jar in classpath)
        3. With 1.4.2_03 JRE installed on system, for example, bring up http://&lt;host:port&gt;/plugintest/mrfrm.htm in IE. You will see the error in the plugin console. Netscape and Mozilla will not throw an error.
        4. Now access http://&lt;host:port&gt;/plugintest/mr_ie.htm with IE directly. You will not see the error.
        5. Now change mr_ie.htm to:

        "<HTML>
        <HEAD>
        <TITLE>Logon to WebFOCUS MRE</TITLE>
        <SCRIPT LANGUAGE="JavaScript">

        function openHTMLTool()
        { alert("HELLO, I am in the openHTMLTool");
        }


        </SCRIPT>
        </HEAD>
        <BODY>
        <APPLET CODE='PanelTest2.class' MAYSCRIPT NAME='PanelTest2' ID='PanelTest2' HEIGHT=475 WIDTH=700>
        </APPLET>
        </BODY>
        </HTML>"

        and bring up http://&lt;host:port&gt;/plugintest/mrfrm.htm in IE. You will not see the error.
        ###@###.### 2004-03-12
        ###@###.### 2004-03-25

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                djayaramsunw Devananda Jayaraman (Inactive)
                Reporter:
                klevesqusunw Kim Levesque (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: