hc_nodereplacechildnewchilddiffdocumentpublic final class hc_nodereplacechildnewchilddiffdocument extends org.w3c.domts.DOMTestCase The "replaceChild(newChild,oldChild)" 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 replace one
of its children with a node created from a different
document. An attempt to make such a replacement
should raise the desired exception. |
Constructors Summary |
---|
public hc_nodereplacechildnewchilddiffdocument(org.w3c.domts.DOMTestDocumentBuilderFactory factory)Constructor.
super(factory);
//
// check if loaded documents are supported for content type
//
String contentType = getContentType();
preload(contentType, "hc_staff", false);
preload(contentType, "hc_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/hc_nodereplacechildnewchilddiffdocument";
| public static void | main(java.lang.String[] args)Runs this test from the command line.
DOMTestCase.doMain(hc_nodereplacechildnewchilddiffdocument.class, args);
| public void | runTest()Runs the test case.
Document doc1;
Document doc2;
Node oldChild;
Node newChild;
NodeList elementList;
Node elementNode;
Node replacedChild;
doc1 = (Document) load("hc_staff", false);
doc2 = (Document) load("hc_staff", true);
newChild = doc1.createElement("br");
elementList = doc2.getElementsByTagName("p");
elementNode = elementList.item(1);
oldChild = elementNode.getFirstChild();
{
boolean success = false;
try {
replacedChild = elementNode.replaceChild(newChild, oldChild);
} catch (DOMException ex) {
success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
}
assertTrue("throw_WRONG_DOCUMENT_ERR", success);
}
|
|