Search in sources :

Example 31 with DOMException

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());
    }
}
Also used : HTMLLinkElement(org.loboevolution.html.dom.HTMLLinkElement) DOMException(com.gargoylesoftware.css.dom.DOMException) HTMLElement(org.loboevolution.html.dom.HTMLElement) HTMLLinkElement(org.loboevolution.html.dom.HTMLLinkElement) Test(org.junit.Test) LoboUnitTest(org.loboevolution.driver.LoboUnitTest)

Aggregations

DOMException (com.gargoylesoftware.css.dom.DOMException)31 Test (org.junit.Test)12 LoboUnitTest (org.loboevolution.driver.LoboUnitTest)12 HTMLElement (org.loboevolution.html.dom.HTMLElement)8 HTMLLinkElement (org.loboevolution.html.dom.HTMLLinkElement)8 Document (org.loboevolution.html.node.Document)8 NodeListImpl (org.loboevolution.html.dom.nodeimpl.NodeListImpl)6 Selector (com.gargoylesoftware.css.parser.selector.Selector)4 SelectorList (com.gargoylesoftware.css.parser.selector.SelectorList)4 Node (org.loboevolution.html.node.Node)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 HTMLBodyElement (org.loboevolution.html.dom.HTMLBodyElement)2 ElementFilter (org.loboevolution.html.dom.filter.ElementFilter)2 DocumentType (org.loboevolution.html.node.DocumentType)2 UserAgentContext (org.loboevolution.http.UserAgentContext)2 CSSStyleDeclarationImpl (com.gargoylesoftware.css.dom.CSSStyleDeclarationImpl)1 CSSOMParser (com.gargoylesoftware.css.parser.CSSOMParser)1 CSS3Parser (com.gargoylesoftware.css.parser.javacc.CSS3Parser)1