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

Firefox: Passing Java objects between 2 applet instances through JS

XMLWordPrintable

    • generic, x86
    • generic, windows_7

      FULL PRODUCT VERSION :
      Java Plug-in 1.6.0_21
      Using JRE version 1.6.0_21-b07 Java HotSpot(TM) Client VM

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 Ultimate, x64

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Firefox 3.6.10

      A DESCRIPTION OF THE PROBLEM :
      Two instances of the same applet run on a page. A JavaScript script calls a method on the first applet that returns an object, and passes that object to a method on the second applet. This works fine under IE and Chrome, but does not work under Firefox. It used to work under Firefox too until a few weeks ago, but we are not sure if the problem apepared because of a new version of the browser or the Java runtime.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      We have uploaded a page that reproduces this here -
      http://mindfusion.eu/_samples/MultiApplets/test.html

      The full code for the test is here -
      http://mindfusion.eu/_samples/MultiApplets/MultiApplets.zip

      Try the following steps in IE8, Google Chrome and Mozilla Firefox:

      1. Open the test page.
      2. Open the Java console.
      3. Hit the 'test' button.

      IE and Chrome print "xyz" in the console, a value which is passed via an object between the applets. Firefox displays nothing in the Java console, but shows the following in its own Error console:

      Error: uncaught exception: java.lang.IllegalArgumentException: No method found matching name setTest and arguments [sun.plugin2.main.client.MessagePassingJSObject]

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The Java console should display "xyz" from Firefox too.
      ACTUAL -
      The Java Console displays nothing. An error appears in the Firefox Error Console.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Error: uncaught exception: java.lang.IllegalArgumentException: No method found matching name setTest and arguments [sun.plugin2.main.client.MessagePassingJSObject]

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // LiveConnectTest.java
      package test;

      import java.applet.Applet;

      public class LiveConnectTest extends Applet
      {
      public Test getTest() { return new Test(); }
      public void setTest(Test test) { System.out.println(test.getLabel()); }
      }

      // Test.java
      package test;

      public class Test
      {
      private String label = "xyz";

      public void setLabel(String label) {
      this.label = label;
      }

      public String getLabel() {
      return label;
      }
      }

      *** test.html ***
      <html>

      <head>
      </head>

      <body>

      <applet id="applet1" code="test.LiveConnectTest.class" width="64" height="64" mayscript>
      </applet>

      <applet id="applet2" code="test.LiveConnectTest.class" width="64" height="64" mayscript>
      </applet>

      <input type="button" value="test" onClick="test();" />

      <script language="JavaScript">
      function test()
      {
      var app1 = document.getElementById("applet1");
      var app2 = document.getElementById("applet2");
      app1.setTest(app2.getTest());
      }
      </script>

      </body>
      </html>
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: