blob: f4053f5c947759cd2e8594993cf1c7123058aa42 [file] [log] [blame]
benjamin@webkit.orge65d2452016-08-18 06:22:40 +00001<!DOCTYPE html>
2<html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <script src="../../resources/js-test-pre.js"></script>
5 <style>
6 @namespace uh url(http://www.w3.org/1999/xhtml);
7 #root div {
8 background-color: rgb(1, 2, 3);
9 color: rgb(1, 2, 3);
10 }
11 #root |div {
12 background-color: rgb(4, 5, 6);
13 }
14 #root uh|div {
15 color: rgb(4, 5, 6);
16 }
17 </style>
18 </head>
19 <body>
20 <div id="root" style="display:none;">
21 <div data-case="1">Default namespace</div>
22 </div>
23 <script>
24 description("Verify that \"|name\" matches the empty namespace while \"*|name\" and \"name\" match any namespace.");
25
26 var root = document.getElementById("root");
27 var elementWithoutNamespace = document.createElementNS("", "div");
28 elementWithoutNamespace.setAttribute("data-case", "2");
29 root.appendChild(elementWithoutNamespace);
30
31 function test(selector, expectedCases)
32 {
33 shouldBe('root.querySelectorAll("' + selector + '").length', '' + expectedCases.length);
34 let queryResult = root.querySelectorAll(selector);
35 for (let i = 0; i < queryResult.length; ++i) {
36 shouldBeEqualToString('root.querySelectorAll("' + selector + '")[' + i + '].getAttribute("data-case")', '' + expectedCases[i]);
37 }
38 }
39
40 debug("Trivial Selector used as rightmost");
41 test("|div", [2]);
42 test("*|div", [1, 2]);
43 test("div", [1, 2]);
44
45 shouldBeEqualToString('getComputedStyle(document.querySelector("[|data-case=\'1\' i]")).color', 'rgb(4, 5, 6)');
46 shouldBeEqualToString('getComputedStyle(document.querySelector("[|data-case=\'1\' i]")).backgroundColor', 'rgb(1, 2, 3)');
47 shouldBeEqualToString('getComputedStyle(document.querySelector("[|data-case=\'2\' i]")).color', 'rgb(1, 2, 3)');
48 shouldBeEqualToString('getComputedStyle(document.querySelector("[|data-case=\'2\' i]")).backgroundColor', 'rgb(4, 5, 6)');
49 </script>
50 <script src="../../resources/js-test-post.js"></script>
51 </body>
52</html>