2010-12-07 Maciej Stachowiak <mjs@apple.com>
[WebKit.git] / LayoutTests / fast / html / hidden-attr.html
1 <!DOCTYPE html>\r
2 <meta charset=utf8>\r
3 <link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">\r
4 <script src="../../fast/js/resources/js-test-pre.js"></script>\r
5 \r
6 <p id="description"></p>\r
7 <div id="console">\r
8 Tests that hidden in markup works:\r
9 <div hidden><span class=fail>FAIL</span> - this line should not appear</div><div hidden=hidden><span class=fail>FAIL</span> - this line should not appear</div><div hidden=false><span class=fail>FAIL</span> - this line should not appear</div><p hidden><span class=fail>FAIL</span> - this line should not appear</p><span hidden><span class=fail>FAIL</span> - this line should not appear</span><img width=400px alt="FAIL - this should not appear" src="resources/xxx-missing.jpeg" hidden>\r
10 \r
11 Tests that dynamically adding/removing hidden works:\r
12 <div hidden id=test1><span class=pass>PASS</span> - this line should appear<div id=test2><span class=fail>FAIL</span> - this line should not appear</div>\r
13 </div>\r
14 <script>\r
15 description('Various tests for the hidden attribute.');\r
16 \r
17 document.getElementById("test1").removeAttribute("hidden");\r
18 document.getElementById("test2").setAttribute("hidden", "");\r
19 \r
20 var testParent = document.createElement('div');\r
21 document.body.appendChild(testParent);\r
22 \r
23 debug('Dynamic changing of hidden and effects on style:');\r
24 testParent.innerHTML="<div id=test3 hidden>a</div><div id=test4>b</div>"\r
25 var test3 = document.getElementById("test3");\r
26 var test4 = document.getElementById("test4");\r
27 \r
28 shouldBe('getComputedStyle(test3, false).display', '"none"');\r
29 test3.removeAttribute("hidden");\r
30 debug('test3.removeAttribute("hidden")');\r
31 shouldBe('getComputedStyle(test3, false).display', '"block"');\r
32 \r
33 shouldBe('getComputedStyle(test4, false).display', '"block"');\r
34 test4.setAttribute("hidden", "");\r
35 debug('test4.setAttribute("hidden", "")');\r
36 shouldBe('getComputedStyle(test4, false).display', '"none"');\r
37 \r
38 var successfullyParsed = true;\r
39 \r
40 </script>\r
41 <script src="../../fast/js/resources/js-test-post.js"></script>\r
42 </body>\r
43 </html>\r