1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script>
var numScrolls;
var pageHeight = 2000;
var pageWidth = 2000;
function reset()
{
window.scrollTo(0, 0);
internals.setPageScaleFactor(2);
}
function testArrowKeys()
{
// Test up and down.
window.eventSender.keyDown('downArrow');
shouldBeGreaterThan('internals.visualViewportScrollY()', '0');
numScrolls = Math.ceil((pageHeight - internals.visualViewportHeight()) / internals.visualViewportScrollY());
for(var i = 0; i < numScrolls - 1; ++i) {
window.eventSender.keyDown('downArrow');
}
shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visualViewportHeight()');
for(var i = 0; i < numScrolls; ++i) {
window.eventSender.keyDown('upArrow');
}
shouldBe('internals.visualViewportScrollY()', '0');
// Now test left and right.
reset();
window.eventSender.keyDown('rightArrow');
numScrolls = Math.ceil((pageWidth - internals.visualViewportWidth()) / internals.visualViewportScrollX());
for(var i = 0; i < numScrolls - 1; ++i) {
window.eventSender.keyDown('rightArrow');
}
shouldBe('internals.visualViewportScrollX()', 'pageWidth - internals.visualViewportWidth()');
for(var i = 0; i < numScrolls; ++i) {
window.eventSender.keyDown('leftArrow');
}
shouldBe('internals.visualViewportScrollX()', '0');
}
function testHomeEnd()
{
window.eventSender.keyDown('end');
shouldBe('window.scrollY', 'pageHeight - window.innerHeight');
shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visualViewportHeight()');
window.eventSender.keyDown('home');
shouldBe('window.scrollY', '0');
shouldBe('internals.visualViewportScrollY()', '0');
}
function testPageUpDown()
{
window.eventSender.keyDown('pageDown');
shouldBeGreaterThan('internals.visualViewportScrollY()', '0');
numScrolls = Math.ceil((pageHeight - internals.visualViewportHeight()) / internals.visualViewportScrollY());
for(var i = 0; i < numScrolls - 1; ++i) {
window.eventSender.keyDown('pageDown');
}
shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visualViewportHeight()');
for(var i = 0; i < numScrolls; ++i) {
window.eventSender.keyDown('pageUp');
}
shouldBe('internals.visualViewportScrollY()', '0');
}
function testSpacebar()
{
window.eventSender.keyDown(' ');
shouldBeGreaterThan('internals.visualViewportScrollY()', '0');
numScrolls = Math.ceil((pageHeight - internals.visualViewportHeight()) / internals.visualViewportScrollY());
for(var i = 0; i < numScrolls - 1; ++i) {
window.eventSender.keyDown(' ');
}
shouldBe('internals.visualViewportScrollY()', 'pageHeight - internals.visualViewportHeight()');
for(var i = 0; i < numScrolls; ++i) {
window.eventSender.keyDown(' ', 'shiftKey');
}
shouldBe('internals.visualViewportScrollY()', '0');
}
function runTest()
{
description(
'Test that keyboard scrolling while the page is scaled scrolls ' +
'both viewports. To test manually, pinch zoom into the page and ' +
'use the arrow keys, page up/down, home/end to scroll the page. ' +
'You should be able to reach the end of the page bounds (i.e. ' +
'scroll to see the divs at the bounds.)');
if (window.eventSender && window.internals) {
internals.settings.setScrollAnimatorEnabled(false);
reset();
debug('Testing arrow keys:');
testArrowKeys();
reset();
debug('');
debug('Testing home and end keys:');
testHomeEnd();
reset();
debug('');
debug('Testing page up and page down keys:');
testPageUpDown();
reset();
debug('');
debug('Testing spacebar:');
testSpacebar();
}
}
addEventListener('load', runTest);
</script>
<style>
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
div {
width: 200px;
height: 20px;
background-color: red;
}
html{
padding: 0px;
margin: 0px;
width: 2000px;
height: 2000px;
}
.top {
position: absolute;
top: 0px;
left: 300px;
}
.middle{
position: absolute;
top: 975px;
left: 300px;
}
.bottom {
position: absolute;
top: 1980px;
left: 300px;
}
.left {
position: absolute;
top: 275px;
left: 0px;
}
.right {
position: absolute;
top: 275px;
left: 1800px;
}
</style>
<p id="description" style="width: 800px"></p>
<p id="console" style="width: 800px"></p>
<div class="top">Top of page</div>
<div class="bottom">Bottom of page</div>
<div class="left">Left of page</div>
<div class="right">Right of page</div>
<div class="middle">Middle of page</div>
|