Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / device-emulation / device-emulation-scale-only.html
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: " + deviceScaleFactor);
42         PageAgent.invoke_setDeviceMetricsOverride({width: 0, height: 0, deviceScaleFactor: deviceScaleFactor, emulateViewport: false, fitWindow: false}, 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.position + " 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 + " instead of " + initialMetrics.body);
54             if (deviceScaleFactor)
55                 InspectorTest.addResult("Got device scale factor: " + metrics.dpr);
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>