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);
}
}
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());
}
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);
}
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);
}
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);
}
Aggregations