Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: LayoutTests/fast/events/scroll-event-handler-count.html

Issue 206603002: Add EventHandlerRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tests now seem to pass. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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/03/27 16:43:31 Note that I've added a bunch more testing to touch
Sami 2014/04/02 19:58:05 Yes, definitely. No need to duplicate the same tes
+
+(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>
« no previous file with comments | « no previous file | LayoutTests/fast/events/scroll-event-handler-count-expected.txt » ('j') | Source/core/dom/EventHandlerRegistry.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698