selectors should match attribute name with case sensitivity based on element & docume...
[WebKit-https.git] / LayoutTests / fast / dom / SelectorAPI / attrname-case-insensitive.html
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../../js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7     <!-- Check that in HTML documents CSS selectors use case-insensitive attribute name matching for HTML elements, case-sensitive otherwise. -->
8     <div id="content">
9         <div style="display: none">
10             <div baR="10" id="bar"></div>
11
12             <svg xmlns="http://www.w3.org/2000/svg">
13                 <path id="pa" pathLength="200"/>
14             </svg>
15         </div>
16     </div>
17     <script>
18         var content = document.getElementById("content");
19         function checkMatchingSelector(selector, elementId) {
20             shouldBe("document.querySelector('" + selector + "')", "document.getElementById('" + elementId + "')");
21             shouldBeTrue("document.getElementById('" + elementId + "').webkitMatchesSelector('" + selector + "')");
22         }
23
24         function checkNonMatchingSelector(selector) {
25             shouldBeNull("content.querySelector('" + selector + "')");
26         }
27
28         // HTML should be matched case-insensitive
29         checkMatchingSelector('div[baR]', "bar");
30         checkMatchingSelector('div[bar]', "bar");
31         checkMatchingSelector('div[BAR]', "bar");
32         checkMatchingSelector('div[bAR]', "bar");
33         checkMatchingSelector('div[baR="10"]', "bar");
34         checkMatchingSelector('div[bar="10"]', "bar");
35         checkMatchingSelector('div[BAR="10"]', "bar");
36         checkMatchingSelector('div[bAR="10"]', "bar");
37
38         // non HTML should be matched case-sensitive
39         checkMatchingSelector('path[pathLength]', "pa");
40         checkNonMatchingSelector('path[pathlength]');
41         checkNonMatchingSelector('path[pathLengTh]');
42         checkMatchingSelector('path[pathLength="200"]', "pa");
43         checkNonMatchingSelector('path[pathlength="200"]');
44         checkNonMatchingSelector('path[pathLengTh="200"]');
45     </script>
46     <script src="../../js/resources/js-test-post.js"></script>
47 </body>
48 </html>