United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6771315 : Error in implementation of Document.createDocumentFragment, createTextNode and createComment

Details
Type:
Bug
Submit Date:
2008-11-13
Status:
Closed
Updated Date:
2010-09-08
Project Name:
JDK
Resolved Date:
2009-01-21
Component:
deploy
OS:
generic
Sub-Component:
plugin
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u12
Fixed Versions:
6u12 (b02)

Related Reports

Sub Tasks

Description
###@###.### discovered that adding a newly-created text node to a part of the HTML document was causing errors. The root cause is a cut-and-paste typo in a few methods of the Document class causing the wrong JavaScript object to be wrapped and returned to the caller, and later inserted into the DOM hierarchy.

The test case is as follows:
DOMAdd.java:
-----
import java.lang.reflect.*;
import org.w3c.dom.*;
import org.w3c.dom.html.*;

public class DOMAdd extends java.applet.Applet
{
    public void start()
    {
        try
        {
            Class c = Class.forName("com.sun.java.browser.plugin2.DOM");
            Method m = c.getMethod("getDocument",
                                   new Class[] { java.applet.Applet.class });
            HTMLDocument doc = (HTMLDocument) m.invoke(null, new Object[] { this });
            Element e = doc.createElement("div");
            Text t = doc.createTextNode("Test passed.");
            e.appendChild(t);
            doc.getBody().appendChild(e);
            System.out.println("Test passed.");
        }
        catch (Exception e)
        {
            e.printStackTrace();
            System.out.println("TEST FAILED");
        }
    }
}
-----

DOMAdd.html:
-----
<html>
  <head>
    <title>
      DOM Add test applet
    </title>
  </head>
  <body>
    <applet code=DOMAdd.class
      width=10 height=10
      mayscript>
    </applet>
  </body>
</html>
-----

                                    

Comments
SUGGESTED FIX

webrev: http://sa.sfbay.sun.com/projects/deployment_data/6u12/6771315.0
testcase: http://j2se.east.sun.com/deployment/www/tests/1.6.0_12/6771315/
                                     
2008-11-13
EVALUATION

A cut-and-paste typo in a few key methods of the Document class cause
wrapping of the wrong object (the containing document rather than the
newly-created node) which prevents the affected APIs from functioning.
                                     
2008-11-13



Hardware and Software, Engineered to Work Together