@Throws(Throwable::class) fun runTest() { val doc: Document val rootNode: Element val newChild: Node val elementList: NodeList val oldChild: Node var replacedChild: Node doc = load("hc_staff", true) as Document newChild = doc.createAttribute("lang")elementList = doc.getElementsByTagName("p") oldChild = elementList.item(1) rootNode = oldChild.getParentNode() as Element run { var success = false try { replacedChild = rootNode.replaceChild(newChild, oldChild) } catch (ex: DOMException) { success = ex.code === DOMException.HIERARCHY_REQUEST_ERR } assertTrue("throw_HIERARCHY_REQUEST_ERR", success) } }
Runs the test case .