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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var tests = [
function testDocumentNeedsScrollbars() {
var viewport =
new Viewport(new MockWindow(100, 100), new MockSizer(), function() {},
function() {}, function() {}, 10, 1, 0);
var scrollbars;
viewport.setDocumentDimensions(new MockDocumentDimensions(90, 90));
scrollbars = viewport.documentNeedsScrollbars_(1);
chrome.test.assertFalse(scrollbars.vertical);
chrome.test.assertFalse(scrollbars.horizontal);
viewport.setDocumentDimensions(new MockDocumentDimensions(100, 100));
scrollbars = viewport.documentNeedsScrollbars_(1);
chrome.test.assertFalse(scrollbars.vertical);
chrome.test.assertFalse(scrollbars.horizontal);
viewport.setDocumentDimensions(new MockDocumentDimensions(110, 110));
scrollbars = viewport.documentNeedsScrollbars_(1);
chrome.test.assertTrue(scrollbars.vertical);
chrome.test.assertTrue(scrollbars.horizontal);
viewport.setDocumentDimensions(new MockDocumentDimensions(90, 101));
scrollbars = viewport.documentNeedsScrollbars_(1);
chrome.test.assertTrue(scrollbars.vertical);
chrome.test.assertFalse(scrollbars.horizontal);
viewport.setDocumentDimensions(new MockDocumentDimensions(101, 90));
scrollbars = viewport.documentNeedsScrollbars_(1);
chrome.test.assertFalse(scrollbars.vertical);
chrome.test.assertTrue(scrollbars.horizontal);
viewport.setDocumentDimensions(new MockDocumentDimensions(91, 101));
scrollbars = viewport.documentNeedsScrollbars_(1);
chrome.test.assertTrue(scrollbars.vertical);
chrome.test.assertTrue(scrollbars.horizontal);
viewport.setDocumentDimensions(new MockDocumentDimensions(101, 91));
scrollbars = viewport.documentNeedsScrollbars_(1);
chrome.test.assertTrue(scrollbars.vertical);
chrome.test.assertTrue(scrollbars.horizontal);
viewport.setDocumentDimensions(new MockDocumentDimensions(40, 51));
scrollbars = viewport.documentNeedsScrollbars_(2);
chrome.test.assertTrue(scrollbars.vertical);
chrome.test.assertFalse(scrollbars.horizontal);
viewport.setDocumentDimensions(new MockDocumentDimensions(101, 202));
scrollbars = viewport.documentNeedsScrollbars_(0.5);
chrome.test.assertTrue(scrollbars.vertical);
chrome.test.assertFalse(scrollbars.horizontal);
chrome.test.succeed();
},
function testSetZoom() {
var mockSizer = new MockSizer();
var mockWindow = new MockWindow(100, 100, mockSizer);
var mockCallback = new MockViewportChangedCallback();
var viewport = new Viewport(mockWindow, mockSizer, mockCallback.callback,
function() {}, function() {}, 0, 1, 0);
// Test setting the zoom without the document dimensions set. The sizer
// shouldn't change size.
mockCallback.reset();
viewport.setZoom(0.5);
chrome.test.assertEq(0.5, viewport.zoom);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('0px', mockSizer.style.width);
chrome.test.assertEq('0px', mockSizer.style.height);
chrome.test.assertEq(0, mockWindow.pageXOffset);
chrome.test.assertEq(0, mockWindow.pageYOffset);
viewport.setZoom(1);
viewport.setDocumentDimensions(new MockDocumentDimensions(200, 200));
// Test zooming out.
mockCallback.reset();
viewport.setZoom(0.5);
chrome.test.assertEq(0.5, viewport.zoom);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('100px', mockSizer.style.width);
chrome.test.assertEq('100px', mockSizer.style.height);
// Test zooming in.
mockCallback.reset();
viewport.setZoom(2);
chrome.test.assertEq(2, viewport.zoom);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('400px', mockSizer.style.width);
chrome.test.assertEq('400px', mockSizer.style.height);
// Test that the scroll position scales correctly. It scales relative to the
// top-left of the page.
viewport.setZoom(1);
mockWindow.pageXOffset = 50;
mockWindow.pageYOffset = 50;
viewport.setZoom(2);
chrome.test.assertEq('400px', mockSizer.style.width);
chrome.test.assertEq('400px', mockSizer.style.height);
chrome.test.assertEq(100, mockWindow.pageXOffset);
chrome.test.assertEq(100, mockWindow.pageYOffset);
mockWindow.scrollTo(250, 250);
viewport.setZoom(1);
chrome.test.assertEq('200px', mockSizer.style.width);
chrome.test.assertEq('200px', mockSizer.style.height);
chrome.test.assertEq(100, mockWindow.pageXOffset);
chrome.test.assertEq(100, mockWindow.pageYOffset);
var documentDimensions = new MockDocumentDimensions(0, 0);
documentDimensions.addPage(200, 200);
viewport.setDocumentDimensions(documentDimensions);
mockWindow.scrollTo(0, 0);
viewport.fitToPage();
viewport.setZoom(1);
chrome.test.assertEq(Viewport.FittingType.NONE, viewport.fittingType);
chrome.test.assertEq('200px', mockSizer.style.width);
chrome.test.assertEq('200px', mockSizer.style.height);
chrome.test.assertEq(0, mockWindow.pageXOffset);
chrome.test.assertEq(0, mockWindow.pageYOffset);
viewport.fitToWidth();
viewport.setZoom(1);
chrome.test.assertEq(Viewport.FittingType.NONE, viewport.fittingType);
chrome.test.assertEq('200px', mockSizer.style.width);
chrome.test.assertEq('200px', mockSizer.style.height);
chrome.test.assertEq(0, mockWindow.pageXOffset);
chrome.test.assertEq(0, mockWindow.pageYOffset);
chrome.test.succeed();
},
function testGetMostVisiblePage() {
var mockWindow = new MockWindow(100, 100);
var viewport = new Viewport(mockWindow, new MockSizer(), function() {},
function() {}, function() {}, 0, 1, 0);
var documentDimensions = new MockDocumentDimensions(100, 100);
documentDimensions.addPage(50, 100);
documentDimensions.addPage(100, 100);
documentDimensions.addPage(100, 200);
viewport.setDocumentDimensions(documentDimensions);
viewport.setZoom(1);
// Scrolled to the start of the first page.
mockWindow.scrollTo(0, 0);
chrome.test.assertEq(0, viewport.getMostVisiblePage());
// Scrolled to the start of the second page.
mockWindow.scrollTo(0, 100);
chrome.test.assertEq(1, viewport.getMostVisiblePage());
// Scrolled half way through the first page.
mockWindow.scrollTo(0, 50);
chrome.test.assertEq(0, viewport.getMostVisiblePage());
// Scrolled just over half way through the first page.
mockWindow.scrollTo(0, 51);
chrome.test.assertEq(1, viewport.getMostVisiblePage());
// Scrolled most of the way through the second page.
mockWindow.scrollTo(0, 180);
chrome.test.assertEq(2, viewport.getMostVisiblePage());
// Scrolled just past half way through the second page.
mockWindow.scrollTo(0, 160);
chrome.test.assertEq(1, viewport.getMostVisiblePage());
// Scrolled just over half way through the first page with 2x zoom.
viewport.setZoom(2);
mockWindow.scrollTo(0, 151);
chrome.test.assertEq(1, viewport.getMostVisiblePage());
// Zoomed out with the entire document visible.
viewport.setZoom(0.25);
mockWindow.scrollTo(0, 0);
chrome.test.assertEq(0, viewport.getMostVisiblePage());
chrome.test.succeed();
},
function testFitToWidth() {
var mockWindow = new MockWindow(100, 100);
var mockSizer = new MockSizer();
var mockCallback = new MockViewportChangedCallback();
var viewport = new Viewport(mockWindow, mockSizer, mockCallback.callback,
function() {}, function() {}, 0, 1, 0);
var documentDimensions = new MockDocumentDimensions();
// Test with a document width which matches the window width.
documentDimensions.addPage(100, 100);
viewport.setDocumentDimensions(documentDimensions);
viewport.setZoom(0.1);
mockCallback.reset();
viewport.fitToWidth();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_WIDTH,
viewport.fittingType);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('100px', mockSizer.style.width);
chrome.test.assertEq(1, viewport.zoom);
// Test with a document width which is twice the size of the window width.
documentDimensions.reset();
documentDimensions.addPage(200, 100);
viewport.setDocumentDimensions(documentDimensions);
mockCallback.reset();
viewport.fitToWidth();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_WIDTH,
viewport.fittingType);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('100px', mockSizer.style.width);
chrome.test.assertEq(0.5, viewport.zoom);
// Test with a document width which is half the size of the window width.
documentDimensions.reset();
documentDimensions.addPage(50, 100);
viewport.setDocumentDimensions(documentDimensions);
mockCallback.reset();
viewport.fitToWidth();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_WIDTH,
viewport.fittingType);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('100px', mockSizer.style.width);
chrome.test.assertEq(2, viewport.zoom);
// Test that the scroll position stays the same relative to the page after
// fit to page is called.
documentDimensions.reset();
documentDimensions.addPage(50, 400);
viewport.setDocumentDimensions(documentDimensions);
viewport.setZoom(1);
mockWindow.scrollTo(0, 100);
mockCallback.reset();
viewport.fitToWidth();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_WIDTH,
viewport.fittingType);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq(2, viewport.zoom);
chrome.test.assertEq(0, viewport.position.x);
chrome.test.assertEq(200, viewport.position.y);
// Test fitting works with scrollbars. The page will need to be zoomed to
// fit to width, which will cause the page height to span outside of the
// viewport, triggering 15px scrollbars to be shown.
viewport = new Viewport(mockWindow, mockSizer, mockCallback.callback,
function() {}, function() {}, 15, 1, 0);
documentDimensions.reset();
documentDimensions.addPage(50, 100);
viewport.setDocumentDimensions(documentDimensions);
mockCallback.reset();
viewport.fitToWidth();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_WIDTH,
viewport.fittingType);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('85px', mockSizer.style.width);
chrome.test.assertEq(1.7, viewport.zoom);
chrome.test.succeed();
},
function testFitToPage() {
var mockWindow = new MockWindow(100, 100);
var mockSizer = new MockSizer();
var mockCallback = new MockViewportChangedCallback();
var viewport = new Viewport(mockWindow, mockSizer, mockCallback.callback,
function() {}, function() {}, 0, 1, 0);
var documentDimensions = new MockDocumentDimensions();
// Test with a page size which matches the window size.
documentDimensions.addPage(100, 100);
viewport.setDocumentDimensions(documentDimensions);
viewport.setZoom(0.1);
mockCallback.reset();
viewport.fitToPage();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_PAGE,
viewport.fittingType);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('100px', mockSizer.style.width);
chrome.test.assertEq('100px', mockSizer.style.height);
chrome.test.assertEq(1, viewport.zoom);
// Test with a page size whose width is larger than its height.
documentDimensions.reset();
documentDimensions.addPage(200, 100);
viewport.setDocumentDimensions(documentDimensions);
mockCallback.reset();
viewport.fitToPage();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_PAGE,
viewport.fittingType);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('100px', mockSizer.style.width);
chrome.test.assertEq('50px', mockSizer.style.height);
chrome.test.assertEq(0.5, viewport.zoom);
// Test with a page size whose height is larger than its width.
documentDimensions.reset();
documentDimensions.addPage(100, 200);
viewport.setDocumentDimensions(documentDimensions);
mockCallback.reset();
viewport.fitToPage();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_PAGE,
viewport.fittingType);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('50px', mockSizer.style.width);
chrome.test.assertEq('100px', mockSizer.style.height);
chrome.test.assertEq(0.5, viewport.zoom);
// Test that when there are multiple pages the height of the most visible
// page and the width of the widest page are sized to.
documentDimensions.reset();
documentDimensions.addPage(100, 100);
documentDimensions.addPage(200, 400);
viewport.setDocumentDimensions(documentDimensions);
viewport.setZoom(1);
mockWindow.scrollTo(0, 0);
mockCallback.reset();
viewport.fitToPage();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_PAGE,
viewport.fittingType);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('100px', mockSizer.style.width);
chrome.test.assertEq('250px', mockSizer.style.height);
chrome.test.assertEq(0.5, viewport.zoom);
viewport.setZoom(1);
mockWindow.scrollTo(0, 100);
mockCallback.reset();
viewport.fitToPage();
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq('50px', mockSizer.style.width);
chrome.test.assertEq('125px', mockSizer.style.height);
chrome.test.assertEq(0.25, viewport.zoom);
// Test that the top of the most visible page is scrolled to.
documentDimensions.reset();
documentDimensions.addPage(200, 200);
documentDimensions.addPage(100, 400);
viewport.setDocumentDimensions(documentDimensions);
viewport.setZoom(1);
mockWindow.scrollTo(0, 0);
viewport.fitToPage();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_PAGE,
viewport.fittingType);
chrome.test.assertEq(0.5, viewport.zoom);
chrome.test.assertEq(0, viewport.position.x);
chrome.test.assertEq(0, viewport.position.y);
viewport.setZoom(1);
mockWindow.scrollTo(0, 175);
viewport.fitToPage();
chrome.test.assertEq(0.25, viewport.zoom);
chrome.test.assertEq(0, viewport.position.x);
chrome.test.assertEq(50, viewport.position.y);
// Test that when the window size changes, fit-to-page occurs but does not
// scroll to the top of the page (it should stay at the scaled scroll
// position).
mockWindow.scrollTo(0, 0);
viewport.fitToPage();
chrome.test.assertEq(Viewport.FittingType.FIT_TO_PAGE,
viewport.fittingType);
chrome.test.assertEq(0.5, viewport.zoom);
mockWindow.scrollTo(0, 10);
mockWindow.setSize(50, 50);
chrome.test.assertEq(0.25, viewport.zoom);
chrome.test.assertEq(0, viewport.position.x);
chrome.test.assertEq(5, viewport.position.y);
chrome.test.succeed();
},
function testGoToPage() {
var mockWindow = new MockWindow(100, 100);
var mockSizer = new MockSizer();
var mockCallback = new MockViewportChangedCallback();
var viewport = new Viewport(mockWindow, mockSizer, mockCallback.callback,
function() {}, function() {}, 0, 1, 0);
var documentDimensions = new MockDocumentDimensions();
documentDimensions.addPage(100, 100);
documentDimensions.addPage(200, 200);
documentDimensions.addPage(100, 400);
viewport.setDocumentDimensions(documentDimensions);
viewport.setZoom(1);
mockCallback.reset();
viewport.goToPage(0);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq(0, viewport.position.x);
chrome.test.assertEq(0, viewport.position.y);
mockCallback.reset();
viewport.goToPage(1);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq(0, viewport.position.x);
chrome.test.assertEq(100, viewport.position.y);
mockCallback.reset();
viewport.goToPage(2);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq(0, viewport.position.x);
chrome.test.assertEq(300, viewport.position.y);
viewport.setZoom(0.5);
mockCallback.reset();
viewport.goToPage(2);
chrome.test.assertTrue(mockCallback.wasCalled);
chrome.test.assertEq(0, viewport.position.x);
chrome.test.assertEq(150, viewport.position.y);
chrome.test.succeed();
},
function testGetPageScreenRect() {
var mockWindow = new MockWindow(100, 100);
var mockSizer = new MockSizer();
var mockCallback = new MockViewportChangedCallback();
var viewport = new Viewport(mockWindow, mockSizer, mockCallback.callback,
function() {}, function() {}, 0, 1, 0);
var documentDimensions = new MockDocumentDimensions();
documentDimensions.addPage(100, 100);
documentDimensions.addPage(200, 200);
viewport.setDocumentDimensions(documentDimensions);
viewport.setZoom(1);
// Test that the rect of the first page is positioned/sized correctly.
mockWindow.scrollTo(0, 0);
var rect1 = viewport.getPageScreenRect(0);
chrome.test.assertEq(Viewport.PAGE_SHADOW.left + 100 / 2, rect1.x);
chrome.test.assertEq(Viewport.PAGE_SHADOW.top, rect1.y);
chrome.test.assertEq(100 - Viewport.PAGE_SHADOW.right -
Viewport.PAGE_SHADOW.left, rect1.width);
chrome.test.assertEq(100 - Viewport.PAGE_SHADOW.bottom -
Viewport.PAGE_SHADOW.top, rect1.height);
// Check that when we scroll, the rect of the first page is updated
// correctly.
mockWindow.scrollTo(100, 10);
var rect2 = viewport.getPageScreenRect(0);
chrome.test.assertEq(rect1.x - 100, rect2.x);
chrome.test.assertEq(rect1.y - 10, rect2.y);
chrome.test.assertEq(rect1.width, rect2.width);
chrome.test.assertEq(rect1.height, rect2.height);
// Check the rect of the second page is positioned/sized correctly.
mockWindow.scrollTo(0, 100);
rect1 = viewport.getPageScreenRect(1);
chrome.test.assertEq(Viewport.PAGE_SHADOW.left, rect1.x);
chrome.test.assertEq(Viewport.PAGE_SHADOW.top, rect1.y);
chrome.test.assertEq(200 - Viewport.PAGE_SHADOW.right -
Viewport.PAGE_SHADOW.left, rect1.width);
chrome.test.assertEq(200 - Viewport.PAGE_SHADOW.bottom -
Viewport.PAGE_SHADOW.top, rect1.height);
chrome.test.succeed();
},
function testBeforeZoomAfterZoom() {
var mockWindow = new MockWindow(100, 100);
var mockSizer = new MockSizer();
var viewport;
var afterZoomCalled = false;
var beforeZoomCalled = false;
var afterZoom = function() {
afterZoomCalled = true;
chrome.test.assertTrue(beforeZoomCalled);
chrome.test.assertEq(0.5, viewport.zoom);
};
var beforeZoom = function() {
beforeZoomCalled = true;
chrome.test.assertFalse(afterZoomCalled);
chrome.test.assertEq(1, viewport.zoom);
};
viewport = new Viewport(mockWindow, mockSizer, function() {},
beforeZoom, afterZoom, 0, 1, 0);
viewport.setZoom(0.5);
chrome.test.succeed();
},
function testInitialSetDocumentDimensionsZoomConstrained() {
var viewport =
new Viewport(new MockWindow(100, 100), new MockSizer(), function() {},
function() {}, function() {}, 0, 1.2, 0);
viewport.setDocumentDimensions(new MockDocumentDimensions(50, 50));
chrome.test.assertEq(1.2, viewport.zoom);
chrome.test.succeed();
},
function testInitialSetDocumentDimensionsZoomUnconstrained() {
var viewport = new Viewport(
new MockWindow(100, 100),
new MockSizer(), function() {}, function() {}, function() {}, 0, 3, 0);
viewport.setDocumentDimensions(new MockDocumentDimensions(50, 50));
chrome.test.assertEq(2, viewport.zoom);
chrome.test.succeed();
},
function testToolbarHeightOffset() {
var mockSizer = new MockSizer();
var mockWindow = new MockWindow(100, 100);
var viewport = new Viewport(mockWindow,
mockSizer, function() {}, function() {}, function() {}, 0, 1, 50);
var documentDimensions = new MockDocumentDimensions(0, 0);
documentDimensions.addPage(50, 500);
viewport.setDocumentDimensions(documentDimensions);
viewport.setZoom(1);
// Check that the sizer incorporates the toolbar height.
chrome.test.assertEq('550px', mockSizer.style.height);
chrome.test.assertEq('50px', mockSizer.style.width);
chrome.test.assertEq(0, viewport.position.x);
// Check the sizer incorporates the toolbar height correctly even if zoomed.
viewport.setZoom(2);
chrome.test.assertEq('1050px', mockSizer.style.height);
chrome.test.assertEq('100px', mockSizer.style.width);
// Test that the viewport scrolls to the correct offset when fit-to-page is
// enabled. The top of the viewport should be at the start of the document.
viewport.fitToPage();
chrome.test.assertEq(0, viewport.position.y);
// Check that going to a page scrolls to the correct offset when fit-to-page
// is enabled. The top of the viewport should be at the start of the
// document.
mockWindow.scrollTo(0, 100);
viewport.goToPage(0);
chrome.test.assertEq(0, viewport.position.y);
// Check that going to a page scrolls to the correct offset when fit-to-page
// is not enabled. The top of the viewport should be before start of the
// document.
viewport.setZoom(1);
viewport.goToPage(0);
chrome.test.assertEq(-50, viewport.position.y);
chrome.test.succeed();
}
];
chrome.test.runTests(tests);
|