Chromium Code Reviews| Index: LayoutTests/fast/events/scroll-event-handler-count.html |
| diff --git a/LayoutTests/fast/events/scroll-event-handler-count.html b/LayoutTests/fast/events/scroll-event-handler-count.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..379abc722f6f09c03586b100e4a9fea921045dc6 |
| --- /dev/null |
| +++ b/LayoutTests/fast/events/scroll-event-handler-count.html |
| @@ -0,0 +1,69 @@ |
| +<script src="../../resources/js-test.js"></script> |
| +<script> |
| +description("This test checks that we correctly update the scroll event handler count as event handlers are added and removed"); |
|
Rick Byers
2014/04/03 15:33:19
You meant to remove this file too, right?
|
| + |
| +(function() { |
| + // Test addEventListener/removeEventListener on the document. |
| + var listener = function() { } |
| + |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
| + document.addEventListener('scroll', listener, true); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + document.addEventListener('scroll', listener, false); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '2'); |
| + document.removeEventListener('scroll', listener, true); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + |
| + // Try removing the capturing listener again. |
| + document.removeEventListener('scroll', listener, true); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + |
| + document.removeEventListener('scroll', listener, false); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
| +})(); |
| + |
| +(function() { |
| + // Test setting onscroll on the document. |
| + |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
| + document.onscroll = function() { } |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + document.onscroll = function() { } |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + document.onscroll = null; |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
| +})(); |
| + |
| +(function() { |
| + // Test addEventListener/removeEventListener on the window. |
| + var listener = function() { } |
| + |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
| + window.addEventListener('scroll', listener, true); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + window.addEventListener('scroll', listener, false); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '2'); |
| + window.removeEventListener('scroll', listener, true); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + |
| + // Try removing the capturing listener again. |
| + window.removeEventListener('scroll', listener, true); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + |
| + window.removeEventListener('scroll', listener, false); |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
| +})(); |
| + |
| +(function() { |
| + // Test setting onscroll on the window. |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
| + window.onscroll = function() { } |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + window.onscroll = function() { } |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '1'); |
| + window.onscroll = null; |
| + shouldBe('window.internals.scrollEventHandlerCount(document)', '0'); |
| +})(); |
| + |
| +</script> |
| +</body> |