26 var floatPrecision
= 0.1;
27 var scrollDistance
= 10;
28 var expectedScrollDistance
;
30 var integerScrollOffset
= false;
32 function scroll(scaleFactor
) {
33 if (integerScrollOffset
)
34 expectedScrollDistance
= Math
.floor(scrollDistance
/scaleFactor
);
36 expectedScrollDistance
= scrollDistance
/scaleFactor
;
38 scrollBox
.scrollTop
= 0;
40 eventSender
.gestureScrollBegin(10, 100);
41 for(var i
= 0; i
< scrollDistance
; ++i
) {
42 eventSender
.gestureScrollUpdate(0, -1);
44 eventSender
.gestureScrollEnd(0, 0);
46 shouldBeCloseTo('scrollBox.scrollTop', expectedScrollDistance
, floatPrecision
);
48 scrollBox
.scrollTop
= 20;
50 eventSender
.gestureScrollBegin(10, 300);
51 for(var i
= 0; i
< scrollDistance
; ++i
) {
52 eventSender
.gestureScrollUpdate(0, 1);
54 eventSender
.gestureScrollEnd(0, 0);
56 if (integerScrollOffset
)
57 expectedScrollDistance
= Math
.floor(20 - scrollDistance
/scaleFactor
);
59 expectedScrollDistance
= 20 - scrollDistance
/scaleFactor
;
61 shouldBeCloseTo('scrollBox.scrollTop', expectedScrollDistance
, floatPrecision
);
64 function scaleWithEventSender(scaleFactor
) {
65 if (window
.internals
) {
66 window
.internals
.setPageScaleFactor(scaleFactor
);
71 scrollBox
= document
.getElementById("scrollbox");
73 debug('Scrolling unscaled div');
74 scaleWithEventSender(1.0);
76 debug('Scrolling 1.5 scaled div');
77 scaleWithEventSender(1.5);
79 debug('Scrolling 1.63 scaled div');
80 scaleWithEventSender(1.63);
82 debug('Scrolling 2.0 scaled div');
83 scaleWithEventSender(2.0);
88 if (window
.eventSender
&& window
.internals
) {
89 description('This tests that a div scrolled by gesture touch while the page is scaled still scrolls at the rate of the touch');
91 window
.internals
.settings
.setPreferCompositingToLCDTextEnabled(true);
92 integerScrollOffset
= false;
95 window
.internals
.settings
.setPreferCompositingToLCDTextEnabled(false);
96 integerScrollOffset
= true;
100 debug('eventSender not detected. Not running test.');
104 <script src=
"../../resources/js-test.js"></script>
106 <body onload=
"run_test();">
107 <div id=
"scrollbox" style=
"left:0; top:0; width:500px; height:500px; position:absolute; overflow-y: scroll; overflow-x: scroll;">
108 <div id=
"bluebox"></div>
109 <div id=
"redbox"></div>
110 <div id=
"bluebox"></div>
111 <div id=
"redbox"></div>
112 <div id=
"bluebox"></div>
113 <div id=
"redbox"></div>
114 <div id=
"bluebox"></div>
115 <div id=
"redbox"></div>
116 <div id=
"bluebox"></div>
117 <div id=
"redbox"></div>
118 <div id=
"bluebox"></div>
119 <div id=
"redbox"></div>
122 <div id=
"console"></div>