OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <style> |
| 5 #scroll { |
| 6 width: 100px; |
| 7 height: 100px; |
| 8 overflow:scroll; |
| 9 } |
| 10 |
| 11 #content { |
| 12 width: 10000px; |
| 13 height: 10000px; |
| 14 background-color: blue; |
| 15 } |
| 16 </style> |
| 17 <script src="../../resources/testharness.js"></script> |
| 18 <script src="../../resources/testharnessreport.js"></script> |
| 19 </head> |
| 20 <body> |
| 21 <div id="scroll"> |
| 22 <div id="content"></div> |
| 23 </div> |
| 24 <script> |
| 25 /** |
| 26 * This test is to make sure smooth scrolling is turned on sub frame |
| 27 * scrollbars. |
| 28 * Actually animation and calculation is tested by unittest. This only |
| 29 * test that non main frame scrollbars can scroll and they are not just |
| 30 * snapping to the correct position when smooth scrolling is on. |
| 31 */ |
| 32 if (window.internals) { |
| 33 window.internals.settings.setScrollAnimatorEnabled(true); |
| 34 } |
| 35 |
| 36 function testing() { |
| 37 var div = document.getElementById("scroll"); |
| 38 |
| 39 test(function() {assert_equals(div.scrollTop, 0)}, "Test starting point"
); |
| 40 test(function() {div.scrollByLines(10); assert_not_equals(div.scrollTop,
0)}, "Test div is able to scroll"); |
| 41 test(function() {div.scrollTop = 0; assert_equals(div.scrollTop, 0)}, "R
eset to starting point"); |
| 42 |
| 43 var smoothScrollTest = async_test('smooth scrolls'); |
| 44 var info = { |
| 45 pos: 0, |
| 46 step: 0 |
| 47 }; |
| 48 |
| 49 div.onscroll = smoothScrollTest.step_func(function() { |
| 50 var cur = div.scrollTop; |
| 51 if (info.step != 0) { |
| 52 assert_true(cur > pos); |
| 53 } |
| 54 info.pos = cur; |
| 55 info.step += 1; |
| 56 }); |
| 57 |
| 58 test(function() { |
| 59 div.scrollByPages(50); |
| 60 assert_greater_than(info.step, 1); |
| 61 assert_greater_than(div.scrollTop, 0); |
| 62 }, "scroll"); |
| 63 smoothScrollTest.done(); |
| 64 } |
| 65 |
| 66 window.addEventListener('load', testing, false); |
| 67 </script> |
| 68 </body> |
| 69 </html> |
OLD | NEW |