Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6771315

Error in implementation of Document.createDocumentFragment, createTextNode and createComment

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b02
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      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>
      -----

        Attachments

          Activity

            People

            Assignee:
            kbr Kenneth Russell (Inactive)
            Reporter:
            kbr Kenneth Russell (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: