JDK-6766056 : javascript DOM function on Object TAG causing javascript errors
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-10-31
  • Updated: 2011-02-16
  • Resolved: 2008-11-03
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :


ADDITIONAL OS VERSION INFORMATION :
Windows XP - Service Pack 3

EXTRA RELEVANT SYSTEM CONFIGURATION :
Internet explorer 7

A DESCRIPTION OF THE PROBLEM :
Several javascript error occurs when upgrading the JRE to from 07 to 10. :

The applet is embedded in the page with the OBJECT tag and started as expected.

When calling element.getAttribute the js engine indicates the function exists, but when the function is called a javascript error occurs. e.g.

if (element.getAttribute){
  element.getAttribute("name");
}

results in an error.

Also when a check for a function is done on the object element, this results in an error, e.g.:

if (element.hasAttribute){
   ///
}

results in an error.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
load the following html file in the browser.

<html>
<head>
    <script>
        function checkAll(){
            var element = document.getElementById("myapplet");
            if (element){
                alert("element found");

                // check if element has the getAttribute function
                if (element.getAttribute){
                    alert("Get attribute");
                    var val = element.getAttribute("mytest");
                    alert("Get attribute done"  + val );
                }

                if (element.hasAttribute){
                    alert("has attribute function present");
                } else {
                    alert("has attribute function not present");

                }
            }
        }
    </script>
</head>
<body>
<input type=button onclick="javascript:checkAll()" value="Check js function" />
<object id="myapplet"
    classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    >

        <param name="code" value="TestApplet.class" />
    </object>
</body>
</html>

The applet code is not relevant for the case. I used an empty applet with a System.out.println in the start of the applet

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The expected results are no javascript errors and the following alert boxes after clicking the button:

- element found
- get attribute
- get attribute donenull
- "has attribute function not present

ACTUAL -
javascript error when getAttribute("name") was executed.

REPRODUCIBILITY :
This bug can be reproduced always.

Release Regression From : 6u7
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION This is duplicate of 6738770. With the fix to 6738770, we now query the applet whether it has a field of method of the name before actually try to get the field or invoke the method. If the field or the method does not exist, we don't try to invoke the method, which can cause an exception thrown.
03-11-2008

EVALUATION Likely duplicate of 6738770. Assigning for evaluation.
03-11-2008