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

window.opener reference is changed during redirect from Applet in Java 1.7.0_04-

XMLWordPrintable

    • b20
    • 7u4
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.7.0_04"
      Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
      Java HotSpot(TM) Client VM (build 23.0-b21, mixed mode, sharing)

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

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      My Tests only work in Firefox (behavior is seen in all versions)

      A DESCRIPTION OF THE PROBLEM :
      I ran into an issue with the javascript property `window.opener` (which keeps a reference to the window that opened the popup) in conjunction with a redirect from within an applet. Whenever a redirect happens from within the applet, `window.opener` was changed to the current pop-up. Even stranger is the fact that this change was introduced with a recent java update quite recently: this did not happen with `java 1.7.0_03-b05` but started happening with `java 1.7.0_04-b20`. Now this might be some exotic usecase but still, I'm wondering if this change was intentional.

        To get to the bottom of this I have written a small test to demonstrate the behavior in question. The HTML-Sites can be found here: http://files.newsnetz.ch/applet_test



      REGRESSION. Last worked in version 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      0. Install java 1.7.0_04-b20
      1. Open HTML at: http://files.newsnetz.ch/applet_test
      2. Click Link 'open applet.html in new window'
      3. In the popup-window within the applet, click Button 'Redirect now!'

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      1. After clicking the link in `index.html`, `applet.html` is opened in a popup window. The alert shows `index.html` as being the openers name. Then the backgroundcolor of the opener is changed to red
        2. After clicking the button in the applet `redirect.html` is opened in the same window. The alert shows `index.html`as being the openers name. Then the backgroundcolor of the opener is changed to green
      ACTUAL -
      1. After clicking the link in `index.html`, `applet.html` is opened in a popup window. The alert shows `index.html` as being the openers name. Then the backgroundcolor of the opener is changed to red
        2. After clicking the button in the applet `redirect.html` is opened in the same window. The alert shows 'redirect.html` as being the openersname. Then the backgroundcolor of the opener (which is the popup-window now!) is changed to green.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Here's the code of the applet used for the redirect:



      import java.applet.Applet;
      import java.awt.Button;
      import java.awt.FlowLayout;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.net.MalformedURLException;
      import java.net.URL;
      import java.util.logging.Level;
      import java.util.logging.Logger;

      public class HelloWorldApplet extends Applet implements ActionListener {

          Button redirectButton;
          
          @Override
          public void init() {
              super.init();
              
              setLayout(new FlowLayout());
              redirectButton = new Button("Redirect now!");
              add(redirectButton);
              
              redirectButton.addActionListener(this);
          }

          @Override
          public void actionPerformed(ActionEvent ae) {
              try {
                  this.getAppletContext().showDocument(new URL(this.getDocumentBase(), "redirect.html"), "_self");
              } catch (MalformedURLException ex) {
                  Logger.getLogger(HelloWorldApplet.class.getName()).log(Level.SEVERE, null, ex);
              }
          }
      }

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

            nam Nam Nguyen (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: