JavaScript access to Java Applet fails.



Core Graveyard
Java: OJI
17 years ago
7 years ago


(Reporter: Steve K, Assigned: Joe Chou)



Firefox Tracking Flags

(Not tracked)


(Whiteboard: [relnote-devel], URL)


(1 attachment)



17 years ago
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

Reproducible: Always
Steps to Reproduce:
With Linux M18 with JVM installed, Go to URL, 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

NOTE: Only tried this with PC/Linux, not other platforms.  Also happened with
2000101021 build.

Comment 1

17 years ago
Using Mozilla MN6 branch build 2000102309 on WinNT. The script 
uses an <APPLET> tag with name = "SizeDetect", and then tries 
to access it via


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:

<TITLE>Bug 56430</TITLE>

<SCRIPT language="JavaScript">

function setres() 
  var x_val, y_val;   

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

      if(x_val != null)
        alert( "HorizonOpts="  + escape(x_val)   +   " x " + escape(y_val));                       
        alert("document.SizeDetect.x  ==  null");

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


Comment 2

17 years ago
Created attachment 17842 [details]
Reduced HTML testcase (see HTML in entry above)

Comment 3

17 years ago
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 804b0002 
Create instance called in JavaPluginFactory5!!!!!!!!
 Succeeding in creating proxy
Register Env [0] proxyenv=142434328 tid=134579240
initilizing the java plugin instantance 


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"

Comment 4

17 years ago
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
Component: Live Connect → OJI
Ever confirmed: true
QA Contact: pschwartau → shrir

Comment 5

17 years ago
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.

Comment 6

17 years ago
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.


17 years ago
No longer depends on: 57004

Comment 7

17 years ago
I get this error:

sun.plugin.liveconnect.OriginNotAllowedException: JavaScript is not from the
same origin as the java code, caller=,

Adding Jeff Dyer.  Jeff, can you please take a look at this?  Does this bug
depend on bug 53849?

Comment 8

17 years ago
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 {

Signing the applet should fix the problem.  Marking invalid.
Last Resolved: 17 years ago
Resolution: --- → INVALID

Comment 9

17 years ago
Signing the applet wouldn't necessarily help. The applet tag sets the code base 
codebase="". 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.)

Comment 10

17 years ago
Thanks for your comments jeff.  Adding [relnote-devel] And marking FUTURE so
Jeff's comments will get into the relnotes.
Resolution: INVALID → ---
Whiteboard: [relnote-devel]
Target Milestone: --- → Future
I'm taking the liberty of marking ASSIGNED and setting the mozilla0.9 milestone 

Keywords: mozilla0.9

Comment 12

17 years ago
Jeff, can you take a stab at solving this?
Assignee: edburns → jeff.dyer


17 years ago

Comment 13

17 years ago
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.

Comment 14

17 years ago
actually, i think you need to change it to:
if(document.Test == null){
And the first alert reports null, the second reports the params of the java

Comment 15

17 years ago
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

Comment 17

17 years ago
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:

Comment 18

17 years ago
Reassigning to Joe
Assignee: jeff.dyer → joe.chou


17 years ago
Depends on: 83698

Comment 19

17 years ago
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.

Comment 20

17 years ago
The problem here is different from 83698. Remove dependance.
No longer depends on: 83698

Comment 21

17 years ago
Per Stanley, this is working as designed, not a bug. Marking invalid.
Last Resolved: 17 years ago17 years ago
Resolution: --- → INVALID

Comment 22

16 years ago
SPAM: reassigning OJI bugs to new QA, pmac. (227 bugs)
QA Contact: shrir → pmac

Comment 23

15 years ago
Chris Petersen is a new QA contact for oji component. His email is:
Assignee: joe.chou → petersen
fixing small error for (filter with : SPAMMAILSUCKS)
Assignee: petersen → joe.chou
QA Contact: pmac → petersen


7 years ago
Component: Java: OJI → Java: OJI
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.