OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../../../resources/js-test.js"></script> | |
3 <script> | |
4 window.jsTestIsAsync = true; | |
5 var pageHeight = 1200; | |
6 var pageWidth = 1000; | |
7 | |
8 var testScrolls = [ | |
9 {key: 'downArrow', expectedX: 0, expectedY: pageHeight - window.innerHei ght}, | |
10 {key: 'upArrow', expectedX: 0, expectedY: 0}, | |
11 {key: 'rightArrow', expectedX: pageWidth - window.innerWidth, expectedY: 0}, | |
12 {key: 'leftArrow', expectedX: 0, expectedY: 0}, | |
13 {key: 'end', expectedX: 0, expectedY: pageHeight - window.innerHeight}, | |
14 {key: 'home', expectedX: 0, expectedY: 0}, | |
15 {key: 'pageDown', expectedX: 0, expectedY: pageHeight - window.innerHeig ht}, | |
16 {key: 'pageUp', expectedX: 0, expectedY: 0}, | |
17 {key: ' ', expectedX: 0, expectedY: pageHeight - window.innerHeight}, | |
18 ]; | |
19 var currentTest = -1; | |
20 | |
21 description("Test keyboard smooth scroll. The main purpose of this\ | |
22 test is to ensure that smooth scrolling on the compositor\ | |
skobes
2015/12/18 19:05:57
This doesn't actually test that the scroll is comp
ymalik
2015/12/18 19:35:47
So what I mean by that comment is that we really c
| |
23 works as intended."); | |
24 | |
25 function runTestCase(testCase) { | |
26 window.eventSender.keyDown(testCase.key); | |
27 if (window.scrollX == testCase.expectedX && window.scrollY == testCase.e xpectedY) { | |
ajuma
2015/12/18 19:02:54
Would this test also pass if all scrolls were inst
ymalik
2015/12/18 19:35:47
Yes. Is that bad?
ajuma
2015/12/18 19:51:12
Depends on what you're trying to test :) If it's
| |
28 testPassed(testCase.key + ' reached target'); | |
29 startNextTestCase(); | |
30 } else { | |
31 requestAnimationFrame(function() { | |
32 runTestCase(testCase); | |
33 }); | |
34 } | |
35 } | |
36 | |
37 function startNextTestCase() { | |
38 currentTest++; | |
39 if (currentTest >= testScrolls.length) { | |
40 finishJSTest(); | |
41 return; | |
42 } | |
43 runTestCase(testScrolls[currentTest]); | |
44 } | |
45 | |
46 function runTest() { | |
47 if (!window.eventSender || !window.internals) { | |
48 finishJSTest(); | |
49 return; | |
50 } | |
51 // Turn on smooth scrolling. | |
52 internals.settings.setScrollAnimatorEnabled(true); | |
53 | |
54 startNextTestCase(); | |
55 } | |
56 addEventListener('load', runTest); | |
57 </script> | |
58 | |
59 <style> | |
60 ::-webkit-scrollbar { | |
61 width: 0px; | |
62 height: 0px; | |
63 } | |
64 | |
65 div { | |
66 width: 200px; | |
67 height: 20px; | |
68 background-color: red; | |
69 } | |
70 | |
71 html{ | |
72 padding: 0px; | |
73 margin: 0px; | |
74 width: 1000px; | |
75 height: 1200px; | |
76 } | |
77 | |
78 .top { | |
79 position: absolute; | |
80 top: 0px; | |
81 left: 300px; | |
82 } | |
83 | |
84 .middle{ | |
85 position: absolute; | |
86 top: 575px; | |
87 left: 300px; | |
88 } | |
89 | |
90 .bottom { | |
91 position: absolute; | |
92 top: 1180px; | |
93 left: 300px; | |
94 } | |
95 | |
96 .left { | |
97 position: absolute; | |
98 top: 275px; | |
99 left: 0px; | |
100 } | |
101 | |
102 .right { | |
103 position: absolute; | |
104 top: 275px; | |
105 left: 800px; | |
106 } | |
107 </style> | |
108 <p id="description" style="width: 800px"></p> | |
109 <p id="console" style="width: 800px"></p> | |
110 <div class="top">Top of page</div> | |
111 <div class="bottom">Bottom of page</div> | |
112 <div class="left">Left of page</div> | |
113 <div class="right">Right of page</div> | |
114 <div class="middle">Middle of page</div> | |
OLD | NEW |