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

AppletContext.showDocument(URL u, String target) does not work with update 13

XMLWordPrintable

    • b03
    • b06
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_13"
      Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
      Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Starting with Java 6 update 12, AppletContext.showDocument(URL u, String target) does not work in IE 7 if "target" refers to a window that is already open.

      No exception is thrown in the console, but the window referred to by "target" does not load the given URL.

      If no window with the same name as "target" is currently open, a new IE window is open and is loaded with the given URL.

      The same call is working fine in Firefox 3.0.8, using the same Java version.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the attached WindowRedirector.java code.
      2. Copy WindowRedirector.class, index.html, and appwindow.html to a web server.
      3. Browse to index.html using IE 7 on Windows XP SP 3 with Java 6 update 13 installed. Disable all pop-up blockers.
      4. Enter some name in the "Change this window's name to" text field, and click the "Change" button.
      5. Click the "Open Redirector" button.
      6. In the smaller browser window that comes up, the WindowRedirector applet will be running. Enter the name you chose in step (4) in the "Window name" field, and some URL in the "URL" field.
      7. Click the "Redirect" button.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The window whose name was changed in step (4) should load the URL entered in step (6).
      ACTUAL -
      Nothing happens. The window named in step (4) does not change locations.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      =========================
      Source of WindowRedirect.java
      =========================

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

      public class WindowRedirector extends Applet implements ActionListener
      {
          private TextField m_nameField = null;
          private TextField m_urlField = null;
          private Button m_redirectButton = null;
          private TextField m_alertArea = null;

          public void init()
          {
              super.init();

              GridBagLayout layout = new GridBagLayout();
              GridBagConstraints c = new GridBagConstraints();

              Panel p = new Panel(layout);

              m_nameField = new TextField(20);
              m_urlField = new TextField(20);
              m_alertArea = new TextField(30);
              m_alertArea.setEditable(false);
              m_redirectButton = new Button("Redirect");
              m_redirectButton.addActionListener(this);

              c.weightx = 1.0;
              c.insets = new Insets(5, 5, 5, 5);
              c.anchor = GridBagConstraints.NORTHWEST;

              Label nameLabel = new Label("Window Name");
              layout.setConstraints(nameLabel, c);
              p.add(nameLabel);

              c.gridwidth = GridBagConstraints.REMAINDER;
              layout.setConstraints(m_nameField, c);
              p.add(m_nameField);

              c.gridwidth = 1;
              Label urlLabel = new Label("URL");
              layout.setConstraints(urlLabel, c);
              p.add(urlLabel);

              c.gridwidth = GridBagConstraints.REMAINDER;
              layout.setConstraints(m_urlField, c);
              p.add(m_urlField);

              c.gridwidth = GridBagConstraints.REMAINDER;
              layout.setConstraints(m_redirectButton, c);
              p.add(m_redirectButton);

              c.gridwidth = GridBagConstraints.REMAINDER;
              layout.setConstraints(m_alertArea, c);
              p.add(m_alertArea);

              add(p);
          }

          public void actionPerformed(ActionEvent evt)
          {
              URL theURL;

              m_alertArea.setText("");

              try {
                  theURL = new URL(m_urlField.getText());
              } catch (MalformedURLException mue) {
                  m_alertArea.setText("Invalid URL");
                  return;
              }

              m_alertArea.setText("Redirect window named " + m_nameField.getText() +
                                  " to " + theURL);

              getAppletContext().showDocument(theURL, m_nameField.getText());
          }
      }

      =================
      Source of index.html
      =================
      <html>
      <head>
      <title>Window Redirector Test Page</title>
      <script language="JavaScript">
      function openRedirector()
      {
          window.open("appwindow.html", "redir_applet", "resizable=no,width=500,height=200");
      }
      function changeMyName()
      {
          var nameField = document.getElementById("nameField");
          if (nameField != null) {
              window.name = nameField.value;
          }

          showWindowName();
      }
      function showWindowName()
      {
          var currName = document.getElementById("currName");
          if (currName != null) {
              currName.innerHTML = window.name;
          }
      }
      </script>
      </head>
      <body onload="showWindowName()">
      <form>
      <table border="0" cellpadding="5">
      <tr>
          <td align="left" colspan="3"><input type="button" value="Open Redirector" onclick="openRedirector();"/></td>
      </tr>
      <tr>
          <td>Change this window's name to:</td>
          <td><input type="text" id="nameField"></td>
          <td><input type="button" value="Change" onclick="changeMyName();"/></td>
      </tr>
      <tr>
      <tr>
          <td>This window's current name:</td>
          <td><div id="currName"></div></td>
      </tr>
      </table>
      </form>
      </body>
      </html>

      =======================
      Source of appwindow.html
      =======================
      <html>
      <head>
      <title>Window Redirector applet</title>
      </head>
      <body>
      <applet code="WindowRedirector.class" width="400" height="150"></applet>
      </body>
      </html>

      ---------- END SOURCE ----------

      Release Regression From : 6u11
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            ccheung Calvin Cheung
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: