OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
2 <script src="../../../resources/js-test.js"></script> | |
3 <style> | |
4 body { | |
5 padding: 0px; | |
6 margin: 0px; | |
7 } | |
8 | |
9 .spacer { | |
10 position: absolute; | |
11 left: 0px; | |
12 top: 0px; | |
13 margin: 0px; | |
14 padding: 0px; | |
15 width: 2000px; | |
16 height: 1500px; | |
17 } | |
18 </style> | |
19 <script language="JavaScript" type="text/javascript"> | |
20 if (window.testRunner && window.eventSender) { | |
21 window.eventSender.setPageScaleFactorLimits(0.5, 4.0); | |
bokan
2014/11/18 23:21:51
I changed the min scale factor to 0.5 so that ther
Rick Byers
2014/11/20 19:23:31
SGTM
| |
22 window.jsTestIsAsync = true; | |
23 testRunner.dumpAsText(); | |
24 testRunner.waitUntilDone(); | |
25 } | |
26 | |
27 description("This test makes sure the window properties related to the\ | |
28 viewport remain correct under pinch-to-zoom."); | |
29 | |
30 debug('===Unscaled==='); | |
31 debug(''); | |
32 shouldBe('window.innerWidth', '800'); | |
33 shouldBe('window.innerHeight', '600'); | |
34 | |
35 function testPinchedIn() { | |
36 debug(''); | |
37 debug('===Pinch Zoom in to 2X==='); | |
38 debug(''); | |
39 window.eventSender.setPageScaleFactor(2.0, 0, 0); | |
40 shouldBe('window.innerWidth', '400'); | |
41 shouldBe('window.innerHeight', '300'); | |
42 shouldBe('window.scrollX', '0'); | |
43 shouldBe('window.scrollY', '0'); | |
44 | |
45 window.scrollBy(10, 20); | |
46 shouldBe('window.scrollX', '10'); | |
47 shouldBe('window.scrollY', '20'); | |
48 window.scrollBy(1590, 1180); | |
49 shouldBe('window.scrollX', '1600'); | |
50 shouldBe('window.scrollY', '1200'); | |
51 window.scrollBy(-1600, -1200); | |
52 shouldBe('window.scrollX', '0'); | |
53 shouldBe('window.scrollY', '0'); | |
54 window.scrollTo(1600, 1200); | |
55 shouldBe('window.scrollX', '1600'); | |
56 shouldBe('window.scrollY', '1200'); | |
57 window.scrollTo(0, 0); | |
58 shouldBe('window.scrollX', '0'); | |
59 shouldBe('window.scrollY', '0'); | |
60 } | |
61 | |
62 function testMaximallyPinchedOut() { | |
63 debug(''); | |
64 debug('===Pinch Out to 0.5X==='); | |
65 debug(''); | |
66 window.eventSender.setPageScaleFactor(0.5, 0, 0); | |
67 shouldBe('window.innerWidth', '1600'); | |
68 shouldBe('window.innerHeight', '1200'); | |
69 shouldBe('window.scrollX', '0'); | |
70 shouldBe('window.scrollY', '0'); | |
71 | |
72 window.scrollBy(10, 20); | |
73 shouldBe('window.scrollX', '10'); | |
74 shouldBe('window.scrollY', '20'); | |
75 window.scrollBy(390, 280); | |
76 shouldBe('window.scrollX', '400'); | |
77 shouldBe('window.scrollY', '300'); | |
78 window.scrollBy(-400, -300); | |
79 shouldBe('window.scrollX', '0'); | |
80 shouldBe('window.scrollY', '0'); | |
81 window.scrollTo(400, 300); | |
82 shouldBe('window.scrollX', '400'); | |
83 shouldBe('window.scrollY', '300'); | |
84 window.scrollTo(0, 0); | |
85 shouldBe('window.scrollX', '0'); | |
86 shouldBe('window.scrollY', '0'); | |
87 } | |
88 | |
89 function testOnScroll() { | |
90 debug(''); | |
91 debug('===Test OnScroll==='); | |
92 debug(''); | |
93 window.eventSender.setPageScaleFactor(1.0, 0, 0); | |
94 shouldBe('window.innerWidth', '800'); | |
95 shouldBe('window.innerHeight', '600'); | |
96 shouldBe('window.scrollX', '0'); | |
97 shouldBe('window.scrollY', '0'); | |
98 | |
99 // First scroll scrolls only the outer viewport. | |
100 // Second scrolls the outer and the inner. | |
101 // Third scrolls only the inner. | |
102 var scrolls = [100, 400, 100]; | |
103 var scrollsReceived = 0; | |
104 | |
105 document.onscroll = function() { | |
106 ++scrollsReceived; | |
107 debug('PASS OnScroll called for scroll #' + scrollsReceived); | |
108 if (scrollsReceived < scrolls.length) { | |
109 var scrollAmount = scrolls[scrollsReceived]; | |
110 window.scrollBy(scrollAmount, 0); | |
111 } else if (scrollsReceived == scrolls.length) { | |
112 window.scrollTo(1200, 0); | |
113 } else { | |
114 debug(''); | |
115 finishJSTest(); | |
116 } | |
117 } | |
118 | |
119 window.scrollBy(scrolls[0], 0); | |
120 | |
121 // Each onscroll should be dispatched in adjacent frames so 4*16ms. Wait a little longer in case | |
122 // we miss a frame or two but anything more and assume the scroll event wasn't fired. | |
123 setTimeout(function() { | |
124 testFailed("Failed to receive scroll event #" + (scrollsReceived+1)) ; | |
125 finishJSTest(); | |
126 }, 200); | |
127 } | |
128 | |
129 function forceLayout() { | |
130 window.scrollTo(0, 0); | |
131 } | |
132 | |
133 function runTests() { | |
134 if (window.testRunner && window.eventSender) { | |
135 forceLayout(); | |
136 testPinchedIn(); | |
137 testMaximallyPinchedOut(); | |
138 testOnScroll(); | |
139 } | |
140 } | |
141 | |
142 onload = runTests; | |
143 </script> | |
144 <div class="spacer"></div> | |
OLD | NEW |