JDK-5028727 : Instead of _self, showDocument(..., _self) shows in the _top frame
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-04-08
  • Updated: 2004-04-08
  • Resolved: 2004-04-08
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 04/07/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 2000 5.00.2195 Service Pack 4

A DESCRIPTION OF THE PROBLEM :
This scenario has not worked since 1.3....

I load an applet in a frame and upon submission by the user, the applet does the following to show a new document:

  UrlOnError = false;
  try{
    userUrl = new URL(getCodeBase().toString() + "new.cgi?" + Key);
  }
  // You MUST try-catch this method.
  // If it is still wrong then we'll show an error message too.
  catch (Exception e){
    UrlOnError = true;
  }
  getAppletContext().showDocument(userUrl,"_self");

In 1.5, the URL replaces "_top" instead of  "_self"

REPRODUCIBLE TEST CASE :
-------------------Frame1.html-------------------
<HTML><HEAD></HEAD><BODY>
<center>Compiled under 1.5.0 on Windows 2K<br/>
Frame 2's applet resides in a DIV and Frame 3's applet resides in the document body.<br/>
<b>For Internet Explorer 6.0 Running 1.5.0:</b><br/>
When we perform a <b>getAppletContext().showDocument(userUrl,"_self")</b> on Frame 2, _top gets replaced.<br/>
Frame 3 works properly only from the document body.<br/>
<b>For Internet Explorer 6.0 Running MS VM:</b><br/>
Response is as expected on both frames: Frame 2 acts just like Frame 3.<br/>
<b>For Netscape 7.2 Running 1.5.0:</b><br/>
Absolutely no response from the button clicks!<br/>
</center>
</BODY></HTML>

-------------------Frame2.html-------------------
<HTML><HEAD></HEAD>
  <SCRIPT LANGUAGE="JavaScript">
  function doApp(){
    v='<center><br/>FRAME 2<br/>Click the button and this frame <b>incorrectly</b> refreshes to "_top" instead of "_self" <b>ALWAYS</b>.<br/>'
    v+='This applet resides in a <b>DIV</b>.<br/><br/>'
    v+='<applet code="testShowdoc.class" width=500 height=120  >'
    v+='<param name=newURL value=frame2>'
    v+='</applet></center>';
    document.getElementById('div02').innerHTML = v;
  }
  </SCRIPT>
  <BODY onload= doApp()>
<div id = 'div02'></div>  </BODY>
</HTML>

-------------------Frame3.html-------------------
<HTML><HEAD></HEAD>
  <SCRIPT LANGUAGE="JavaScript">
  function doApp(){
    v='<center><br/>FRAME 3<br/>Click the button and this frame <b>correctly refreshes to "_self" always</b>.<br/>'
    v+='This applet resides in the document body.<br/><br/>'
    v+='<applet code="testShowdoc.class" width=500 height=120  >'
    v+='<param name=newURL value=frame3>'
    v+='</applet></center>';
    document.write(v);
  }
  </SCRIPT>
  <BODY onload= doApp()>
<div id = 'div02'></div>  </BODY>
</HTML>

-------------------Index.html-------------------
<HTML><HEAD></HEAD>
  <FRAMESET ROWS="30%, 35%, 35%" BORDER=5>
      <FRAME SRC="frame1.html" NAME="F1" MARGINHEIGHT=1 MARGINWIDTH=1>
      <FRAME SRC="frame2.html" NAME="F2" MARGINHEIGHT=1 MARGINWIDTH=1>
      <FRAME SRC="frame3.html" NAME="F3" MARGINHEIGHT=1 MARGINWIDTH=1>
  </FRAMESET>
</HTML>

-------------------testShowdoc.java-------------------
import java.awt.*;
import java.net.*;
import java.applet.*;
import java.awt.event.*;

public class testShowdoc extends Applet implements ActionListener{
  String newURL = new String();
  URL userUrl;
  Button signInButton;
  public void init(){
    newURL = getParameter( "newURL" );
    signInButton = new Button("Get New Contents for _self");
    signInButton.setEnabled(true);
    signInButton.addActionListener(this);
    setBackground(Color.yellow);
    setLayout(null);
    add(signInButton);
    signInButton.setEnabled(true);
    signInButton.setBounds(145, 40, 180, 20);
  }
  //***********************************************************************************//
  public void actionPerformed(ActionEvent act){
      // You MUST try-catch this method.
      // If it is still wrong then we'll show an error message too.
      boolean UrlOnError = false;
      try{
          if(newURL.compareTo("frame2") == 0)
            userUrl = new URL(getCodeBase().toString() + "Frame2.html");
          if(newURL.compareTo("frame3") == 0)
            userUrl = new URL(getCodeBase().toString() + "Frame3.html");
      }
      catch (Exception e){
        UrlOnError = true;
      }
      getAppletContext().showDocument(userUrl,"_self");
  }
}

Load an applet in a frame and
getAppletContext().showDocument(userUrl,"_self");



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected that the frame would be the target of the URL and not _top.
ACTUAL -
_top became the target and the browser's top frame was replaced with
the response of the url.

REPRODUCIBILITY :
This bug can be reproduced always.
(Incident Review ID: 238174) 
======================================================================