OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 ::-webkit-scrollbar { |
| 4 width: 0px; |
| 5 height: 0px; |
| 6 } |
| 7 |
| 8 body, html { |
| 9 width: 100%; |
| 10 height: 100%; |
| 11 } |
| 12 |
| 13 body { |
| 14 margin: 0px; |
| 15 } |
| 16 |
| 17 #container { |
| 18 width: 1000px; |
| 19 height: 1000px; |
| 20 overflow: auto; |
| 21 } |
| 22 |
| 23 #spacer { |
| 24 width: 2000px; |
| 25 height: 1900px; |
| 26 } |
| 27 </style> |
| 28 |
| 29 <div id="container"> |
| 30 <div id="spacer"> |
| 31 <span id="spanner">TEST</span> |
| 32 </div> |
| 33 </div> |
| 34 |
| 35 <script src="../../resources/testharness.js"></script> |
| 36 <script src="../../resources/testharnessreport.js"></script> |
| 37 |
| 38 <script> |
| 39 test(function() { |
| 40 assert_false(typeof document.setRootScroller === 'undefined'); |
| 41 }, 'setRootScroller API enabled'); |
| 42 test(function() { |
| 43 // Setting the container object should succeed. |
| 44 assert_equals(document.rootScroller, document.documentElement); |
| 45 var container = document.querySelector('#container'); |
| 46 document.setRootScroller(container); |
| 47 assert_equals(document.rootScroller, container); |
| 48 |
| 49 // Trying to set the <span> should fail with an exception thrown since a |
| 50 // span is not a valid scroller. |
| 51 assert_throws( |
| 52 'InvalidStateError', |
| 53 function() { |
| 54 document.setRootScroller(document.querySelector('#spanner')); |
| 55 }, |
| 56 'Trying to set a non-block flow element should throw'); |
| 57 assert_equals(document.rootScroller, container); |
| 58 |
| 59 // Scroll the container <div> past the end. The scrolls should not chain |
| 60 // past the rootScroller to the scrollingElement. |
| 61 if (typeof eventSender !== 'undefined') { |
| 62 eventSender.gestureScrollBegin(500, 500); |
| 63 eventSender.gestureScrollUpdate(-300, -300); |
| 64 eventSender.gestureScrollEnd(0, 0); |
| 65 eventSender.gestureScrollBegin(500, 500); |
| 66 eventSender.gestureScrollUpdate(-300, -300); |
| 67 eventSender.gestureScrollEnd(0, 0); |
| 68 eventSender.gestureScrollBegin(500, 500); |
| 69 eventSender.gestureScrollUpdate(-300, -300); |
| 70 eventSender.gestureScrollEnd(0, 0); |
| 71 eventSender.gestureScrollBegin(500, 500); |
| 72 eventSender.gestureScrollUpdate(-300, -300); |
| 73 eventSender.gestureScrollEnd(0, 0); |
| 74 |
| 75 assert_equals(container.scrollTop, 900); |
| 76 assert_equals(container.scrollLeft, 1000); |
| 77 assert_equals(document.scrollingElement.scrollTop, 0); |
| 78 assert_equals(document.scrollingElement.scrollLeft, 0); |
| 79 } |
| 80 |
| 81 // Making the current rootScroller an invalid scroller should reset the |
| 82 // rootScroller to the default, the documentElement. |
| 83 container.style.display = "none"; |
| 84 newRootScroller = document.rootScroller; |
| 85 assert_equals(newRootScroller, document.documentElement); |
| 86 |
| 87 container.style.display = "block"; |
| 88 assert_equals(newRootScroller, document.documentElement); |
| 89 |
| 90 // Now scrolling over the <div> should scroll the scrollingElement. |
| 91 if (typeof eventSender !== 'undefined') { |
| 92 eventSender.gestureScrollBegin(500, 500); |
| 93 eventSender.gestureScrollUpdate(-300, -300); |
| 94 eventSender.gestureScrollEnd(0, 0); |
| 95 eventSender.gestureScrollBegin(500, 500); |
| 96 eventSender.gestureScrollUpdate(-300, -300); |
| 97 eventSender.gestureScrollEnd(0, 0); |
| 98 eventSender.gestureScrollBegin(500, 500); |
| 99 eventSender.gestureScrollUpdate(-300, -300); |
| 100 eventSender.gestureScrollEnd(0, 0); |
| 101 eventSender.gestureScrollBegin(500, 500); |
| 102 eventSender.gestureScrollUpdate(-300, -300); |
| 103 eventSender.gestureScrollEnd(0, 0); |
| 104 |
| 105 assert_equals(document.scrollingElement.scrollTop, 400); |
| 106 assert_equals(document.scrollingElement.scrollLeft, 200); |
| 107 } |
| 108 |
| 109 // Don't output the text in spanner. |
| 110 document.querySelector('#spanner').style.display = 'none'; |
| 111 |
| 112 }, 'Test the setRootScroller API basic functionality'); |
| 113 </script> |
OLD | NEW |