Moved the test directory.
[jquery.git] / build / test / tests / xpath.html
1 <html id="html">
2 <head>
3         <script type="text/javascript" src="../lib/Test/Builder.js"></script>
4         <script type="text/javascript" src="../lib/Test/More.js"></script>
5         <script type="text/javascript" src="../lib/test.js"></script>
6         <script type="text/javascript" src="../../jquery/jquery-svn.js"></script>
7 </head>
8 <body id="body">
9         <h1>XPath Expressions</h1>
10         
11         <!-- Test HTML -->
12         <div id="main" style="display: none;">
13                 <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> 
14                         for more information.</p>
15                 <p id="ap">Here are some links in a normal paragraph: 
16                         <a id="google" href="http://www.google.com/" title="Google!">Google</a>, 
17                         <a id="groups" href="http://groups.google.com/">Google Groups</a>. 
18                         This link has <code><a href="#" id="anchor1">class="blog"</a></code>: 
19                         <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a>
20                 </p>
21                 <div id="foo">
22                         <p id="sndp">Everything inside the red border is inside a div with 
23                         <code>id="foo"</code>.</p>
24                         <p lang="en" id="en">This is a normal link: 
25                         <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a>
26                         </p>
27                         <p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: 
28                         <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a>
29                         </p>
30                 </div>
31                 <p id="first">Try them out: </p>
32                 <ol id="empty"></ol>
33                 <form id="form">
34                         <input type="text" value="Test" id="text1"/>
35                         <input type="text" value="Test" id="text2" disabled="disabled"/>
36                         <input type="radio" name="radio1" id="radio1"/>
37                         <input type="radio" name="radio2" id="radio2" checked/>
38                         <input type="checkbox" name="check" id="check1" checked/>
39                         <input type="checkbox" name="check" id="check2"/>
40                 </form>
41         </div>
42         
43         <pre id="test"><script>
44                 plan({tests: 14});
45                 
46                 cmpOK( $.find("//*").length, ">=", 30, "All Elements (//*)" );
47                 t( "All Div Elements", "//div", ["main","foo"] );
48                 
49                 t( "Absolute Path", "/html/body", ["body"] );
50                 t( "Absolute Path w/ *", "/*/body", ["body"] );
51                 t( "Long Absolute Path", "/html/body/div/div/p", ["sndp","en","sap"] );
52                 
53                 t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
54                 
55                 t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
56                 t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
57                 
58                 t( "Attribute Exists", "//a[@title]", ["google"] );
59                 t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
60                 
61                 t( "Parent Axis", "//p/..", ["main","foo"] );
62                 t( "Sibling Axis", "//p/../", 
63                         ["firstp","ap","foo","first","empty","form","sndp","en","sap"] );
64                 t( "Sibling Axis", "//p/../*", 
65                         ["firstp","ap","foo","first","empty","form","sndp","en","sap"] );
66                         
67                 t( "Has Children", "//p[a]", 
68                         ["firstp","ap","en","sap"] );
69         </script></pre>
70 </body>
71 </html>