Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: LayoutTests/fast/scrolling/scrolling-apis-subpixel.html

Issue 610423004: Preserve fractional scroll offset for JS scrolling API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // FIXME: Make this smaller. crbug.com/414283.
32 var floatPrecision = 0.01;
33
31 function testScroll(scrollOffset) { 34 function testScroll(scrollOffset) {
32 35
33 debug('Scrolling DIV with scrollTop/scrollLeft'); 36 debug('Scrolling DIV with scrollTop/scrollLeft');
34 scroller.scrollTop = scrollOffset; 37 scroller.scrollTop = scrollOffset;
35 shouldBeEqualToNumber('scroller.scrollTop', scrollOffset); 38 shouldBeCloseTo('scroller.scrollTop', scrollOffset, floatPrecision);
36 scroller.scrollLeft = scrollOffset; 39 scroller.scrollLeft = scrollOffset;
37 shouldBeEqualToNumber('scroller.scrollLeft', scrollOffset); 40 shouldBeCloseTo('scroller.scrollLeft', scrollOffset, floatPrecision);
38 41
39 // Note that the body element is a special case - we don't attempt to 42 // 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). 43 // test it here as it's semantics are in flux (http://goo.gl/BFHtMR).
41 44
42 debug('Scrolling the document with window.scroll'); 45 debug('Scrolling the document with window.scroll');
43 window.scroll(0,0); 46 window.scroll(0,0);
44 scrollOffset++; 47 scrollOffset++;
45 window.scroll(scrollOffset, scrollOffset); 48 window.scroll(scrollOffset, scrollOffset);
46 shouldBeEqualToNumber('window.scrollY', scrollOffset); 49 shouldBeCloseTo('window.scrollY', scrollOffset, floatPrecision);
47 shouldBeEqualToNumber('window.scrollX', scrollOffset); 50 shouldBeCloseTo('window.scrollX', scrollOffset, floatPrecision);
48 51
49 debug('Scrolling the document with window.scrollTo'); 52 debug('Scrolling the document with window.scrollTo');
50 window.scroll(0,0); 53 window.scroll(0,0);
51 window.scrollTo(scrollOffset, scrollOffset); 54 window.scrollTo(scrollOffset, scrollOffset);
52 shouldBeEqualToNumber('window.pageYOffset', scrollOffset); 55 shouldBeCloseTo('window.pageYOffset', scrollOffset, floatPrecision);
53 shouldBeEqualToNumber('window.pageXOffset', scrollOffset); 56 shouldBeCloseTo('window.pageXOffset', scrollOffset, floatPrecision);
54 57
55 debug('Scrolling the document with window.scrollBy'); 58 debug('Scrolling the document with window.scrollBy');
56 window.scroll(1,1); 59 window.scroll(1,1);
57 window.scrollBy(scrollOffset - 1, scrollOffset - 1); 60 window.scrollBy(scrollOffset - 1, scrollOffset - 1);
58 shouldBeEqualToNumber('window.scrollY', scrollOffset); 61 shouldBeCloseTo('window.scrollY', scrollOffset, floatPrecision);
59 shouldBeEqualToNumber('window.scrollX', scrollOffset); 62 shouldBeCloseTo('window.scrollX', scrollOffset, floatPrecision);
60 63
61 debug(''); 64 debug('');
62 } 65 }
63 66
64 function testPageZoom(zoom) { 67 function testPageZoom(zoom) {
65 debug('---- Testing page zoom = ' + zoom + ' ----'); 68 debug('---- Testing page zoom = ' + zoom + ' ----');
66 eventSender.setPageZoomFactor(zoom); 69 eventSender.setPageZoomFactor(zoom);
67 testScroll(4); 70 testScroll(4);
68 testScroll(4.5); 71 testScroll(4.5);
69 } 72 }
70 73
74 testScroll(4.2);
71 testPageZoom(2); 75 testPageZoom(2);
72 </script> 76 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698