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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/device-emulation/device-emulation-partial.html

Issue 1638953002: [DevTools] Migrate device-emulation tests from OverridesSupport to inspector-protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/inspector-test.js"></script>
5
6 <style>
7 body {
8 margin: 0;
9 min-height: 1000px;
10 }
11 </style>
12
13 <script>
14 function dumpMetrics()
15 {
16 return JSON.stringify({
17 width: window.innerWidth,
18 height: window.innerHeight,
19 screenWidth: window.screen.width,
20 screenHeight: window.screen.height,
21 screenX: window.screenX,
22 screenY: window.screenY,
23 deviceScaleFactor: window.devicePixelRatio
24 });
25 }
26
27 function test()
28 {
29 function getPageMetrics(callback)
30 {
31 InspectorTest.evaluateInPage("dumpMetrics()", parse);
32
33 function parse(json)
34 {
35 callback(JSON.parse(json.value));
36 }
37 }
38
39 var initialMetrics;
40
41 function testPartialOverride(name, value, next)
42 {
43 var params = {width: 0, height: 0, deviceScaleFactor: 0, mobile: false, fitWindow: false};
44 if (name === null) {
45 InspectorTest.PageAgent.clearDeviceMetricsOverride(getPageMetrics.bi nd(null, check));
46 } else {
47 if (name)
48 params[name] = value;
49 InspectorTest.PageAgent.invoke_setDeviceMetricsOverride(params, getP ageMetrics.bind(null, check));
50 }
51
52 function check(metrics)
53 {
54 var fail = false;
55 for (var key in initialMetrics) {
56 var expected = key === name ? value : initialMetrics[key];
57 if (metrics[key] !== expected) {
58 InspectorTest.addResult("[FAIL]: " + metrics[key] + " instea d of " + expected + " for " + key);
59 fail = true;
60 }
61 }
62 if (!fail)
63 InspectorTest.addResult(name ? ("[PASS]: " + name + "=" + value) : "[PASS]");
64 next();
65 }
66 }
67
68 InspectorTest.runTestSuite([
69 function collectMetrics(next)
70 {
71 function collect(metrics)
72 {
73 initialMetrics = metrics;
74 next();
75 }
76 getPageMetrics(collect);
77 },
78
79 function noOverrides(next)
80 {
81 testPartialOverride("", 0, next);
82 },
83
84 function width(next)
85 {
86 testPartialOverride("width", 300, next);
87 },
88
89 function height(next)
90 {
91 testPartialOverride("height", 400, next);
92 },
93
94 function deviceScaleFactor1(next)
95 {
96 testPartialOverride("deviceScaleFactor", 1, next);
97 },
98
99 function deviceScaleFactor2(next)
100 {
101 testPartialOverride("deviceScaleFactor", 2, next);
102 },
103
104 function clear(next)
105 {
106 testPartialOverride(null, null, next);
107 },
108
109 function anotherWidth(next)
110 {
111 testPartialOverride("width", 400, next);
112 },
113
114 function anotherHeight(next)
115 {
116 testPartialOverride("height", 300, next);
117 },
118
119 function deviceScaleFactor3(next)
120 {
121 testPartialOverride("deviceScaleFactor", 3, next);
122 },
123
124 function clear(next)
125 {
126 testPartialOverride(null, null, next);
127 }
128 ]);
129 }
130 </script>
131
132 </head>
133 <body onload="runTest()">
134 <p>
135 Tests that overriding only a single parameter does not affect others.
136 </p>
137 </body>
138 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698