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.touchEventHandlerCount(document)', '0'); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 touchtarget.ontouchend = function() {}; | 229 touchtarget.ontouchend = function() {}; |
230 | 230 |
231 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 231 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); |
232 | 232 |
233 touchtarget.appendChild(iframe); | 233 touchtarget.appendChild(iframe); |
234 | 234 |
235 nestedDocument = iframe.contentWindow.document; | 235 nestedDocument = iframe.contentWindow.document; |
236 nestedDocument.open('text/html', 'replace'); | 236 nestedDocument.open('text/html', 'replace'); |
237 nestedDocument.write('<!DOCTYPE html>\n<script>\nwindow.ontouchstart=functio
n(){};\n</' + 'script>\n' + | 237 nestedDocument.write('<!DOCTYPE html>\n<script>\nwindow.ontouchstart=functio
n(){};\n</' + 'script>\n' + |
238 '<div id=twoHandlers ontouchmove="function(){}" ontouchcancel="function(
){}"></div>'); | 238 '<div id=twoHandlers ontouchmove="function(){}" ontouchcancel="function(
){}"></div>'); |
239 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '3'); | 239 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '4'); |
240 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 240 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); |
241 | 241 |
242 nestedDocument.write('<script>window.ontouchstart=undefined</' + 'script>\n'
); | 242 nestedDocument.write('<script>window.ontouchstart=undefined</' + 'script>\n'
); |
243 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '2'); | 243 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '3'); |
244 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 244 shouldBe('window.internals.touchEventHandlerCount(document)', '3'); |
245 | 245 |
246 nestedDocument.write('<script>document.addEventListener("touchmove", functio
n(){});</' + 'script>\n'); | 246 nestedDocument.write('<script>document.addEventListener("touchmove", functio
n(){});</' + 'script>\n'); |
247 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '3'); | 247 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '4'); |
248 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 248 shouldBe('window.internals.touchEventHandlerCount(document)', '4'); |
249 | 249 |
250 nestedDocument.write('<script>document.getElementById("twoHandlers").remove(
);</' + 'script>\n'); | 250 nestedDocument.write('<script>document.getElementById("twoHandlers").remove(
);</' + 'script>\n'); |
251 gc(); | 251 gc(); |
252 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '1'); | 252 shouldBe('window.internals.touchEventHandlerCount(nestedDocument)', '2'); |
253 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); | 253 shouldBe('window.internals.touchEventHandlerCount(document)', '2'); |
254 nestedDocument.close(); | 254 nestedDocument.close(); |
255 | 255 |
256 touchtarget.removeChild(iframe); | 256 touchtarget.removeChild(iframe); |
257 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); | 257 shouldBe('window.internals.touchEventHandlerCount(document)', '1'); |
258 })(); | 258 })(); |
259 </script> | 259 </script> |
260 </body> | 260 </body> |
OLD | NEW |