| 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 <script> | |
| 20 if (window.internals) { | |
| 21 window.internals.settings.setScrollAnimatorEnabled(true); | |
| 22 } | |
| 23 | |
| 24 setup({explicit_done:true}); | |
| 25 </script> | |
| 26 </head> | |
| 27 <body> | |
| 28 <div id="scroll"> | |
| 29 <div id="content"></div> | |
| 30 </div> | |
| 31 <script> | |
| 32 /** | |
| 33 * This test is to make sure smooth scrolling is turned on sub frame | |
| 34 * scrollbars. | |
| 35 * Actually animation and calculation is tested by unittest. This only | |
| 36 * test that non main frame scrollbars can scroll and they are not just | |
| 37 * snapping to the correct position when smooth scrolling is on. | |
| 38 */ | |
| 39 | |
| 40 function testing() { | |
| 41 var div = document.getElementById("scroll"); | |
| 42 // Generate what end position should be if there is no smooth scrolling. | |
| 43 var endPosition = (function() { | |
| 44 if (window.internals) { | |
| 45 window.internals.settings.setScrollAnimatorEnabled(false); | |
| 46 } | |
| 47 div.scrollByPages(10); | |
| 48 | |
| 49 if (window.internals) { | |
| 50 window.internals.settings.setScrollAnimatorEnabled(true); | |
| 51 } | |
| 52 return div.scrollTop; | |
| 53 }) (); | |
| 54 | |
| 55 // Test that div is scrollable and reset scrollTop to 0. | |
| 56 test(function() {div.scrollTop = 0; assert_equals(div.scrollTop, 0)}, "R
eset scrollable area to starting point."); | |
| 57 | |
| 58 var smoothScrollTest = async_test("Smooth scrolling is on for non mainfr
ame scrollbars."); | |
| 59 // Test that checks scrollTop is between start and end. | |
| 60 var testFunc = smoothScrollTest.step_func(function() { | |
| 61 var cur = div.scrollTop; | |
| 62 assert_greater_than(cur, 0, "Scrolling has started."); | |
| 63 assert_less_than(cur, endPosition, "Scrolling hasn't ended."); | |
| 64 smoothScrollTest.done(); | |
| 65 done(); | |
| 66 }); | |
| 67 // In the middle of scroll animation, scrollTop should be between start
and end position. | |
| 68 div.onscroll = window.setTimeout(testFunc, 200); | |
| 69 | |
| 70 div.scrollByPages(10); | |
| 71 | |
| 72 // If there is no smooth scrolling, test times out. Explicitly ends test
so it would show up as fail. | |
| 73 window.setTimeout(function() { | |
| 74 smoothScrollTest.done(); | |
| 75 done(); | |
| 76 }, 1000); | |
| 77 } | |
| 78 | |
| 79 window.addEventListener('load', testing, false); | |
| 80 </script> | |
| 81 </body> | |
| 82 </html> | |
| OLD | NEW |