From: <rb...@us...> - 2013-02-01 18:26:33
|
Revision: 8078 http://sourceforge.net/p/htmlunit/code/8078 Author: rbri Date: 2013-02-01 18:26:28 +0000 (Fri, 01 Feb 2013) Log Message: ----------- enabled selector was missing in the list of supported pseudo selectors Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-02-01 17:38:11 UTC (rev 8077) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-02-01 18:26:28 UTC (rev 8078) @@ -142,7 +142,7 @@ "focus", "lang", "first-child"); private static final Collection<String> CSS3_PSEUDO_CLASSES = new ArrayList<String>(Arrays.asList( - "checked", "disabled", "indeterminated", "root", "target", "not()", + "checked", "disabled", "enabled", "indeterminated", "root", "target", "not()", "nth-child()", "nth-last-child()", "nth-of-type()", "nth-last-of-type()", "last-child", "first-of-type", "last-of-type", "only-child", "only-of-type", "empty")); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java 2013-02-01 17:38:11 UTC (rev 8077) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java 2013-02-01 18:26:28 UTC (rev 8078) @@ -810,4 +810,79 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "1", "id1", "1", "id1" }) + public void enabled() throws Exception { + final String html = "<html><head><title>First</title>\n" + + "<meta http-equiv='X-UA-Compatible' content='IE=9'>\n" + + "<script>\n" + + "function test() {\n" + + " if (document.querySelectorAll) {\n" + + " try {\n" + + " found = document.querySelectorAll('input:enabled');\n" + + " alert(found.length);\n" + + " alert(found[0].id);\n" + + " } catch(e) {alert('exception')}\n" + + " }\n" + + "\n" + + " document.getElementById('id2').focus();\n" + + "\n" + + " if (document.querySelectorAll) {\n" + + " try {\n" + + " found = document.querySelectorAll('input:enabled');\n" + + " alert(found.length);\n" + + " alert(found[0].id);\n" + + " } catch(e) {alert('exception')}\n" + + " }\n" + + "}\n" + + "</script></head>\n" + + "<body onload='test()'>\n" + + " <input id='id1' >\n" + + " <input id='id2' disabled='disabled'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "1", "id2", "1", "id2" }) + public void disabled() throws Exception { + final String html = "<html><head><title>First</title>\n" + + "<meta http-equiv='X-UA-Compatible' content='IE=9'>\n" + + "<script>\n" + + "function test() {\n" + + " if (document.querySelectorAll) {\n" + + " try {\n" + + " found = document.querySelectorAll('input:disabled');\n" + + " alert(found.length);\n" + + " alert(found[0].id);\n" + + " } catch(e) {alert('exception')}\n" + + " }\n" + + "\n" + + " document.getElementById('id2').focus();\n" + + "\n" + + " if (document.querySelectorAll) {\n" + + " try {\n" + + " found = document.querySelectorAll('input:disabled');\n" + + " alert(found.length);\n" + + " alert(found[0].id);\n" + + " } catch(e) {alert('exception')}\n" + + " }\n" + + "}\n" + + "</script></head>\n" + + "<body onload='test()'>\n" + + " <input id='id1' >\n" + + " <input id='id2' disabled='disabled'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |