content/base/test/test_meta_viewport0.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:15b1c1c60291
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 <script src="viewport_helpers.js"></script>
9 </head>
10 <body>
11 <p>No &lt;meta name="viewport"&gt; tag</p>
12 <script type="application/javascript;version=1.7">
13 "use strict";
14
15 SimpleTest.waitForExplicitFinish();
16
17 let tests = [];
18
19 tests.push(function test1() {
20 SpecialPowers.pushPrefEnv(scaleRatio(1.0),
21 function() {
22 let info = getViewportInfo(800, 480);
23 is(info.defaultZoom, 0, "initial scale is unspecified");
24 is(info.minZoom, 0, "minumum scale defaults to the absolute minumum");
25 is(info.maxZoom, 10, "maximum scale defaults to the absolute maximum");
26 is(info.width, 980, "width is the default width");
27 is(info.height, 588, "height is proportional to displayHeight");
28 is(info.autoSize, false, "autoSize is disabled by default");
29 is(info.allowZoom, true, "zooming is enabled by default");
30
31 info = getViewportInfo(490, 600);
32 is(info.width, 980, "width is still the default width");
33 is(info.height, 1200, "height is proportional to the new displayHeight");
34
35 nextTest();
36 });
37 });
38
39 tests.push(function test2() {
40 SpecialPowers.pushPrefEnv(scaleRatio(1.5),
41 function() {
42 let info = getViewportInfo(800, 480);
43 is(info.width, 980, "width is still the default width");
44 is(info.height, 588, "height is still proportional to displayHeight");
45
46 nextTest();
47 });
48 });
49
50 function getViewportInfo(aDisplayWidth, aDisplayHeight) {
51 let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
52 width = {}, height = {}, autoSize = {};
53
54 let cwu = SpecialPowers.getDOMWindowUtils(window);
55 cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
56 minZoom, maxZoom, width, height, autoSize);
57 return {
58 defaultZoom: defaultZoom.value,
59 minZoom: minZoom.value,
60 maxZoom: maxZoom.value,
61 width: width.value,
62 height: height.value,
63 autoSize: autoSize.value,
64 allowZoom: allowZoom.value
65 };
66 }
67
68 function nextTest() {
69 if (tests.length)
70 (tests.shift())();
71 else
72 SimpleTest.finish();
73 }
74 addEventListener("load", nextTest);
75 </script>
76 </body>
77 </html>

mercurial