OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> |
| 5 <script src="resources/shadow-dom.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 <p>This tests TAB focus navigation with isTabStop property on elements</p> |
| 9 <pre id="console"></pre> |
| 10 <script> |
| 11 |
| 12 function prepareDOMTree(parent) { |
| 13 parent.appendChild( |
| 14 createDOM('div', {'id': 'testform'}, |
| 15 createDOM('input', {'id': 'input-before'}), |
| 16 createDOM('div', {'id': 'host'}, |
| 17 createShadowRoot( |
| 18 createDOM('input', {'id': 'inner-input'}))), |
| 19 createDOM('input', {'id': 'input-after'}))); |
| 20 parent.offsetTop; |
| 21 } |
| 22 |
| 23 function test() { |
| 24 debug("Testing shadow host with possible combinations of tabindex and isTabS
top"); |
| 25 |
| 26 var host = document.getElementById('host'); |
| 27 |
| 28 debug("Normal tab order without tabindex"); |
| 29 shouldBe('host.isTabStop', 'false'); |
| 30 |
| 31 var expected_nav = [ |
| 32 'input-before', |
| 33 'host/inner-input', |
| 34 'input-after' |
| 35 ]; |
| 36 |
| 37 testFocusNavigationFowrad(expected_nav); |
| 38 expected_nav.reverse(); |
| 39 testFocusNavigationBackward(expected_nav); |
| 40 |
| 41 debug("Normal tab order without tabindex but isTabStop=true"); |
| 42 host.isTabStop = true; |
| 43 |
| 44 var expected_nav = [ |
| 45 'input-before', |
| 46 'host/inner-input', |
| 47 'input-after' |
| 48 ]; |
| 49 |
| 50 testFocusNavigationFowrad(expected_nav); |
| 51 expected_nav.reverse(); |
| 52 testFocusNavigationBackward(expected_nav); |
| 53 |
| 54 debug("Normal tab order with tabindex=0 on host"); |
| 55 |
| 56 host.tabIndex = 0; |
| 57 shouldBeEqualToString('host.getAttribute("tabindex")', '0'); |
| 58 shouldBe('host.isTabStop', 'true'); |
| 59 |
| 60 expected_nav = [ |
| 61 'input-before', |
| 62 'host', |
| 63 'host/inner-input', |
| 64 'input-after' |
| 65 ]; |
| 66 |
| 67 testFocusNavigationFowrad(expected_nav); |
| 68 expected_nav.reverse(); |
| 69 testFocusNavigationBackward(expected_nav); |
| 70 |
| 71 debug("Normal tab order with tabindex=0 but isTabStop = false on host"); |
| 72 host.isTabStop = false; |
| 73 |
| 74 expected_nav = [ |
| 75 'input-before', |
| 76 // 'host', // should skip host when isTabStop = false |
| 77 'host/inner-input', |
| 78 'input-after' |
| 79 ]; |
| 80 |
| 81 testFocusNavigationFowrad(expected_nav); |
| 82 expected_nav.reverse(); |
| 83 testFocusNavigationBackward(expected_nav); |
| 84 |
| 85 debug("Normal tab order with tabindex=-1 on host"); |
| 86 |
| 87 host.tabIndex = -1; |
| 88 shouldBeEqualToString('host.getAttribute("tabindex")', '-1'); |
| 89 shouldBe('host.isTabStop', 'false'); |
| 90 |
| 91 expected_nav = [ |
| 92 'input-before', |
| 93 'host/inner-input', |
| 94 'input-after' |
| 95 ]; |
| 96 |
| 97 testFocusNavigationFowrad(expected_nav); |
| 98 expected_nav.reverse(); |
| 99 testFocusNavigationBackward(expected_nav); |
| 100 |
| 101 debug("Normal tab order with tabindex=-1 but isTabStop=true on host"); |
| 102 host.isTabStop = true; |
| 103 |
| 104 expected_nav = [ |
| 105 'input-before', |
| 106 'host/inner-input', |
| 107 'input-after' |
| 108 ]; |
| 109 |
| 110 testFocusNavigationFowrad(expected_nav); |
| 111 expected_nav.reverse(); |
| 112 testFocusNavigationBackward(expected_nav); |
| 113 |
| 114 debug("Normal tab order with tabindex=1 on host"); |
| 115 |
| 116 host.tabIndex = 1; |
| 117 shouldBeEqualToString('host.getAttribute("tabindex")', '1'); |
| 118 shouldBe('host.isTabStop', 'true'); |
| 119 |
| 120 expected_nav = [ |
| 121 'input-before', |
| 122 'input-after', |
| 123 'host', |
| 124 'host/inner-input' |
| 125 ]; |
| 126 |
| 127 testFocusNavigationFowrad(expected_nav); |
| 128 expected_nav.reverse(); |
| 129 testFocusNavigationBackward(expected_nav); |
| 130 |
| 131 debug("Normal tab order with tabindex=1 but isTabStop=false on host"); |
| 132 host.isTabStop = false; |
| 133 |
| 134 expected_nav = [ |
| 135 'input-before', |
| 136 'input-after', |
| 137 // 'host', // should skip host when isTabStop = false |
| 138 'host/inner-input' |
| 139 ]; |
| 140 |
| 141 testFocusNavigationFowrad(expected_nav); |
| 142 expected_nav.reverse(); |
| 143 testFocusNavigationBackward(expected_nav); |
| 144 } |
| 145 |
| 146 function run_tests() { |
| 147 if (window.testRunner) |
| 148 testRunner.dumpAsText(); |
| 149 |
| 150 if (!window.eventSender) { |
| 151 testFailed(''); |
| 152 return; |
| 153 } |
| 154 |
| 155 prepareDOMTree(document.body); |
| 156 test(); |
| 157 |
| 158 debug('Test finished.'); |
| 159 } |
| 160 |
| 161 run_tests(); |
| 162 </script> |
| 163 </body> |
| 164 </html> |
OLD | NEW |