Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / fire-scroll-event-element.html
blobf8c20747523cfd9a51dab9e58f0a04f445db00f1
1 <html>
2 <script src="../../resources/js-test.js"></script>
3 <body>
4 <div id="container" style="overflow: auto; width: 500px; height: 500px">
5 <div style="height: 5000px; width: 5000px;"></div>
6 </div>
7 <script>
8 description('Checks that the scroll event fires on elements asychronously and only once.');
10 var eventCount = 0;
11 var doneTimeout;
13 function scrollHandler(event)
15 eventCount++;
16 if (eventCount == 1) {
17 debug('Scroll event bubbles: ' + event.bubbles);
18 var container = document.getElementById('container');
19 var scrollX = container.scrollLeft;
20 var scrollY = container.scrollTop;
21 testPassed('Scroll position: (' + scrollX + ', ' + scrollY + ')');
22 // Don't call notifyDone straight away, in case there's another scroll event coming.
23 doneTimeout = setTimeout(finishJSTest, 100);
24 } else {
25 clearTimeout(doneTimeout);
26 testFailed('Scroll handler was invoked ' + eventCount + ' times');
27 finishJSTest();
31 onload = function()
33 var container = document.getElementById('container');
34 container.addEventListener('scroll', scrollHandler, false);
35 container.scrollTop = 100;
36 if (eventCount > 0) {
37 testFailed('Scroll event fired synchronously');
38 finishJSTest();
40 container.scrollTop = 200;
42 var jsTestIsAsync = true;
43 </script>
44 </body>
45 </html>