OLD | NEW |
1 <div id="scrolltarget"> | 1 <div id="scrolltarget"> |
2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
3 <script> | 3 <script> |
4 description("This test checks that we correctly update the scroll event handler
count as event handlers are added and removed"); | 4 description("This test checks that we correctly update the scroll event handler
count as event handlers are added and removed"); |
5 (function() { | 5 (function() { |
6 // Test addEventListener/removeEventListener on the document. | 6 // Test addEventListener/removeEventListener on the document. |
7 var listener = function() { } | 7 var listener = function() { } |
8 | 8 |
9 shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); | 9 shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
10 document.addEventListener('scroll', listener, true); | 10 document.addEventListener('scroll', listener, true); |
(...skipping 15 matching lines...) Expand all Loading... |
26 // Test setting onscroll on the document. | 26 // Test setting onscroll on the document. |
27 | 27 |
28 shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); | 28 shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
29 document.onscroll = function() { } | 29 document.onscroll = function() { } |
30 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); | 30 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
31 document.onscroll = function() { } | 31 document.onscroll = function() { } |
32 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); | 32 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
33 document.onscroll = null; | 33 document.onscroll = null; |
34 shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); | 34 shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
35 })(); | 35 })(); |
| 36 debug("Test that nested Documents' scroll handlers are properly tracked in their
parent Document."); |
| 37 (function() { |
| 38 var iframe = document.createElement('iframe'); |
| 39 var scrolltarget = document.getElementById('scrolltarget'); |
| 40 scrolltarget.onscroll = function() {}; |
| 41 |
| 42 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| 43 |
| 44 scrolltarget.appendChild(iframe); |
| 45 |
| 46 nestedDocument = iframe.contentWindow.document; |
| 47 nestedDocument.open('text/html', 'replace'); |
| 48 nestedDocument.write('<!DOCTYPE html>\n<script>\ndocument.onscroll=function(
){};\n</' + 'script>\n'); |
| 49 shouldBe('window.internals.scrollEventHandlerCount(nestedDocument)', '1'); |
| 50 shouldBe('window.internals.scrollEventHandlerCount(document)', '2'); |
| 51 |
| 52 nestedDocument.write('<script>document.onscroll=undefined</' + 'script>\n'); |
| 53 shouldBe('window.internals.scrollEventHandlerCount(nestedDocument)', '0'); |
| 54 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| 55 |
| 56 nestedDocument.close(); |
| 57 |
| 58 scrolltarget.removeChild(iframe); |
| 59 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| 60 })(); |
36 </script> | 61 </script> |
37 </body> | 62 </body> |
OLD | NEW |