use of com.gargoylesoftware.css.dom.DOMException in project LoboEvolution by LoboEvolution.
the class HTMLDocumentTest method testCreateElementNS.
@Test
public void testCreateElementNS() {
Element elm = document.createElementNS(HTMLDocument.HTML_NAMESPACE_URI, "link");
assertTrue(elm instanceof HTMLLinkElement);
elm = document.createElementNS(HTMLDocument.HTML_NAMESPACE_URI, "LINK");
assertTrue(elm instanceof HTMLLinkElement);
assertEquals("LINK", elm.getLocalName());
assertEquals("LINK", elm.getTagName());
assertEquals(HTMLDocument.HTML_NAMESPACE_URI, elm.getNamespaceURI());
elm = document.createElementNS(HTMLDocument.HTML_NAMESPACE_URI, "style");
assertTrue(elm instanceof HTMLLinkElement);
elm = document.createElementNS(HTMLDocument.HTML_NAMESPACE_URI, "STYLE");
assertTrue(elm instanceof HTMLLinkElement);
assertEquals("style", elm.getLocalName());
elm = document.createElementNS("http://www.w3.org/2000/svg", "g:rect");
assertEquals("g", elm.getPrefix());
assertEquals("rect", elm.getLocalName());
assertEquals("g:rect", elm.getTagName());
assertEquals("<g:rect/>", elm.toString());
try {
document.createElementNS(HTMLDocument.HTML_NAMESPACE_URI, "s:div");
fail("Must throw exception");
} catch (DOMException e) {
assertEquals(DOMException.INVALID_CHARACTER_ERR, e.getCode());
}
try {
document.createElementNS(HTMLDocument.HTML_NAMESPACE_URI, null);
fail("Must throw exception");
} catch (DOMException e) {
assertEquals(DOMException.INVALID_CHARACTER_ERR, e.getCode());
}
try {
document.createElementNS(HTMLDocument.HTML_NAMESPACE_URI, "");
fail("Must throw exception");
} catch (DOMException e) {
assertEquals(DOMException.INVALID_CHARACTER_ERR, e.getCode());
}
try {
document.createElementNS(Document.XML_NAMESPACE_URI, "x:");
fail("Must throw exception");
} catch (DOMException e) {
assertEquals(DOMException.INVALID_CHARACTER_ERR, e.getCode());
}
try {
document.createElementNS(Document.XML_NAMESPACE_URI, ":x");
fail("Must throw exception");
} catch (DOMException e) {
assertEquals(DOMException.INVALID_CHARACTER_ERR, e.getCode());
}
try {
document.createElementNS(Document.XML_NAMESPACE_URI, ":");
fail("Must throw exception");
} catch (DOMException e) {
assertEquals(DOMException.INVALID_CHARACTER_ERR, e.getCode());
}
try {
document.createElementNS(Document.XML_NAMESPACE_URI, "\u0000");
fail("Must throw exception");
} catch (DOMException e) {
assertEquals(DOMException.INVALID_CHARACTER_ERR, e.getCode());
}
try {
document.createElementNS(Document.XML_NAMESPACE_URI, "<");
fail("Must throw exception");
} catch (DOMException e) {
assertEquals(DOMException.INVALID_CHARACTER_ERR, e.getCode());
}
try {
document.createElementNS(Document.XML_NAMESPACE_URI, ">");
fail("Must throw exception");
} catch (DOMException e) {
assertEquals(DOMException.INVALID_CHARACTER_ERR, e.getCode());
}
}
Aggregations