Search in sources :

Example 1 with CSSStyleSheetImpl

use of org.loboevolution.html.js.css.CSSStyleSheetImpl in project LoboEvolution by LoboEvolution.

the class HTMLStyleElementImpl method setDisabled.

/**
 * {@inheritDoc}
 */
@Override
public void setDisabled(boolean disabled) {
    this.disabled = disabled;
    final CSSStyleSheetImpl sheet = this.styleSheet;
    if (sheet != null) {
        sheet.setDisabled(disabled);
    }
}
Also used : CSSStyleSheetImpl(org.loboevolution.html.js.css.CSSStyleSheetImpl)

Example 2 with CSSStyleSheetImpl

use of org.loboevolution.html.js.css.CSSStyleSheetImpl in project LoboEvolution by LoboEvolution.

the class HTMLDocumentTest method testLinkElement.

@Test
public void testLinkElement() {
    Element link = (Element) document.getElementsByTagName("link").item(0);
    CSSStyleSheetImpl sheet = (CSSStyleSheetImpl) ((HTMLLinkElement) link).getSheet();
    assertNotNull(sheet);
    assertEquals(0, sheet.getMedia().getLength());
    assertTrue(sheet.getCssRules().getLength() > 0);
    assertSame(sheet.getOwnerNode(), link);
    link.setAttribute("media", "screen");
    CSSStyleSheetImpl sheet2 = (CSSStyleSheetImpl) ((HTMLLinkElement) link).getSheet();
    assertNotNull(sheet2);
    assertSame(sheet2, sheet);
    assertEquals(1, sheet2.getMedia().getLength());
    assertEquals("screen", sheet2.getMedia().item(0));
    link.setAttribute("href", "css/alter1.css");
    sheet = (CSSStyleSheetImpl) ((HTMLLinkElement) link).getSheet();
    assertSame(sheet2, sheet);
    assertSame(sheet.getOwnerNode(), link);
    Attr href = link.getAttributeNode("href");
    assertNotNull(href);
    href.setValue("http://www.example.com/css/example.css");
    assertNotNull(((HTMLLinkElement) link).getSheet());
    assertEquals(0, sheet.getCssRules().getLength());
    link.setAttribute("media", "screen only and");
    assertNull(((HTMLLinkElement) link).getSheet());
}
Also used : HTMLLinkElement(org.loboevolution.html.dom.HTMLLinkElement) CSSStyleSheetImpl(org.loboevolution.html.js.css.CSSStyleSheetImpl) HTMLElement(org.loboevolution.html.dom.HTMLElement) HTMLLinkElement(org.loboevolution.html.dom.HTMLLinkElement) Test(org.junit.Test) LoboUnitTest(org.loboevolution.driver.LoboUnitTest)

Example 3 with CSSStyleSheetImpl

use of org.loboevolution.html.js.css.CSSStyleSheetImpl in project LoboEvolution by LoboEvolution.

the class HTMLDocumentTest method testLinkElementBadMIMEType.

@Test
public void testLinkElementBadMIMEType() {
    Element link = document.createElement("link");
    link.setAttribute("href", "http://www.example.com/css/background.png");
    assertNull(((HTMLLinkElement) link).getSheet());
    link.setAttribute("rel", "stylesheet");
    CSSStyleSheetImpl sheet = (CSSStyleSheetImpl) ((HTMLLinkElement) link).getSheet();
    assertNull(sheet);
}
Also used : CSSStyleSheetImpl(org.loboevolution.html.js.css.CSSStyleSheetImpl) HTMLElement(org.loboevolution.html.dom.HTMLElement) HTMLLinkElement(org.loboevolution.html.dom.HTMLLinkElement) Test(org.junit.Test) LoboUnitTest(org.loboevolution.driver.LoboUnitTest)

Example 4 with CSSStyleSheetImpl

use of org.loboevolution.html.js.css.CSSStyleSheetImpl in project LoboEvolution by LoboEvolution.

the class HTMLDocumentTest method testLinkElement2.

@Test
public void testLinkElement2() {
    Element link = document.createElement("link");
    link.setAttribute("href", "http://www.example.com/foo");
    assertNull(((HTMLLinkElement) link).getSheet());
    link.setAttribute("rel", "stylesheet");
    CSSStyleSheetImpl sheet = (CSSStyleSheetImpl) ((HTMLLinkElement) link).getSheet();
    assertNotNull(sheet);
    assertEquals(0, sheet.getMedia().getLength());
    assertEquals(0, sheet.getCssRules().getLength());
    assertSame(sheet.getOwnerNode(), link);
}
Also used : CSSStyleSheetImpl(org.loboevolution.html.js.css.CSSStyleSheetImpl) HTMLElement(org.loboevolution.html.dom.HTMLElement) HTMLLinkElement(org.loboevolution.html.dom.HTMLLinkElement) Test(org.junit.Test) LoboUnitTest(org.loboevolution.driver.LoboUnitTest)

Example 5 with CSSStyleSheetImpl

use of org.loboevolution.html.js.css.CSSStyleSheetImpl in project LoboEvolution by LoboEvolution.

the class HTMLDocumentTest method testLinkElementEvil.

@Test(timeout = 8000)
public void testLinkElementEvil() {
    Element link = document.createElement("link");
    link.setAttribute("rel", "stylesheet");
    link.setAttribute("href", "file:/dev/zero");
    CSSStyleSheetImpl sheet = (CSSStyleSheetImpl) ((HTMLLinkElement) link).getSheet();
    assertNotNull(sheet);
    assertEquals(0, sheet.getMedia().getLength());
    assertEquals(0, sheet.getCssRules().getLength());
    assertSame(sheet.getOwnerNode(), link);
}
Also used : CSSStyleSheetImpl(org.loboevolution.html.js.css.CSSStyleSheetImpl) HTMLElement(org.loboevolution.html.dom.HTMLElement) HTMLLinkElement(org.loboevolution.html.dom.HTMLLinkElement) Test(org.junit.Test) LoboUnitTest(org.loboevolution.driver.LoboUnitTest)

Aggregations

CSSStyleSheetImpl (org.loboevolution.html.js.css.CSSStyleSheetImpl)15 Test (org.junit.Test)11 LoboUnitTest (org.loboevolution.driver.LoboUnitTest)11 HTMLElement (org.loboevolution.html.dom.HTMLElement)11 HTMLLinkElement (org.loboevolution.html.dom.HTMLLinkElement)11 DOMException (com.gargoylesoftware.css.dom.DOMException)1 CSSOMParser (com.gargoylesoftware.css.parser.CSSOMParser)1 InputSource (com.gargoylesoftware.css.parser.InputSource)1 CSS3Parser (com.gargoylesoftware.css.parser.javacc.CSS3Parser)1 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URL (java.net.URL)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 HtmlPanel (org.loboevolution.html.gui.HtmlPanel)1 CSSRuleList (org.loboevolution.html.node.css.CSSRuleList)1 HtmlRendererContext (org.loboevolution.http.HtmlRendererContext)1 UserAgentContext (org.loboevolution.http.UserAgentContext)1 TimingInfo (org.loboevolution.info.TimingInfo)1