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

JSObject.eval does not work properly in case of nested call in Firefox/Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • tbd
    • 6u10
    • deploy
    • x86
    • windows_xp

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

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

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Firefox 3.6.3

      A DESCRIPTION OF THE PROBLEM :
      The applet calls some function of window object in start() method, then JavaScript code of this function calls applet's method in which JSObject.eval is called on the window object. It works properly in Firefox/Linux but does not execute eval's code in Firefox/Windows.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start applet.xhtml in Firefox.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      [alert] call applet.f()...
      [JavaConsole] window.alert...
      [alert] here
      [JavaConsole] window.alert done
      [alert] done
      ACTUAL -
      [alert] call applet.f()...
      [JavaConsole] window.alert...
      [JavaConsole] window.alert done
      [alert] done

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      TestApplet.java

      package test;

      import javax.swing.JApplet;

      import netscape.javascript.JSObject;

      public class TestApplet
      extends JApplet
      {
          @Override
          public void start()
          {
              JSObject window = JSObject.getWindow(this);

              window.call("load", new Object[0]);
          }

          public void f()
          {
              JSObject window = JSObject.getWindow(this);

              System.out.println("window.alert...");
              window.eval("alert('here');");
              System.out.println("window.alert done");
          }
      }

      applet.xhtml
      <?xml version="1.0" encoding="UTF-8" ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
          <title>Applet test</title>

          <script><![CDATA[
            function load()
            {
              var applet = document.getElementById("applet");
              alert('call applet.f()...');
              applet.f();
              alert('done');
            }

            function test()
            {
              var applet = document.getElementById("applet");
              applet.f();
            }
          ]]></script>
        </head>

        <body>
          <applet id="applet"
                  codebase="."
                  archive="applet.jar"
                  code="test.TestApplet"
                  mayscript="mayscript">
          </applet>

          <button onclick="test();">Test</button>
        </body>
      </html>

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

      CUSTOMER SUBMITTED WORKAROUND :
      The issue seems to be valid only while some JSObject.eval call is already processing. It would be possible to work around this by calling the other JSObject.eval in the other thread but it is not sufficient.

      public void f()
      {
          Thread t = new Thread()
          {
              public void run()
              {
                  JSObject window = JSObject.getWindow(TestApplet.this);

                  System.out.println("window.alert...");
                  window.eval("alert('here');");
                  System.out.println("window.alert done");
              }
          };
          t.start();
      }

      Also does not work. But it starts working if you add Thread.sleep() prior to window.eval. So I think it's necessary to add synchronization but I don't know what is the object to synchronize with.

      SUPPORT :
      YES

            almatvee Alexander Matveev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: