| OLD | NEW |
| 1 <script src="../../../resources/js-test.js"></script> | 1 <script src="../../../resources/js-test.js"></script> |
| 2 <div id='touchtarget' style='width: 50; height: 50'></div> | 2 <div id='touchtarget' style='width: 50; height: 50'></div> |
| 3 <script> | 3 <script> |
| 4 description("This test checks that we correctly update the touch event handler c
ount as event handlers are added and removed"); | 4 description("This test checks that we correctly update the touch event handler c
ount as event handlers are added and removed"); |
| 5 | 5 |
| 6 debug("Test addEventListener/removeEventListener on the document."); | 6 debug("Test addEventListener/removeEventListener on the document."); |
| 7 (function() { | 7 (function() { |
| 8 var listener = function() { } | 8 var listener = function() { } |
| 9 | 9 |
| 10 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 10 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 11 document.addEventListener('touchstart', listener, true); | 11 document.addEventListener('touchstart', listener, true); |
| 12 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 12 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 13 document.addEventListener('touchmove', listener, true); | 13 document.addEventListener('touchmove', listener, true); |
| 14 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 14 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 15 document.addEventListener('touchstart', listener, false); | 15 document.addEventListener('touchstart', listener, false); |
| 16 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 16 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '3'
); |
| 17 document.removeEventListener('touchmove', listener, true); | 17 document.removeEventListener('touchmove', listener, true); |
| 18 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 18 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 19 document.removeEventListener('touchstart', listener, true); | 19 document.removeEventListener('touchstart', listener, true); |
| 20 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 20 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 21 | 21 |
| 22 // Try removing the capturing listener again. | 22 // Try removing the capturing listener again. |
| 23 document.removeEventListener('touchstart', listener, true); | 23 document.removeEventListener('touchstart', listener, true); |
| 24 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 24 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 25 document.removeEventListener('touchmove', listener, true); | 25 document.removeEventListener('touchmove', listener, true); |
| 26 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 26 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 27 | 27 |
| 28 document.removeEventListener('touchstart', listener, false); | 28 document.removeEventListener('touchstart', listener, false); |
| 29 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 29 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 30 })(); | 30 })(); |
| 31 | 31 |
| 32 debug("Test setting touch handlers on the document."); | 32 debug("Test setting touch handlers on the document."); |
| 33 (function() { | 33 (function() { |
| 34 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 34 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 35 document.ontouchstart = function() { } | 35 document.ontouchstart = function() { } |
| 36 document.ontouchmove = function() {} | 36 document.ontouchmove = function() {} |
| 37 document.ontouchend = function() {} | 37 document.ontouchend = function() {} |
| 38 document.ontouchcancel = function() {} | 38 document.ontouchcancel = function() {} |
| 39 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); | 39 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 40 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 40 document.ontouchstart = function() { } | 41 document.ontouchstart = function() { } |
| 41 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); | 42 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 43 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 42 document.ontouchstart = null; | 44 document.ontouchstart = null; |
| 43 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 45 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 46 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 44 document.ontouchstart = null; | 47 document.ontouchstart = null; |
| 45 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 48 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 49 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 50 document.ontouchend = null; |
| 51 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 52 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 46 document.ontouchmove = null; | 53 document.ontouchmove = null; |
| 47 document.ontouchend = null; | |
| 48 document.ontouchcancel = null; | 54 document.ontouchcancel = null; |
| 49 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 55 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 56 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '0'
); |
| 50 })(); | 57 })(); |
| 51 | 58 |
| 52 debug("Test addEventListener/removeEventListener on the window."); | 59 debug("Test addEventListener/removeEventListener on the window."); |
| 53 (function() { | 60 (function() { |
| 54 var listener = function() { } | 61 var listener = function() { } |
| 55 | 62 |
| 56 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 63 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 57 window.addEventListener('touchstart', listener, true); | 64 window.addEventListener('touchstart', listener, true); |
| 58 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 65 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 59 window.addEventListener('touchmove', listener, true); | 66 window.addEventListener('touchmove', listener, true); |
| 60 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 67 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 61 window.addEventListener('touchstart', listener, false); | 68 window.addEventListener('touchstart', listener, false); |
| 62 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 69 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '3'
); |
| 63 window.removeEventListener('touchmove', listener, true); | 70 window.removeEventListener('touchmove', listener, true); |
| 64 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 71 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 65 window.removeEventListener('touchstart', listener, true); | 72 window.removeEventListener('touchstart', listener, true); |
| 66 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 73 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 67 | 74 |
| 68 // Try removing the capturing listener again. | 75 // Try removing the capturing listener again. |
| 69 window.removeEventListener('touchstart', listener, true); | 76 window.removeEventListener('touchstart', listener, true); |
| 70 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 77 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 71 window.removeEventListener('touchmove', listener, true); | 78 window.removeEventListener('touchmove', listener, true); |
| 72 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 79 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 73 | 80 |
| 74 window.removeEventListener('touchstart', listener, false); | 81 window.removeEventListener('touchstart', listener, false); |
| 75 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 82 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 76 })(); | 83 })(); |
| 77 | 84 |
| 78 debug("Test setting touch handlers on the window."); | 85 debug("Test setting touch handlers on the window."); |
| 79 (function() { | 86 (function() { |
| 80 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 87 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 81 window.ontouchstart = function() { } | 88 window.ontouchstart = function() { } |
| 82 window.ontouchmove = function() {} | 89 window.ontouchmove = function() {} |
| 83 window.ontouchend = function() {} | 90 window.ontouchend = function() {} |
| 84 window.ontouchcancel = function() {} | 91 window.ontouchcancel = function() {} |
| 85 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); | 92 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 93 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 86 window.ontouchstart = function() { } | 94 window.ontouchstart = function() { } |
| 87 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); | 95 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 96 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 88 window.ontouchstart = null; | 97 window.ontouchstart = null; |
| 89 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 98 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 99 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 90 window.ontouchstart = null; | 100 window.ontouchstart = null; |
| 91 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 101 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 102 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 103 window.ontouchend = null; |
| 104 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 105 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 92 window.ontouchmove = null; | 106 window.ontouchmove = null; |
| 93 window.ontouchend = null; | |
| 94 window.ontouchcancel = null; | 107 window.ontouchcancel = null; |
| 95 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 108 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 109 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '0'
); |
| 96 })(); | 110 })(); |
| 97 | 111 |
| 98 debug("Test addEventListener/removeEventListener on a div."); | 112 debug("Test addEventListener/removeEventListener on a div."); |
| 99 (function() { | 113 (function() { |
| 100 var listener = function() { } | 114 var listener = function() { } |
| 101 var div = document.getElementById('touchtarget'); | 115 var div = document.getElementById('touchtarget'); |
| 102 | 116 |
| 103 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 117 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 104 div.addEventListener('touchstart', listener, true); | 118 div.addEventListener('touchstart', listener, true); |
| 105 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 119 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 106 div.addEventListener('touchmove', listener, true); | 120 div.addEventListener('touchmove', listener, true); |
| 107 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 121 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 108 div.addEventListener('touchstart', listener, false); | 122 div.addEventListener('touchstart', listener, false); |
| 109 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 123 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '3'
); |
| 110 div.removeEventListener('touchmove', listener, true); | 124 div.removeEventListener('touchmove', listener, true); |
| 111 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 125 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 112 div.removeEventListener('touchstart', listener, true); | 126 div.removeEventListener('touchstart', listener, true); |
| 113 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 127 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 114 | 128 |
| 115 // Try removing the capturing listener again. | 129 // Try removing the capturing listener again. |
| 116 div.removeEventListener('touchstart', listener, true); | 130 div.removeEventListener('touchstart', listener, true); |
| 117 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 131 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 118 div.removeEventListener('touchmove', listener, true); | 132 div.removeEventListener('touchmove', listener, true); |
| 119 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 133 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 120 | 134 |
| 121 div.removeEventListener('touchstart', listener, false); | 135 div.removeEventListener('touchstart', listener, false); |
| 122 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 136 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 123 })(); | 137 })(); |
| 124 | 138 |
| 125 debug("Test setting touch handlers on a div."); | 139 debug("Test setting touch handlers on a div."); |
| 126 (function() { | 140 (function() { |
| 127 var div = document.getElementById('touchtarget'); | 141 var div = document.getElementById('touchtarget'); |
| 128 | 142 |
| 129 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 143 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 130 div.ontouchstart = function() { } | 144 div.ontouchstart = function() { } |
| 131 div.ontouchmove = function() { } | 145 div.ontouchmove = function() { } |
| 132 div.ontouchend = function() { } | 146 div.ontouchend = function() { } |
| 133 div.ontouchcancel = function() { } | 147 div.ontouchcancel = function() { } |
| 134 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); | 148 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 149 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 135 div.ontouchstart = function() { } | 150 div.ontouchstart = function() { } |
| 136 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); | 151 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 152 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 137 div.ontouchstart = null; | 153 div.ontouchstart = null; |
| 138 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 154 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 155 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 139 div.ontouchstart = null; | 156 div.ontouchstart = null; |
| 140 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 157 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 158 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 159 div.ontouchend = null; |
| 160 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 161 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 141 div.ontouchmove = null; | 162 div.ontouchmove = null; |
| 142 div.ontouchend = null; | |
| 143 div.ontouchcancel = null; | 163 div.ontouchcancel = null; |
| 144 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 164 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 165 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '0'
); |
| 145 })(); | 166 })(); |
| 146 | 167 |
| 147 debug("Test redudant addEventListener on a div."); | 168 debug("Test redudant addEventListener on a div."); |
| 148 (function() { | 169 (function() { |
| 149 var listener = function() { } | 170 var listener = function() { } |
| 150 var div = document.getElementById('touchtarget'); | 171 var div = document.getElementById('touchtarget'); |
| 151 | 172 |
| 152 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 173 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 153 div.addEventListener('touchstart', listener, false); | 174 div.addEventListener('touchstart', listener, false); |
| 154 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 175 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 155 div.addEventListener('touchstart', listener, false); | 176 div.addEventListener('touchstart', listener, false); |
| 156 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 177 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 157 | 178 |
| 158 div.removeEventListener('touchstart', listener, false); | 179 div.removeEventListener('touchstart', listener, false); |
| 159 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 180 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 160 })(); | 181 })(); |
| 161 | 182 |
| 162 | 183 |
| 163 debug("Test addEventListener/removeEventListener on a new div."); | 184 debug("Test addEventListener/removeEventListener on a new div."); |
| 164 (function() { | 185 (function() { |
| 165 var div = document.createElement('div'); | 186 var div = document.createElement('div'); |
| 166 var touchtarget = document.getElementById('touchtarget'); | 187 var touchtarget = document.getElementById('touchtarget'); |
| 167 var listener = function() { } | 188 var listener = function() { } |
| 168 | 189 |
| 169 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 190 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 191 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '0'
); |
| 170 | 192 |
| 171 div.addEventListener('touchstart', listener, true); | 193 div.addEventListener('touchstart', listener, true); |
| 172 div.addEventListener('touchmove', listener, true); | 194 div.addEventListener('touchmove', listener, true); |
| 173 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 195 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 196 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '0'
); |
| 174 | 197 |
| 175 touchtarget.appendChild(div); | 198 touchtarget.appendChild(div); |
| 176 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 199 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 200 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '0'
); |
| 177 | 201 |
| 178 div.addEventListener('touchend', listener, true); | 202 div.addEventListener('touchend', listener, true); |
| 179 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 203 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 204 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 180 | 205 |
| 181 div.removeEventListener('touchstart', listener, true); | 206 div.removeEventListener('touchstart', listener, true); |
| 182 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 207 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 183 | 208 |
| 184 touchtarget.removeChild(div); | 209 touchtarget.removeChild(div); |
| 185 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 210 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 186 | 211 |
| 187 div.removeEventListener('touchmove', listener, false); | 212 div.removeEventListener('touchmove', listener, false); |
| 188 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 213 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 189 | 214 |
| 190 div.removeEventListener('touchmove', listener, true); | 215 div.removeEventListener('touchmove', listener, true); |
| 191 div.removeEventListener('touchend', listener, true); | 216 div.removeEventListener('touchend', listener, true); |
| 192 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 217 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 218 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '0'
); |
| 193 })(); | 219 })(); |
| 194 | 220 |
| 195 debug("Test setting touch handlers on a new div."); | 221 debug("Test setting touch handlers on a new div."); |
| 196 (function() { | 222 (function() { |
| 197 var div = document.createElement('div'); | 223 var div = document.createElement('div'); |
| 198 var touchtarget = document.getElementById('touchtarget'); | 224 var touchtarget = document.getElementById('touchtarget'); |
| 199 | 225 |
| 200 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 226 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 201 | 227 |
| 202 div.ontouchstart = function() { } | 228 div.ontouchstart = function() { } |
| 203 div.ontouchmove = function() { } | 229 div.ontouchmove = function() { } |
| 204 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 230 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 205 | 231 |
| 206 touchtarget.appendChild(div); | 232 touchtarget.appendChild(div); |
| 207 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 233 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 234 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '0'
); |
| 208 | 235 |
| 209 div.ontouchend = function() { } | 236 div.ontouchend = function() { } |
| 210 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 237 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 238 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 211 | 239 |
| 212 div.ontouchstart = null; | 240 div.ontouchstart = null; |
| 213 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 241 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 242 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 214 | 243 |
| 215 touchtarget.removeChild(div); | 244 touchtarget.removeChild(div); |
| 216 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 245 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 246 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 217 | 247 |
| 218 div.ontouchend = null; | 248 div.ontouchend = null; |
| 219 div.ontouchmove = null; | 249 div.ontouchmove = null; |
| 220 shouldBe('window.internals.touchEventHandlerCount(document)', '0'); | 250 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 251 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '0'
); |
| 221 })(); | 252 })(); |
| 222 | 253 |
| 223 var nestedDocument; | 254 var nestedDocument; |
| 224 | 255 |
| 225 debug("Test that nested Documents' touch handlers are properly tracked in their
parent Document."); | 256 debug("Test that nested Documents' touch handlers are properly tracked in their
parent Document."); |
| 226 (function() { | 257 (function() { |
| 227 var iframe = document.createElement('iframe'); | 258 var iframe = document.createElement('iframe'); |
| 228 var touchtarget = document.getElementById('touchtarget'); | 259 var touchtarget = document.getElementById('touchtarget'); |
| 229 touchtarget.ontouchend = function() {}; | 260 touchtarget.ontouchend = function() {}; |
| 230 | 261 |
| 231 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 262 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 263 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 232 | 264 |
| 233 touchtarget.appendChild(iframe); | 265 touchtarget.appendChild(iframe); |
| 234 | 266 |
| 235 nestedDocument = iframe.contentWindow.document; | 267 nestedDocument = iframe.contentWindow.document; |
| 236 nestedDocument.open('text/html', 'replace'); | 268 nestedDocument.open('text/html', 'replace'); |
| 237 nestedDocument.write('<!DOCTYPE html>\n<script>\nwindow.ontouchstart=functio
n(){};\n</' + 'script>\n' + | 269 nestedDocument.write('<!DOCTYPE html>\n<script>\nwindow.ontouchstart=functio
n(){};\n</' + 'script>\n' + |
| 238 '<div id=twoHandlers ontouchmove="function(){}" ontouchcancel="function(
){}"></div>'); | 270 '<div id=twoHandlers ontouchmove="function(){}" ontouchcancel="function(
){}"></div>'); |
| 239 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '4'); | 271 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(nestedDocument)
', '2'); |
| 240 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); | 272 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(nestedDocument)
', '2'); |
| 273 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 274 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 241 | 275 |
| 242 nestedDocument.write('<script>window.ontouchstart=undefined</' + 'script>\n'
); | 276 nestedDocument.write('<script>window.ontouchstart=undefined</' + 'script>\n'
); |
| 243 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '3'); | 277 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(nestedDocument)
', '1'); |
| 244 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); | 278 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(nestedDocument)
', '2'); |
| 279 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 280 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 245 | 281 |
| 246 nestedDocument.write('<script>document.addEventListener("touchmove", functio
n(){});</' + 'script>\n'); | 282 nestedDocument.write('<script>document.addEventListener("touchmove", functio
n(){});</' + 'script>\n'); |
| 247 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '4'); | 283 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(nestedDocument)
', '2'); |
| 248 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); | 284 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(nestedDocument)
', '2'); |
| 285 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '2'
); |
| 286 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '2'
); |
| 249 | 287 |
| 250 nestedDocument.write('<script>document.getElementById("twoHandlers").remove(
);</' + 'script>\n'); | 288 nestedDocument.write('<script>document.getElementById("twoHandlers").remove(
);</' + 'script>\n'); |
| 251 gc(); | 289 gc(); |
| 252 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '2'); | 290 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(nestedDocument)
', '1'); |
| 253 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 291 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(nestedDocument)
', '1'); |
| 292 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '1'
); |
| 293 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 254 nestedDocument.close(); | 294 nestedDocument.close(); |
| 255 | 295 |
| 256 touchtarget.removeChild(iframe); | 296 touchtarget.removeChild(iframe); |
| 257 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 297 shouldBe('window.internals.touchStartOrMoveEventHandlerCount(document)', '0'
); |
| 298 shouldBe('window.internals.touchEndOrCancelEventHandlerCount(document)', '1'
); |
| 258 })(); | 299 })(); |
| 259 </script> | 300 </script> |
| 260 </body> | 301 </body> |
| OLD | NEW |