OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <p>This is basic behavior test for tabStop attribute.</p> | 7 <p>This is basic behavior test for tabStop attribute.</p> |
8 <pre id="console"></pre> | 8 <pre id="console"></pre> |
9 <script> | 9 <script> |
10 var div; | 10 var div; |
11 | 11 |
| 12 function resetAttributes(el) |
| 13 { |
| 14 el.removeAttribute("tabindex"); |
| 15 el.removeAttribute("tabstop"); |
| 16 } |
| 17 |
| 18 function tabStopShouldBe(el, expected) |
| 19 { |
| 20 shouldBe(el + ".tabStop", expected); |
| 21 shouldBeEqualToString(el + ".getAttribute('tabstop')", expected); |
| 22 } |
| 23 |
12 function test() { | 24 function test() { |
13 debug("Testing tabStop property and attribute"); | 25 debug("Testing tabStop property and attribute"); |
14 | 26 |
15 debug("Test tabStop normal assignment behavior"); | 27 debug("Test tabStop normal assignment behavior"); |
16 div = document.createElement("div"); | 28 div = document.createElement("div"); |
| 29 |
| 30 resetAttributes(div); |
17 var flag = div.tabStop; | 31 var flag = div.tabStop; |
18 shouldBe("div.tabStop", "false"); | 32 shouldBe("div.tabStop", "false"); |
19 | 33 |
20 div.tabStop = flag; | 34 div.tabStop = flag; |
| 35 tabStopShouldBe("div", "false"); |
| 36 |
| 37 div.removeAttribute('tabstop'); |
21 shouldBe("div.tabStop", "false"); | 38 shouldBe("div.tabStop", "false"); |
| 39 shouldBe("div.hasAttribute('tabstop')", "false"); |
22 | 40 |
23 div.removeAttribute('isTabstop'); | 41 div.tabStop = true; |
| 42 tabStopShouldBe("div", "true"); |
| 43 |
| 44 div.removeAttribute('tabstop'); |
24 shouldBe("div.tabStop", "false"); | 45 shouldBe("div.tabStop", "false"); |
| 46 shouldBe("div.hasAttribute('tabstop')", "false"); |
25 | 47 |
26 debug("Test tabStop override by tabindex property"); | 48 |
| 49 debug("Test tabStop value implicitly set by tabindex property"); |
| 50 resetAttributes(div); |
27 div.tabIndex = 0; | 51 div.tabIndex = 0; |
28 shouldBe("div.tabStop", "true"); | 52 shouldBe("div.tabStop", "true"); |
29 | 53 |
30 div.tabIndex = -1; | 54 div.tabIndex = -1; |
31 shouldBe("div.tabStop", "false"); | 55 shouldBe("div.tabStop", "false"); |
32 | 56 |
33 div.tabIndex = 1; | 57 div.tabIndex = 1; |
34 shouldBe("div.tabStop", "true"); | 58 shouldBe("div.tabStop", "true"); |
35 | 59 |
36 debug("Test tabStop override by tabindex attribute"); | 60 resetAttributes(div); |
| 61 shouldBe("div.tabStop", "false"); |
| 62 |
| 63 |
| 64 debug("Test explicit tabStop not overridable by tabindex attribute"); |
| 65 resetAttributes(div); |
37 div.tabStop = false; | 66 div.tabStop = false; |
38 div.setAttribute("tabindex", "0"); | 67 div.setAttribute("tabindex", "0"); |
39 shouldBe("div.tabStop", "true"); | 68 tabStopShouldBe("div", "false"); |
40 | 69 |
41 div.tabStop = true; | 70 div.tabStop = true; |
42 div.setAttribute("tabindex", "-1"); | 71 div.setAttribute("tabindex", "-1"); |
43 shouldBe("div.tabStop", "false"); | 72 tabStopShouldBe("div", "true"); |
44 | 73 |
45 div.tabStop = false; | 74 div.tabStop = false; |
46 div.setAttribute("tabIndex", "1"); | 75 div.setAttribute("tabIndex", "1"); |
| 76 tabStopShouldBe("div", "false"); |
| 77 |
| 78 resetAttributes(div); |
| 79 shouldBe("div.tabStop", "false"); |
| 80 shouldBe("div.hasAttribute('tabstop')", "false"); |
| 81 |
| 82 |
| 83 debug("Test tabStop change with explicit tabindex change"); |
| 84 resetAttributes(div); |
| 85 |
| 86 div.tabIndex = 0; |
47 shouldBe("div.tabStop", "true"); | 87 shouldBe("div.tabStop", "true"); |
48 | |
49 debug("Test tabStop change after tabindex change"); | |
50 div.tabIndex = 0; | |
51 div.tabStop = false; | 88 div.tabStop = false; |
52 shouldBe("div.tabStop", "false"); | 89 tabStopShouldBe("div", "false"); |
| 90 resetAttributes(div); |
53 | 91 |
54 div.tabIndex = -1; | 92 div.tabIndex = -1; |
| 93 shouldBe("div.tabStop", "false"); |
55 div.tabStop = true; | 94 div.tabStop = true; |
56 shouldBe("div.tabStop", "true"); | 95 tabStopShouldBe("div", "true"); |
57 | 96 resetAttributes(div); |
58 debug("Test tabStop change before tabindex change which will be overridden")
; | |
59 div.tabStop = false; | |
60 div.tabIndex = 0; | |
61 shouldBe("div.tabStop", "true"); | |
62 | |
63 div.tabStop = true; | |
64 div.tabIndex = -1; | |
65 shouldBe("div.tabStop", "false"); | |
66 } | 97 } |
67 | 98 |
68 function run_test() { | 99 function run_test() { |
69 if (window.testRunner) | 100 if (window.testRunner) |
70 testRunner.dumpAsText(); | 101 testRunner.dumpAsText(); |
71 | 102 |
72 test(); | 103 test(); |
73 | 104 |
74 debug('Test finished.'); | 105 debug('Test finished.'); |
75 } | 106 } |
76 | 107 |
77 run_test(); | 108 run_test(); |
78 </script> | 109 </script> |
79 </body> | 110 </body> |
80 </html> | 111 </html> |
OLD | NEW |