nodeinsertbeforenewchilddiffdocumentpublic final class nodeinsertbeforenewchilddiffdocument extends org.w3c.domts.DOMTestCase The "insertBefore(newChild,refChild)" method raises a
WRONG_DOCUMENT_ERR DOMException if the "newChild" was
created from a different document than the one that
created this node.
Retrieve the second employee and attempt to insert a new
child that was created from a different document than the
one that created the second employee. An attempt to
insert such a child should raise the desired exception. |
Constructors Summary |
---|
public nodeinsertbeforenewchilddiffdocument(org.w3c.domts.DOMTestDocumentBuilderFactory factory)Constructor.
super(factory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "staff", false);
preload(contentType, "staff", true);
|
Methods Summary |
---|
public java.lang.String | getTargetURI()Gets URI that identifies the test.
return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenewchilddiffdocument";
| public static void | main(java.lang.String[] args)Runs this test from the command line.
DOMTestCase.doMain(nodeinsertbeforenewchilddiffdocument.class, args);
| public void | runTest()Runs the test case.
Document doc1;
Document doc2;
Node refChild;
Node newChild;
NodeList elementList;
Node elementNode;
Node insertedNode;
doc1 = (Document) load("staff", false);
doc2 = (Document) load("staff", true);
newChild = doc1.createElement("newChild");
elementList = doc2.getElementsByTagName("employee");
elementNode = elementList.item(1);
refChild = elementNode.getFirstChild();
{
boolean success = false;
try {
insertedNode = elementNode.insertBefore(newChild, refChild);
} catch (DOMException ex) {
success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
}
assertTrue("throw_WRONG_DOCUMENT_ERR", success);
}
|
|