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

Side by Side Diff: LayoutTests/inspector/device-emulation/device-emulation-scale-only.html

Issue 205403004: [DevTools] Allow overriding only the device scale factor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase, one test fixed Created 6 years, 9 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 screen: window.screen.width + "x" + window.screen.height,
18 position: window.screenX + "x" + window.screenY,
19 inner: window.innerWidth + "x" + window.innerHeight,
20 body: document.body.offsetWidth + "x" + document.body.offsetHeight,
21 dpr: window.devicePixelRatio
22 });
23 }
24
25 function test()
26 {
27 function getPageMetrics(callback)
28 {
29 InspectorTest.evaluateInPage("dumpMetrics()", parse);
30
31 function parse(json)
32 {
33 callback(JSON.parse(json.value));
34 }
35 }
36
37 var initialMetrics;
38
39 function applyEmulationAndCheckMetrics(deviceScaleFactor, callback)
40 {
41 InspectorTest.addResult("Overriding device scale factor: " + deviceScale Factor);
42 PageAgent.setDeviceMetricsOverride(0, 0, deviceScaleFactor, false, false , false, 1, getPageMetrics.bind(null, check));
43
44 function check(metrics)
45 {
46 if (metrics.screen !== initialMetrics.screen)
47 InspectorTest.addResult("Wrong screen size: " + metrics.screen + " instead of " + initialMetrics.screen);
48 if (metrics.position !== initialMetrics.position)
49 InspectorTest.addResult("Wrong screen position: " + metrics.posi tion + " instead of " + initialMetrics.position);
50 if (metrics.inner !== initialMetrics.inner)
51 InspectorTest.addResult("Wrong window size: " + metrics.inner + " instead of " + initialMetrics.inner);
52 if (metrics.body !== initialMetrics.body)
53 InspectorTest.addResult("Wrong body size: " + metrics.body + " i nstead of " + initialMetrics.body);
54 if (deviceScaleFactor)
55 InspectorTest.addResult("Got device scale factor: " + metrics.dp r);
56 callback();
57 }
58 }
59
60 function saveInitialMetrics(callback)
61 {
62 getPageMetrics(save);
63
64 function save(metrics)
65 {
66 initialMetrics = metrics;
67 callback();
68 }
69 }
70
71 var complete = InspectorTest.completeTest.bind(InspectorTest);
72 var reset = applyEmulationAndCheckMetrics.bind(null, 0, complete);
73 var check3 = applyEmulationAndCheckMetrics.bind(null, 3, reset);
74 var check2 = applyEmulationAndCheckMetrics.bind(null, 2, check3);
75 var check1 = applyEmulationAndCheckMetrics.bind(null, 1, check2);
76 saveInitialMetrics(check1);
77 }
78 </script>
79
80 </head>
81 <body onload="runTest()">
82 <p>
83 Tests that overriding only device scale factor does not affect any other value.
84 </p>
85 </body>
86 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698