Closed Bug 75588 Opened 24 years ago Closed 24 years ago

Exception thrown (for mayscript) when JSObject.getWindow() called in JAVA applet

Categories

(Core Graveyard :: Java: OJI, defect)

x86
Windows NT
defect
Not set
critical

Tracking

(Not tracked)

VERIFIED INVALID

People

(Reporter: bcortez, Assigned: joe.chou)

References

()

Details

(Keywords: crash, qawanted)

Tested on Mozilla Build: 2001041104


Using the new JRE from sun (j2re1_3_0_02-win.exe) an exception gets thrown when 
attempting to call JSObject.getWindow() in JAVA applet.

Note: When you view the source of the test page, the MAYSCRIPT parameter is 
present. This works in MSIE5+ as well.
Trace from the JAVA Console window:
===================================

JSObjectTestApplet: Entering init()

netscape.javascript.JSException: JSObject.getWindow() requires mayscript 
attribute on this Applet
	at java.lang.reflect.Constructor.newInstance(Native Method)
	at sun.plugin.liveconnect.PrivilegedConstructObjectAction.run(Unknown 
Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.plugin.liveconnect.SecureInvocation.ConstructObject(Unknown 
Source)
Added keywords: crash, qawanted, topcrash
For tracking purposes
Keywords: crash, qawanted, topcrash
This bug may be related to 61599.  It is simialr in nature, but doesn't throw a 
null pointer exception.  It seem to throw more of a security exception.
The test case uses an Object tag to embed an applet for LiveConnect. It is an
known issue (or problem) that LiveConnect currently does not work with Object
tags. Please try to use an Embed tag or an applet tag, and it should work.
Joe,  then why does LiveConnect work perfectly when MSIE uses the OBJECT tag?  
The plugin doesn't complain at all.  Is this a Mozilla/Netscape6 issue with the 
OBJECT tag?  
Tried with embed tag, it did not work. Stanley, is Embed tag supposed to work in
LiveConnect?

Tried with applet tag, it seemed work OK (see attachment below). 

Simplified test case:

HTML  file:

<html>
<head> <title>But 75588 test</title> </head>

<SCRIPT LANGUAGE="JavaScript">
function click_doit1()
{
        document.MyApplet.callJSAlert();
}
function showAlert(txt)
{
        alert ("JavaScript 'showAlert': called from " + txt);
}
</SCRIPT>

<body>
    <center>
      <h1>bug 75588 test</h1>
      <applet type="application/x-java-applet;version=1.3" NAME=MyApplet code=my
copy.class
        WIDTH=100 HEIGHT=100 MAYSCRIPT>
      </applet>
    </center>

    <form name=myForm>
        Test with call method:
        <input type=button name=myButton value="Test 1"
          onClick=click_doit1()>
    </form>
</body>
</html>

import java.applet.*;
import java.awt.*;
import java.util.Date;
import javax.swing.*;
import java.awt.event.*;
import netscape.javascript.*;

public class mycopy extends Applet {

   private static JSObject _jsWindow;


   public void init() {
      //String className = getClass().getName();
      System.out.println("Entering mycopy init(), and calling getWindow().");

      _jsWindow = JSObject.getWindow(this);
      if (_jsWindow == null) {
          System.err.println("getWindow() returned null.");
          return;
      } else {
          System.out.println("getWindow() return non-null.");
      }
   }

   public void callJSAlert() {
      System.out.println("Entering callJSAlert.");
      // Call a javascript function that launches an alert box directly
      String[] msgs;
      msgs = new String[1];
      msgs[0] = "This alert box was called from callJSAlert()";
      _jsWindow.call("showAlert", msgs);

   }
}
The APPLET tag may work, however, the APPLET tag and the EMBED tag are 
deprecated in the HTML4 specification.  The OBJECT tag has been promoted to 
handle all elements in place of the APPLET and EMBED tags.  If we are trying to 
follow the W3C specifications, shouldn't we be trying to get the OBJECT tag 
working with LiveConnect within a JAVA applet?
Keywords: topcrash
Marking NEW while its discussed.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Joe, can you please own this bug?  Is this bug equivalent to "LiveConnect 
should work with OBJECT or EMBED tag" or do we need to file a separete bug?
Assignee: edburns → joe.chou
Currently, LiveConnect works with Applet tag, which has MAYSCRIPT attribute to
allow communication from Java to JavaScript. On the other hand, other tags
(i.e., Object, Embed, etc.) do not work with LiveConnect. The walk around here,
if possible, is to use Applet tags. To make other tags working with LiveConnect
may be enhanced in a future release when time permits.
The reason for the exception about missing mayscript is that OBJECT tag was
used, instead of the tags (EMBED or APPLET)that work for Nectscape's
LiveConnect. Object tag has not been implemented for LiveConnect in Netscape
(either 4.x or 6.x). The same test case won't work in 4.x either. After changing
OBJECT tag to either EMBED tag or APPLET tag, the test case worked. No crashing,
no exception.
Therefore, the original test case is invalid (using something not supported),
and the walk-around is to use either embed or applet tag, instead of object tag.
If requesting the support of object tag for liveConnect in the future release,
please write the request in a new bug. 
Marking this bug invalid.  
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → INVALID
Be that as it may, the fact still stands that both the APPLET and EMBED tags 
have been already been deprecated in the W3C HTML4 specification in favor of 
the OBJECT tag.  If the OBJECT tag is not supported in Mozilla, then (sadly) 
Mozilla CANNOT claim full HTML4 compliance for it's browser.  That being said, 
I will submit a new bug as a feature request for implementation in a future 
release.

New bug created for this enhancement request (Bug 80802).
SPAM: reassigning OJI bugs to new QA, pmac. (227 bugs)
QA Contact: shrir → pmac
verified
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.