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

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

Issue 237963014: Track scroll event handlers in nested documents (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: didMove{Into,OutOf}Page Created 6 years, 8 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
index 7c757ab313869cccb09b79f1656ad16e01499805..0532fe88c51de7c21dd841adeee63c5a32462243 100644
--- a/LayoutTests/fast/events/scroll-event-handler-count.html
+++ b/LayoutTests/fast/events/scroll-event-handler-count.html
@@ -33,5 +33,64 @@ description("This test checks that we correctly update the scroll event handler
document.onscroll = null;
shouldBe('window.internals.scrollEventHandlerCount(document)', '0');
})();
+debug("Test that nested Documents' scroll handlers are properly tracked in their parent Document.");
+(function() {
+ var iframe = document.createElement('iframe');
+ var scrolltarget = document.getElementById('scrolltarget');
+ scrolltarget.onscroll = function() {};
+
+ shouldBe('window.internals.scrollEventHandlerCount(document)', '1');
+
+ scrolltarget.appendChild(iframe);
+
+ nestedDocument = iframe.contentWindow.document;
+ nestedDocument.open('text/html', 'replace');
+ nestedDocument.write('<!DOCTYPE html>\n<script>\ndocument.onscroll=function(){};\n</' + 'script>\n');
+ shouldBe('window.internals.scrollEventHandlerCount(nestedDocument)', '2');
+ shouldBe('window.internals.scrollEventHandlerCount(document)', '2');
+
+ nestedDocument.write('<script>document.onscroll=undefined</' + 'script>\n');
+ shouldBe('window.internals.scrollEventHandlerCount(nestedDocument)', '1');
+ shouldBe('window.internals.scrollEventHandlerCount(document)', '1');
+
+ nestedDocument.close();
+
+ scrolltarget.removeChild(iframe);
+ shouldBe('window.internals.scrollEventHandlerCount(document)', '1');
+ scrolltarget.onscroll = undefined;
+})();
+debug("Test that detaching a nested Document with handlers works properly.");
+(function() {
+ var iframe = document.createElement('iframe');
+ var scrolltarget = document.getElementById('scrolltarget');
+
+ scrolltarget.appendChild(iframe);
+
+ nestedDocument = iframe.contentWindow.document;
+ nestedDocument.open('text/html', 'replace');
+ nestedDocument.write('<!DOCTYPE html>\n<script>\ndocument.onscroll=function(){};\n</' + 'script>\n');
+ shouldBe('window.internals.scrollEventHandlerCount(nestedDocument)', '1');
+ shouldBe('window.internals.scrollEventHandlerCount(document)', '1');
+
+ nestedDocument.close();
+ scrolltarget.removeChild(iframe);
+ shouldBe('window.internals.scrollEventHandlerCount(document)', '0');
+})();
+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 -
+(function() {
+ var doc = document.implementation.createHTMLDocument('');
+ var div = doc.createElement('div');
+
+ div.addEventListener('scroll', function() { });
+ document.body.appendChild(div);
+ shouldBe('window.internals.scrollEventHandlerCount(document)', '1');
+
+ document.body.removeChild(div);
+ shouldBe('window.internals.scrollEventHandlerCount(document)', '1');
+
+ div = null;
+ gc();
+ shouldBe('window.internals.scrollEventHandlerCount(document)', '0');
+})();
</script>
</body>

Powered by Google App Engine
This is Rietveld 408576698