Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <style> | 2 <style> |
| 3 .spacer { | 3 .spacer { |
| 4 height: 1000px; | 4 height: 1000px; |
| 5 width: 1000px; | 5 width: 1000px; |
| 6 } | 6 } |
| 7 #scroller, body { | 7 #scroller, body { |
| 8 height: 100px; | 8 height: 100px; |
| 9 width: 100px; | 9 width: 100px; |
| 10 overflow: scroll; | 10 overflow: scroll; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 </body> | 21 </body> |
| 22 | 22 |
| 23 <script src="../../resources/js-test.js"></script> | 23 <script src="../../resources/js-test.js"></script> |
| 24 <script> | 24 <script> |
| 25 | 25 |
| 26 description("Verifies that scrolling APIs support fractional offsets."); | 26 description("Verifies that scrolling APIs support fractional offsets."); |
| 27 // Note we current support fractional scrolling only for the special case of | 27 // Note we current support fractional scrolling only for the special case of |
| 28 // browser zoom. When http://crbug.com/414283 is fixed, we should test | 28 // browser zoom. When http://crbug.com/414283 is fixed, we should test |
| 29 // other cases like device scale. | 29 // other cases like device scale. |
| 30 | 30 |
| 31 var floatPrecision = 0.01; | |
|
Rick Byers
2014/10/02 21:44:05
How close is this in practice? Eg. would 0.0001 a
Yufeng Shen (Slow to review)
2014/10/02 23:34:34
Yes. Element::setScrollLeft() has a conversion fro
Rick Byers
2014/10/03 16:42:46
Ok. Ideally we'll even be able to go back to shou
| |
| 32 | |
| 31 function testScroll(scrollOffset) { | 33 function testScroll(scrollOffset) { |
| 32 | 34 |
| 33 debug('Scrolling DIV with scrollTop/scrollLeft'); | 35 debug('Scrolling DIV with scrollTop/scrollLeft'); |
| 34 scroller.scrollTop = scrollOffset; | 36 scroller.scrollTop = scrollOffset; |
| 35 shouldBeEqualToNumber('scroller.scrollTop', scrollOffset); | 37 shouldBeCloseTo('scroller.scrollTop', scrollOffset, floatPrecision); |
| 36 scroller.scrollLeft = scrollOffset; | 38 scroller.scrollLeft = scrollOffset; |
| 37 shouldBeEqualToNumber('scroller.scrollLeft', scrollOffset); | 39 shouldBeCloseTo('scroller.scrollLeft', scrollOffset, floatPrecision); |
| 38 | 40 |
| 39 // Note that the body element is a special case - we don't attempt to | 41 // Note that the body element is a special case - we don't attempt to |
| 40 // test it here as it's semantics are in flux (http://goo.gl/BFHtMR). | 42 // test it here as it's semantics are in flux (http://goo.gl/BFHtMR). |
| 41 | 43 |
| 42 debug('Scrolling the document with window.scroll'); | 44 debug('Scrolling the document with window.scroll'); |
| 43 window.scroll(0,0); | 45 window.scroll(0,0); |
| 44 scrollOffset++; | 46 scrollOffset++; |
| 45 window.scroll(scrollOffset, scrollOffset); | 47 window.scroll(scrollOffset, scrollOffset); |
| 46 shouldBeEqualToNumber('window.scrollY', scrollOffset); | 48 shouldBeCloseTo('window.scrollY', scrollOffset, floatPrecision); |
| 47 shouldBeEqualToNumber('window.scrollX', scrollOffset); | 49 shouldBeCloseTo('window.scrollX', scrollOffset, floatPrecision); |
| 48 | 50 |
| 49 debug('Scrolling the document with window.scrollTo'); | 51 debug('Scrolling the document with window.scrollTo'); |
| 50 window.scroll(0,0); | 52 window.scroll(0,0); |
| 51 window.scrollTo(scrollOffset, scrollOffset); | 53 window.scrollTo(scrollOffset, scrollOffset); |
| 52 shouldBeEqualToNumber('window.pageYOffset', scrollOffset); | 54 shouldBeCloseTo('window.pageYOffset', scrollOffset, floatPrecision); |
| 53 shouldBeEqualToNumber('window.pageXOffset', scrollOffset); | 55 shouldBeCloseTo('window.pageXOffset', scrollOffset, floatPrecision); |
| 54 | 56 |
| 55 debug('Scrolling the document with window.scrollBy'); | 57 debug('Scrolling the document with window.scrollBy'); |
| 56 window.scroll(1,1); | 58 window.scroll(1,1); |
| 57 window.scrollBy(scrollOffset - 1, scrollOffset - 1); | 59 window.scrollBy(scrollOffset - 1, scrollOffset - 1); |
| 58 shouldBeEqualToNumber('window.scrollY', scrollOffset); | 60 shouldBeCloseTo('window.scrollY', scrollOffset, floatPrecision); |
| 59 shouldBeEqualToNumber('window.scrollX', scrollOffset); | 61 shouldBeCloseTo('window.scrollX', scrollOffset, floatPrecision); |
| 60 | 62 |
| 61 debug(''); | 63 debug(''); |
| 62 } | 64 } |
| 63 | 65 |
| 64 function testPageZoom(zoom) { | 66 function testPageZoom(zoom) { |
| 65 debug('---- Testing page zoom = ' + zoom + ' ----'); | 67 debug('---- Testing page zoom = ' + zoom + ' ----'); |
| 66 eventSender.setPageZoomFactor(zoom); | 68 eventSender.setPageZoomFactor(zoom); |
| 67 testScroll(4); | 69 testScroll(4); |
| 68 testScroll(4.5); | 70 testScroll(4.5); |
| 69 } | 71 } |
| 70 | 72 |
| 73 testScroll(4.2); | |
| 71 testPageZoom(2); | 74 testPageZoom(2); |
| 72 </script> | 75 </script> |
| OLD | NEW |