/**
* Tests that {@link DOM#isOrHasChild(Element, Element)} works consistently
* across browsers.
*/
public void testIsOrHasChild() {
Document doc = Document.get();
Element div = DOM.createDiv();
Element childDiv = DOM.createDiv();
Text text = Document.get().createTextNode("text");
// unattached, not related
assertFalse(div.isOrHasChild(childDiv));
assertFalse(div.isOrHasChild(text));
assertTrue(div.isOrHasChild(div));
assertTrue(text.isOrHasChild(text));
assertFalse(doc.isOrHasChild(div));
assertFalse(doc.isOrHasChild(text));
assertFalse(div.isOrHasChild(doc));
assertFalse(text.isOrHasChild(doc));
// unattached, related
div.appendChild(childDiv);
childDiv.appendChild(text);
assertTrue(div.isOrHasChild(childDiv));
assertTrue(childDiv.isOrHasChild(text));
assertFalse(childDiv.isOrHasChild(div));
assertFalse(text.isOrHasChild(childDiv));
assertFalse(doc.isOrHasChild(div));
assertFalse(doc.isOrHasChild(text));
assertFalse(div.isOrHasChild(doc));
assertFalse(text.isOrHasChild(doc));
// attached, related
DOM.appendChild(RootPanel.getBodyElement(), div);
assertTrue(div.isOrHasChild(childDiv));
assertTrue(childDiv.isOrHasChild(text));
assertTrue(div.isOrHasChild(div));
assertTrue(text.isOrHasChild(text));
assertFalse(childDiv.isOrHasChild(div));
assertFalse(text.isOrHasChild(childDiv));
assertTrue(doc.isOrHasChild(div));
assertTrue(doc.isOrHasChild(text));
assertFalse(div.isOrHasChild(Document.get()));
assertFalse(text.isOrHasChild(Document.get()));
}