JDK-6771315 : Error in implementation of Document.createDocumentFragment, createTextNode and createComment
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u12
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-11-13
  • Updated: 2010-09-08
  • Resolved: 2009-01-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 6
6u12 b02Fixed
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
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

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