diff --git a/test/src/test/java/scripts/BehaviorTest.java b/test/src/test/java/scripts/BehaviorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..08621675f67fcc097f1634af6b50dc8cfd2488a8 --- /dev/null +++ b/test/src/test/java/scripts/BehaviorTest.java @@ -0,0 +1,43 @@ +/* + * The MIT License + * + * Copyright (c) 2011, CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package scripts; + +import com.gargoylesoftware.htmlunit.ScriptResult; +import com.gargoylesoftware.htmlunit.html.HtmlPage; +import org.jvnet.hudson.test.HudsonTestCase; + +/** + * @author Kohsuke Kawaguchi + */ +public class BehaviorTest extends HudsonTestCase { + public void testCssSelectors() throws Exception { + HtmlPage p = createWebClient().goTo("self/testCssSelectors"); + assertEquals(2,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',true).length"))); + assertEquals(1,asInt(p.executeJavaScript("findElementsBySelector($('test1'),'.a',false).length"))); + } + + private int asInt(ScriptResult r) { + return ((Double)r.getJavaScriptResult()).intValue(); + } +} diff --git a/test/src/test/java/scripts/package-info.java b/test/src/test/java/scripts/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..8b419d90ea216bc92cd486436e6f9823b3b6525a --- /dev/null +++ b/test/src/test/java/scripts/package-info.java @@ -0,0 +1,4 @@ +/** + * Tests the JavaScript code. + */ +package scripts; \ No newline at end of file diff --git a/test/src/test/resources/scripts/BehaviorTest/testCssSelectors.jelly b/test/src/test/resources/scripts/BehaviorTest/testCssSelectors.jelly new file mode 100644 index 0000000000000000000000000000000000000000..e8a4d236fe9be5656a069c99aa0d67d18c0bb36b --- /dev/null +++ b/test/src/test/resources/scripts/BehaviorTest/testCssSelectors.jelly @@ -0,0 +1,36 @@ + + + + + + +
+
+
+ + +