Closed Bug 61488 Opened 24 years ago Closed 23 years ago

Javascript calls to Java functions fail.

Categories

(Core Graveyard :: Java: OJI, defect, P3)

x86
Windows 2000
defect

Tracking

(Not tracked)

VERIFIED DUPLICATE of bug 80802

People

(Reporter: chris, Assigned: joe.chou)

References

()

Details

(Whiteboard: oji_escalation)

Attachments

(1 file)

On the page at the URL given, clicking the "Test" button attempts to make a 
call to the "loopTest" function of the Java applet.  Mozilla does not call the 
function, but rather throws the Javascript exception "TestApplet.loopTest is 
not a function".

Using:
Mozilla nightly, Build ID: 2000111304
Windows 2000 sp1.

The function does get called under Internet Explorer, which later deadlocks due 
to a different problem (detailed in the HTML page).
Confirming on WinNT with debug trunk build 2000-11-23. Here is the HTML 
at the test URL. Note the applet is at this tag below:

            <object name="TestApplet" id="TestApplet"  etc. etc. 


<html>
<head>
<title>Test</title>
</head>
<body>

<p>Clicking the "Test" button makes calls the "loopTest" function of the Java 
applet.  The loopTest function attempts to read the "value" attribute of the 
button, which deadlocks IE.  Mozilla does not even call the function, throwing a 
Javascript exception "TestApplet.loopTest is not a function".</p>

<form id="testform" name="testform">
  <input name="button1" type="button" value="Test"                                                                             
onclick="TestApplet.loopTest()"/><br/>
</form>

<object name="TestApplet" id="TestApplet" 
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="300" height="100" 
codebase="j2re1_3_0-win.exe#Version=1,3,0,0" mayscript="true" scriptable="true">
<param name="type" value="application/x-java-applet;version=1.3"/>
<param name="mayscript" value="true"/>
<param name="scriptable" value="true"/>
<param name="code" value="Test1Applet"/>
</object><br/>

<a href="Test1Applet.java">Test1Applet.java</a><br/>
<a href="compile.bat">compile.bat</a><br/>

</body>
</html>



Reassigning to OJI component - 
Assignee: rogerl → edburns
Status: UNCONFIRMED → NEW
Component: Live Connect → OJI
Ever confirmed: true
QA Contact: pschwartau → shrir
And Chris has provided the source code for the applet at his URL. 
For convenience, here it is:


import javax.swing.*;
import netscape.javascript.*;

public class Test1Applet extends JApplet {

  public Test1Applet() {
    return;
  }

  public void loopTest() {
    JSObject window = JSObject.getWindow(this);
    JSObject document = (JSObject)window.getMember("document");
    JSObject testform = (JSObject)document.getMember("testform");
    JSObject button1 = (JSObject)testform.getMember("button1");
    System.err.println(String.valueOf(button1.getMember("value")));
    return;
  }
}
Reassign to Jeff.  You may want to see the thread in the newsgroup
netscape.public.mozilla.oji.
Assignee: edburns → jeff.dyer
Status: NEW → ASSIGNED
The test case does not work in N4.x. I think the applet should be derived from 
Applet, rather than JApplet. With that change, it will still fail as described 
in 59447. Marking duplicate

*** This bug has been marked as a duplicate of 59447 ***
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
It still fails.
It works fine in IE.
Not that it should matter (it's the plugin) but I have created a new test, only 
extending Applet.
I have updated the URL.
You marked this as a duplicate of a Java->JS bug, when this is a JS->Java bug. 
With this new test I have also removed any references to JSObject, just to make 
the differentiation between this and the other bug clear....

----------
import java.applet.*;

public class Test5Applet extends Applet {

  public Test5Applet() {
    return;
  }

  public void someFunction() {
    System.err.println("Function Call Success!!!");
    return;
  }

}
-----
All the button on the page does is call this function.
It fails with the same error detailed in this report.
I am now using Build ID 2000121804. (Last night).  I have tried on Windows 
2000, and NT4 (different boxes).  It fails under both.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
*** Bug 73271 has been marked as a duplicate of this bug. ***
Reassigning to Joe
Assignee: jeff.dyer → joe.chou
Status: REOPENED → NEW
Reporter:
    The javascript call java is ok now. Please use the latest trunk and test it. 
Something about your testcase, in your html file, you should use sperate tag for 
IE and mozilla. Mozilla does not support object tag that well. You can use html 
converter from Sun to do this.
   
Add Xiaobin
Thank you very much for fixing this! :-)  I will test when I have a chance to 
download the latest build.

And, No, I should /not/ be using separate tags for IE and Mozilla.  Or for 
Opera, Konqueror, GTK_HTML, AOL, etc, etc, etc, etc, etc.  I shouldn't be doing 
anything special or specific to /any/ browser.  What I should be doing, and 
what I am doing, is writing browser neutral HTML that complies with, and 
validates againsed, the HTML specifications.  And you are right, Mozilla does 
not support the Object tag that well, which means IT is /broken/ 
and /uncompliant/ with the HTML specifications, and IT should be fixed, not my 
web page.
Adding appropriate status to the Status Whiteboard to note high priority of this
bug.  Priority of this bug should probably be changed as well by the owner.
Whiteboard: oji_escalation
Was code checked in to fix this bug? Where is the diff?
The fix will be bundled into next release of Java Plugin 1.4.
Status: NEW → ASSIGNED
I made mistake here. I thought this was 46518. 

Please see patch from 82034.
The test case here is basically trying to make a simple call from JavaScript to
Java and embed an applet in an object tag. The problem is the object tag. Object
tag is not supported to do liveconnect in Netscape (neither in 4.x nor 6.x).
There is an existing enhancement request to add support to object tag in
liveconnect (#80802).
A work-around for this test case is to use applet tag instead of object tag. I
tried it and it worked.
 
Reporter, 
in your case, could you use applet tag instead? Or you have to use object tag?
If you could use applet tag, try it on a today's trunk build (fix of 83698 was
checked in last night), and it should work.
I'm confused. It seems like the APPLET/OBJECT/EMBED story got worse after 6.0? 
On OS/2, we were able to take the code in nsHTMLAppletElement and duplicate it 
in nsHTMLObjectElement and nsHTMLEmbedElement and we shipped with LiveConnect 
working for all three.

It seems like the rearchitect to remove Get and SetScriptObject changed all 
this?

I'm attaching a 6.01 diff
In case you couldn't tell :-) I'm a purist.  I try to create web sites the way 
they should be done.
The XHTML Modularization specification at:
http://www.w3.org/TR/2001/REC-xhtml-modularization-
20010410/abstract_modules.html#s_appletmodule
States in section 5.3:
     "This module is deprecated. Similar functionality can be found in the 
Object Module."
My point here is not how hard to make changes to support object and embed tag in
liveconnect (actually it should be just expend the liveconnect tag set to
include embed and object tags), I am just pointing out two facts:
1) Currently object tag is not supported (either 4.x or 6.x), and there is a 
   request for supporting it.
2) There is a workaround, which is to use applet tag for now.

Thanks for the attachment, and it may be used for reference when 80802 is being 
worked on. 
By the way, since you've already made the change in OS2 to support embed and
object tag, why wasn't it ported to mozilla? The change seems platform
independant. Also a question about the changes in the attachment: did you have
to make the similar changes in all three tags (and maybe more tags in the
future), or can you make references to one change? Like making one routine
reference by all three tags, instead of making three similar routines?
Reporter,
If the issue here is to make the test case work for you, and object tag can be
replaced by applet tag, then if you have the latest trunk build (today's or
later), it should work for you. 
Other the other hand, if the issue here is about using object tag in
liveconnect, then it will be resolved in 80802. 
Which one is it?

*** This bug has been marked as a duplicate of 80802 ***
Status: ASSIGNED → RESOLVED
Closed: 24 years ago23 years ago
Resolution: --- → DUPLICATE
The issue here is using the object tag with liveconnect.  I have no problem 
with this being marked as a dup of bug 80802.  This is naturally based on the 
assumption that the fixes for bug 80802 will also fix the test case for this.
SPAM: reassigning OJI bugs to new QA, pmac. (227 bugs)
QA Contact: shrir → pmac
verified dup
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: