Closed Bug 56430 Opened 24 years ago Closed 23 years ago

JavaScript access to Java Applet fails.

Categories

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

x86
Linux
defect

Tracking

(Not tracked)

RESOLVED INVALID
Future

People

(Reporter: stevek, Assigned: joe.chou)

References

()

Details

(Whiteboard: [relnote-devel])

Attachments

(1 file)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.16-3 i686; en-US; m18) Gecko/20001010
BuildID:    2000101015 (M18)

This page has a small applet called "SizeDetect", which simply uses Java to
determine the user's screen resolution.  There is then some JavaScript called
from an onLoad, which attempts to access the Java Applet's properties to get the
screen resolution.  This code works properly on all other Browser platforms, but
causes an Error (no description) under Mozilla M18 at Line 31. Line 31 is the
following: " if (document.SizeDetect != null){".  SizeDetect is the name of the
Applet.


Reproducible: Always
Steps to Reproduce:
With Linux M18 with JVM installed, Go to URL http://live.horizonlive.com/, click
on "Launch HorizonLive".  See JavaScript Console for errors.


Actual Results:  Got Window saying size not detected, got JavaScript Errors.


Expected Results:  Not get window saying size not detected, not get JavaScript
Errors.

NOTE: Only tried this with PC/Linux, not other platforms.  Also happened with
2000101021 build.
Using Mozilla MN6 branch build 2000102309 on WinNT. The script 
uses an <APPLET> tag with name = "SizeDetect", and then tries 
to access it via

                    document.SizeDetect

This works in NN4.7, but is not working in Mozilla 
(document.SizeDetect evaluates to null). I will attach a reduced
testcase below - here is the HTML for it:


<HTML>
<HEAD>
<TITLE>Bug 56430</TITLE>

<SCRIPT language="JavaScript">

function setres() 
{
  var x_val, y_val;   

    if (document.SizeDetect == null)
    {
      alert("document.SizeDetect ==  null");
    }
    else
    {
      x_val = document.SizeDetect.x;
      y_val = document.SizeDetect.y;    

      if(x_val != null)
      {
        alert( "HorizonOpts="  + escape(x_val)   +   " x " + escape(y_val));                       
      }
      else
      {
        alert("document.SizeDetect.x  ==  null");
      }
    }
}
</SCRIPT>
</HEAD>

<BODY BGCOLOR="#ffffff"  onload="setres();">
       <APPLET code="SizeDetect.class" width="2" height="1"
        codebase="http://208.185.32.64/classes" name="SizeDetect"></APPLET>
</BODY>

</HTML>

Using Mozilla MN6 branch builds 2000102309 on WinNT, Linux.
When I click on the above testcase in NN4.7 or IE4.7, I get
an alert saying

                  HorizonOpts = 1286 x 1024


While I wait for it to come up , I see these messages in the status bar:

                  "Starting Java",
                  "Applet SizeDetect running"


But in Mozilla, I get the alert saying

                  "document.SizeDetect == null"


On Linux, I got a simultaneous dialog stating I needed to download
the Java 2.0 plugin. I did this and got a "Successful install" message.
I closed Mozilla and started it again. This time I CRASHED when I tried
to load the reduced testcase above. I saw these messages in the debug 
console just before I crashed:

Error loading URL 
http://bugzilla.mozilla.org/showattachment.cgi?attach_id=17842: 804b0002 
Create instance called in JavaPluginFactory5!!!!!!!!
 Succeeding in creating proxy
Register Env [0] proxyenv=142434328 tid=134579240
initilizing the java plugin instantance 


(CRASH)



On WinNT I never got any dialog about the Java 2.0 plugin.
It looks like I have Java Plug-in 1.2.2. installed on WinNT.
I just got the alert 


                  "document.SizeDetect == null"
I have the feeling this belongs over in OJI rather than in LiveConnect.
Reassigning; please reassign back if you feel this is LiveConnect -
Assignee: rogerl → edburns
Status: UNCONFIRMED → NEW
Component: Live Connect → OJI
Ever confirmed: true
QA Contact: pschwartau → shrir
Forgot to note - I get no errors in the JavaScript console from the 
reduced testcase. I believe the error the reporter noted is due to 
document.SizeDetect evaluating to null.
Can't test this without working java bits.
Depends on: 57004
Summary: JavaScript access to Java Applet variables fails with unspecified Error → JavaScript access to Java Applet fails.
No longer depends on: 57004
I get this error:

sun.plugin.liveconnect.OriginNotAllowedException: JavaScript is not from the
same origin as the java code, caller=http://live.horizonlive.com,
callee=http://208.185.32.64/classes/

Adding Jeff Dyer.  Jeff, can you please take a look at this?  Does this bug
depend on bug 53849?
Status: NEW → ASSIGNED
This applet may need to be signed.  After putting this in my java.policy file, I
get no errors in the JavaScript or Java Consoles:

grant {
  permission java.security.AllPermission;
};

Signing the applet should fix the problem.  Marking invalid.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → INVALID
Signing the applet wouldn't necessarily help. The applet tag sets the code base 
to 
codebase="http://208.185.32.64/classes". The problem is that the Livconnect 
security policy says that the page and the applet must be from the same origin, 
even if the page is the one that specified the different origin of the applet. 
This is a design incompatibility between 4.x and 6.0. Its a valid browser bug, 
but I'm not sure who should own it. (Apparently, I'm not powerful enough to 
reverse the Invalid status. Ed, could you do it.)
Thanks for your comments jeff.  Adding [relnote-devel] And marking FUTURE so
Jeff's comments will get into the relnotes.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
Whiteboard: [relnote-devel]
Target Milestone: --- → Future
I'm taking the liberty of marking ASSIGNED and setting the mozilla0.9 milestone 
keyword.

/be
Status: REOPENED → ASSIGNED
Keywords: mozilla0.9
Jeff, can you take a stab at solving this?
Assignee: edburns → jeff.dyer
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
Using Mozilla Build ID 2001020208 on Linux Redhat 6.2 I'm still getting this
bug. It's not a problem with Windows.  

Interestingly enough the FIRST time the script checks to see if the applet ==
null it returns true, the SECOND time it tries to do the same thing it does not
return null.

Changing the 
reduced test case to: 

if (document.SizeDetect == null)
{
	alert(document.SizeDetect ==  null);
}

the alert will actually return false, the object is now NOT NULL.  So it's not
until after the script accesses the object that it gets set.

Hope this information helps.
actually, i think you need to change it to:
if(document.Test == null){
		alert(document.Test);
		alert(document.Test);
	}
And the first alert reports null, the second reports the params of the java
applet.
Is it possible that there is a timing issue here? I believe NS4/IE wait until
everything on the page is loaded (including applets being started) before
calling the onload event. The behavior seems to indicate that Mozilla is firing
the onload event early. Just a guess.
Nom. nsbeta1. Want to achieve b.c. of JavaScript-->Java LiveConnect.
Keywords: nsbeta1
I think Bug #61488 I filed may be a dup of this.

That bug has a /much/ simpler test case, which can be found at:
http://www.hubick.com/software/Misc/LiveConnect/test5.htm
Reassigning to Joe
Assignee: jeff.dyer → joe.chou
Status: ASSIGNED → NEW
Depends on: 83698
Reproduced the problem, and the problem boils down to the following question:
When calling a method in an applet from a function of JavaScript, whereas the
applet code is in a different origin than the one of JavaScript, should that
work in Netscape 6? Currently we see an error in Java console, saying that the
JavaScript origin is different from the applet code. Is that working as
designed, or a bug? The same scenario works in Netscape 4.x and IE.
Status: NEW → ASSIGNED
The problem here is different from 83698. Remove dependance.
No longer depends on: 83698
Per Stanley, this is working as designed, not a bug. Marking invalid.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago23 years ago
Resolution: --- → INVALID
SPAM: reassigning OJI bugs to new QA, pmac. (227 bugs)
QA Contact: shrir → pmac
Chris Petersen is a new QA contact for oji component. His email is:
petersen@netscape.com
Assignee: joe.chou → petersen
fixing small error for pmac@netscape.com (filter with : SPAMMAILSUCKS)
Assignee: petersen → joe.chou
QA Contact: pmac → petersen
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: