Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>meta viewport test</title>
6 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
8 <meta name="viewport" content="width=2000, minimum-scale=0.75">
9 <script src="viewport_helpers.js"></script>
10 </head>
11 <body>
12 <p>width=2000, minimum-scale=0.75</p>
13 <script type="application/javascript;version=1.7">
14 "use strict";
16 SimpleTest.waitForExplicitFinish();
18 let tests = [];
20 tests.push(function test1() {
21 SpecialPowers.pushPrefEnv(scaleRatio(1.0),
22 function() {
23 let info = getViewportInfo(800, 480);
24 is(info.minZoom, 0.75, "minumum scale is set explicitly");
25 is(info.defaultZoom, 0.75, "initial scale is bounded by the minimum scale");
26 is(info.maxZoom, 10, "maximum scale defaults to the absolute maximum");
27 is(info.width, 2000, "width is set explicitly");
28 is(info.height, 1200, "height is proportional to displayHeight");
29 is(info.autoSize, false, "autoSize is disabled by default");
30 is(info.allowZoom, true, "zooming is enabled by default");
32 info = getViewportInfo(2000, 1000);
33 is(info.minZoom, 0.75, "minumum scale is still set explicitly");
34 is(info.defaultZoom, 1, "initial scale fits the width");
35 is(info.width, 2000, "width is set explicitly");
36 is(info.height, 1000, "height is proportional to the new displayHeight");
38 nextTest();
39 });
40 });
42 tests.push(function test2() {
43 SpecialPowers.pushPrefEnv(scaleRatio(1.5),
44 function() {
45 let info = getViewportInfo(800, 480);
46 is(info.minZoom, 1.125, "minumum scale is converted to device pixel scale");
47 is(info.defaultZoom, 1.125, "initial scale is bounded by the minimum scale");
48 is(info.maxZoom, 15, "maximum scale defaults to the absolute maximum");
49 is(info.width, 2000, "width is still set explicitly");
50 is(info.height, 1200, "height is still proportional to displayHeight");
52 nextTest();
53 });
54 });
56 function getViewportInfo(aDisplayWidth, aDisplayHeight) {
57 let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
58 width = {}, height = {}, autoSize = {};
60 let cwu = SpecialPowers.getDOMWindowUtils(window);
61 cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
62 minZoom, maxZoom, width, height, autoSize);
63 return {
64 defaultZoom: defaultZoom.value,
65 minZoom: minZoom.value,
66 maxZoom: maxZoom.value,
67 width: width.value,
68 height: height.value,
69 autoSize: autoSize.value,
70 allowZoom: allowZoom.value
71 };
72 }
74 function nextTest() {
75 if (tests.length)
76 (tests.shift())();
77 else
78 SimpleTest.finish();
79 }
80 addEventListener("load", nextTest);
81 </script>
82 </body>
83 </html>