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 shouldBeFalse("div.tabStop"); |
19 | 33 |
20 div.tabStop = flag; | 34 div.tabStop = flag; |
21 shouldBe("div.tabStop", "false"); | 35 tabStopShouldBe("div", "false"); |
22 | 36 |
23 div.removeAttribute('isTabstop'); | 37 div.removeAttribute('tabstop'); |
24 shouldBe("div.tabStop", "false"); | 38 shouldBeFalse("div.tabStop"); |
| 39 shouldBeFalse("div.hasAttribute('tabstop')"); |
25 | 40 |
26 debug("Test tabStop override by tabindex property"); | 41 div.tabStop = true; |
| 42 tabStopShouldBe("div", "true"); |
| 43 |
| 44 div.removeAttribute('tabstop'); |
| 45 shouldBeFalse("div.tabStop"); |
| 46 shouldBeFalse("div.hasAttribute('tabstop')"); |
| 47 |
| 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 shouldBeTrue("div.tabStop"); |
29 | 53 |
30 div.tabIndex = -1; | 54 div.tabIndex = -1; |
31 shouldBe("div.tabStop", "false"); | 55 shouldBeFalse("div.tabStop"); |
32 | 56 |
33 div.tabIndex = 1; | 57 div.tabIndex = 1; |
34 shouldBe("div.tabStop", "true"); | 58 shouldBeTrue("div.tabStop"); |
35 | 59 |
36 debug("Test tabStop override by tabindex attribute"); | 60 resetAttributes(div); |
| 61 shouldBeFalse("div.tabStop"); |
| 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"); |
47 shouldBe("div.tabStop", "true"); | 76 tabStopShouldBe("div", "false"); |
48 | 77 |
49 debug("Test tabStop change after tabindex change"); | 78 resetAttributes(div); |
| 79 shouldBeFalse("div.tabStop"); |
| 80 shouldBeFalse("div.hasAttribute('tabstop')"); |
| 81 |
| 82 |
| 83 debug("Test tabStop change with explicit tabindex change"); |
| 84 resetAttributes(div); |
| 85 |
| 86 div.tabIndex = 0; |
| 87 shouldBeTrue("div.tabStop"); |
| 88 div.tabStop = false; |
| 89 tabStopShouldBe("div", "false"); |
| 90 resetAttributes(div); |
| 91 |
| 92 div.tabIndex = -1; |
| 93 shouldBeFalse("div.tabStop"); |
| 94 div.tabStop = true; |
| 95 tabStopShouldBe("div", "true"); |
| 96 resetAttributes(div); |
| 97 |
| 98 debug("Test tabStop with invalid value"); |
| 99 resetAttributes(div); |
| 100 |
50 div.tabIndex = 0; | 101 div.tabIndex = 0; |
51 div.tabStop = false; | 102 div.tabStop = false; |
52 shouldBe("div.tabStop", "false"); | 103 tabStopShouldBe("div", "false"); |
| 104 div.setAttribute("tabstop", "invalid"); |
| 105 shouldBeTrue("div.tabStop"); |
| 106 shouldBeEqualToString("div.getAttribute('tabstop')", "invalid"); |
53 | 107 |
54 div.tabIndex = -1; | 108 div.tabIndex = -1; |
55 div.tabStop = true; | 109 div.tabStop = true; |
56 shouldBe("div.tabStop", "true"); | 110 tabStopShouldBe("div", "true"); |
57 | 111 div.setAttribute("tabstop", "invalid"); |
58 debug("Test tabStop change before tabindex change which will be overridden")
; | 112 shouldBeFalse("div.tabStop"); |
59 div.tabStop = false; | 113 shouldBeEqualToString("div.getAttribute('tabstop')", "invalid"); |
60 div.tabIndex = 0; | |
61 shouldBe("div.tabStop", "true"); | |
62 | |
63 div.tabStop = true; | |
64 div.tabIndex = -1; | |
65 shouldBe("div.tabStop", "false"); | |
66 } | 114 } |
67 | 115 |
68 function run_test() { | 116 function run_test() { |
69 if (window.testRunner) | 117 if (window.testRunner) |
70 testRunner.dumpAsText(); | 118 testRunner.dumpAsText(); |
71 | 119 |
72 test(); | 120 test(); |
73 | 121 |
74 debug('Test finished.'); | 122 debug('Test finished.'); |
75 } | 123 } |
76 | 124 |
77 run_test(); | 125 run_test(); |
78 </script> | 126 </script> |
79 </body> | 127 </body> |
80 </html> | 128 </html> |
OLD | NEW |