Chromium Code Reviews| 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)', '2'); | |
| 50 shouldBe('window.internals.scrollEventHandlerCount(document)', '2'); | |
| 51 | |
| 52 nestedDocument.write('<script>document.onscroll=undefined</' + 'script>\n'); | |
| 53 shouldBe('window.internals.scrollEventHandlerCount(nestedDocument)', '1'); | |
| 54 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); | |
| 55 | |
| 56 nestedDocument.close(); | |
| 57 | |
| 58 scrolltarget.removeChild(iframe); | |
| 59 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); | |
| 60 scrolltarget.onscroll = undefined; | |
| 61 })(); | |
| 62 debug("Test that detaching a nested Document with handlers works properly."); | |
| 63 (function() { | |
| 64 var iframe = document.createElement('iframe'); | |
| 65 var scrolltarget = document.getElementById('scrolltarget'); | |
| 66 | |
| 67 scrolltarget.appendChild(iframe); | |
| 68 | |
| 69 nestedDocument = iframe.contentWindow.document; | |
| 70 nestedDocument.open('text/html', 'replace'); | |
| 71 nestedDocument.write('<!DOCTYPE html>\n<script>\ndocument.onscroll=function( ){};\n</' + 'script>\n'); | |
| 72 shouldBe('window.internals.scrollEventHandlerCount(nestedDocument)', '1'); | |
| 73 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); | |
| 74 | |
| 75 nestedDocument.close(); | |
| 76 scrolltarget.removeChild(iframe); | |
| 77 shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); | |
| 78 })(); | |
| 79 debug('Moving a scroll event listener between documents should keep it active'); | |
|
Rick Byers
2014/04/28 21:18:07
The test below doesn't seem to be testing what thi
Sami
2014/04/29 14:21:28
Sorry, this the description was a little unclear -
| |
| 80 (function() { | |
| 81 var doc = document.implementation.createHTMLDocument(''); | |
| 82 var div = doc.createElement('div'); | |
| 83 | |
| 84 div.addEventListener('scroll', function() { }); | |
| 85 document.body.appendChild(div); | |
| 86 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); | |
| 87 | |
| 88 document.body.removeChild(div); | |
| 89 shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); | |
| 90 | |
| 91 div = null; | |
| 92 gc(); | |
| 93 shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); | |
| 94 })(); | |
| 36 </script> | 95 </script> |
| 37 </body> | 96 </body> |
| OLD | NEW |