Menu ▾ ▴

#1829 Incomplete list of CSS3 Pseudo Classes

2.23
closed
RBRi
None
1
2016-10-10
2016-10-10
Marc
No

When running asText against some webpages, i'm getting CSS validation exceptions.

I'm not an expert on CSS selectors, but after inspecting the code a little, I see the problem might be that the CSSStyleSheet.CSS3_PSEUDO_CLASSES variable is missing some valid pseudo classes, like required, which according to w3schools is a valid pseudo-class: http://www.w3schools.com/Css/css_pseudo_classes.asp
and it's supported by most desktop browsers according to Mozilla
https://developer.mozilla.org/en/docs/Web/CSS/:required

This is a sample url in which it happens and the resulting exception.
https://www.afhs.eu/user/index.php

org.w3c.css.sac.CSSException: Invalid selector: :required 
        at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.validateSelectors(CSSStyleSheet.java:1457) 
        at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.selectsPseudoClass(CSSStyleSheet.java:859) 
        at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.selects(CSSStyleSheet.java:609) 
        at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.selects(CSSStyleSheet.java:559) 
        at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.selects(CSSStyleSheet.java:484) 
        at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.modifyIfNecessary(CSSStyleSheet.java:274) 
        at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.modifyIfNecessary(CSSStyleSheet.java:253) 
        at com.gargoylesoftware.htmlunit.javascript.host.Window.getComputedStyle(Window.java:1615) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendNode(HtmlSerializer.java:315) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendChildren(HtmlSerializer.java:398) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendNode(HtmlSerializer.java:325) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendChildren(HtmlSerializer.java:398) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendNode(HtmlSerializer.java:325) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendChildren(HtmlSerializer.java:398) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendNode(HtmlSerializer.java:325) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendChildren(HtmlSerializer.java:398) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendNode(HtmlSerializer.java:325) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendChildren(HtmlSerializer.java:398) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendNode(HtmlSerializer.java:325) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendChildren(HtmlSerializer.java:398) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendNode(HtmlSerializer.java:325) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendChildren(HtmlSerializer.java:398) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.appendNode(HtmlSerializer.java:325) 
        at com.gargoylesoftware.htmlunit.html.HtmlSerializer.asText(HtmlSerializer.java:65) 

Just adding required to CSS3_PSEUDO_CLASSES seems to work for me and I don't get the exception, but my guess is that something else needs to be done for proper support...

Thanks!

Discussion

  • RBRi

    RBRi - 2016-10-10
    • status: open --> pending
    • assigned_to: RBRi
     
  • RBRi

    RBRi - 2016-10-10

    as a quick fix, support for 'optional' and 'requred' was added. Do you need others?

     
  • Marc

    Marc - 2016-10-10

    :required is the one that's showing up the most on the logs.

    I'm seeing other selector exceptions but I think in these instances they are really invalid selectors so it might make sense that an Exception is raised:

    • CSSException: Invalid selector: :justified
    • CSSException: Invalid selector: :-moz-handler-blocked
     
  • RBRi

    RBRi - 2016-10-10

    So this is solved for you?

     
  • Marc

    Marc - 2016-10-10

    Yes, with required it's fixed at the moment.

     
  • RBRi

    RBRi - 2016-10-10
    • status: pending --> closed
     
  • RBRi

    RBRi - 2016-10-10

    Ok, open a new one if you need more.

    Enjoy using HtmlUnit.

     

Log in to post a comment.