Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/emulation/scroll-and-scale-override.html

Issue 2096633002: Adds scroll position/scale emulation to DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync, patch in 2169483002 (+ regression test), add DevTools tests. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <html>
2 <head>
3
4 <script src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></s cript>
5
6 <style>
7 body {
8 margin: 0;
9 overflow: hidden;
10 min-width: 2000px;
11 min-height: 10000px;
12 }
13
14 div#layoutViewportDiv {
15 position: fixed;
16 z-index: 100;
17 width: 100%;
18 height: 100%;
19 }
20 </style>
21
22 <script>
23 function dumpMetrics()
24 {
25 return JSON.stringify({
26 visualWidth: window.innerWidth,
27 visualHeight: window.innerHeight,
28 layoutWidth: document.getElementById("layoutViewportDiv").clientWidth,
29 layoutHeight: document.getElementById("layoutViewportDiv").clientHeight,
30 scrollX: window.visualViewport.pageX - window.visualViewport.scrollLeft,
31 scrollY: window.visualViewport.pageY - window.visualViewport.scrollTop,
32 visualScrollX: window.visualViewport.scrollLeft,
33 visualScrollY: window.visualViewport.scrollTop,
34 visualScale: window.visualViewport.scale
35 }, null, 4);
36 }
37
38 function test()
39 {
40 function printMetrics(callback)
41 {
42 InspectorTest.evaluateInPage("dumpMetrics()", print);
43
44 function print(metrics)
45 {
46 InspectorTest.log(metrics);
47 callback();
48 }
49 }
50
51 function testOverrides(width, height, visualWidth, visualHeight, scrollX, sc rollY, visualX, visualY, visualScale, next)
52 {
53 var metricsParams = {
54 width: width,
55 height: height,
56 visualViewportWidth: visualWidth,
57 visualViewportHeight: visualHeight,
58 deviceScaleFactor: 0,
59 mobile: false,
60 fitWindow: false
61 };
62 var scrollParams = {
63 scrollPositionX: scrollX,
64 scrollPositionY: scrollY,
65 visualViewportPositionX: visualX,
66 visualViewportPositionY: visualY,
67 visualViewportScale: visualScale
68 };
69 InspectorTest.log("Device metrics overrides: " + JSON.stringify(metricsP arams));
70 InspectorTest.log("Scroll/scale overrides: " + JSON.stringify(scrollPara ms));
71
72 InspectorTest.sendCommandOrDie("Emulation.setDeviceMetricsOverride", met ricsParams, metricsOverrideActive);
73
74 function metricsOverrideActive()
75 {
76 InspectorTest.sendCommandOrDie("Emulation.setScrollAndScaleOverride" , scrollParams, printMetrics.bind(null, allOverridesActive));
77 }
78
79 function allOverridesActive()
80 {
81 InspectorTest.log("Clearing overrides.");
82 InspectorTest.sendCommandOrDie("Emulation.clearScrollAndScaleOverrid e", {}, scrollOverrideCleared);
83
84 function scrollOverrideCleared()
85 {
86 InspectorTest.sendCommandOrDie("Emulation.clearDeviceMetricsOver ride", {}, printMetrics.bind(null, next));
87 }
88 }
89 }
90
91 InspectorTest.runTestSuite([
92 function noOverrides(next)
93 {
94 testOverrides(0, 0, 0, 0, -1, -1, -1, -1, 0, next);
95 },
96
97 function frameScrollX(next)
98 {
99 testOverrides(400, 200, 0, 0, 200, -1, -1, -1, 0, next);
100 },
101
102 function frameScrollY(next)
103 {
104 testOverrides(400, 200, 0, 0, -1, 600, -1, -1, 0, next);
105 },
106
107 function frameScrollXWithResizedVisualViewport(next)
108 {
109 testOverrides(400, 200, 200, 100, 200, -1, -1, -1, 0, next);
110 },
111
112 function frameScrollYWithResizedVisualViewport(next)
113 {
114 testOverrides(400, 200, 200, 100, -1, 600, -1, -1, 0, next);
115 },
116
117 function visualScrollX(next)
118 {
119 testOverrides(400, 200, 200, 100, -1, -1, 100, -1, 0, next);
120 },
121
122 function visualScrollY(next)
123 {
124 testOverrides(400, 200, 200, 100, -1, -1, -1, 50, 0, next);
125 },
126
127 function visualScale(next)
128 {
129 testOverrides(400, 200, 200, 100, -1, -1, -1, -1, 2.0, next);
130 },
131
132 function visualScrollAndScale(next)
133 {
134 testOverrides(400, 200, 200, 100, -1, -1, 100, 50, 2.0, next);
135 },
136
137 function scrollFrameAndVisual(next)
138 {
139 testOverrides(400, 200, 200, 100, 200, 600, 100, 50, 0, next);
140 },
141
142 function scrollFrameAndVisualMax(next)
143 {
144 testOverrides(400, 200, 200, 100, 100000, 100000, 100000, 100000, 0, next);
145 },
146
147 function scrollAndScaleFrameAndVisual(next)
148 {
149 testOverrides(400, 200, 200, 100, 200, 600, 100, 50, 2.0, next);
150 },
151
152 function scrollAndScaleFrameAndVisualMax(next)
153 {
154 testOverrides(400, 200, 200, 100, 100000, 100000, 100000, 100000, 2. 0, next);
155 },
156 ]);
157 }
158 </script>
159
160 </head>
161 <body onload="runTest()">
162 <div id="layoutViewportDiv"></div>
163 <p>
164 Tests overrides for frame scroll position and visual viewport scroll position an d scale.
165 </p>
166 </body>
167 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698