Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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=320">
9 <script src="viewport_helpers.js"></script>
10 </head>
11 <body>
12 <p>width=320</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, 80);
24 is(info.defaultZoom, 2.5, "initial zoom fits the displayWidth");
25 is(info.width, 320, "width is set explicitly");
26 is(info.height, 40, "height is at the absolute minimum");
27 is(info.autoSize, false, "width=device-width enables autoSize");
28 is(info.allowZoom, true, "zooming is enabled by default");
30 info = getViewportInfo(480, 800);
31 is(info.defaultZoom, 1.5, "initial zoom fits the new displayWidth");
32 is(info.width, 320, "explicit width is unchanged");
33 is(info.height, 533, "height changes proportional to displayHeight");
35 nextTest();
36 });
37 });
39 tests.push(function test2() {
40 SpecialPowers.pushPrefEnv(scaleRatio(1.5),
41 function() {
42 // With an explicit width in CSS px, the scaleRatio has no effect.
43 let info = getViewportInfo(800, 80);
44 is(info.defaultZoom, 2.5, "initial zoom still fits the displayWidth");
45 is(info.width, 320, "width is still set explicitly");
46 is(info.height, 40, "height is still minimum height");
48 nextTest();
49 });
50 });
52 function getViewportInfo(aDisplayWidth, aDisplayHeight) {
53 let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
54 width = {}, height = {}, autoSize = {};
56 let cwu = SpecialPowers.getDOMWindowUtils(window);
57 cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
58 minZoom, maxZoom, width, height, autoSize);
59 return {
60 defaultZoom: defaultZoom.value,
61 minZoom: minZoom.value,
62 maxZoom: maxZoom.value,
63 width: width.value,
64 height: height.value,
65 autoSize: autoSize.value,
66 allowZoom: allowZoom.value
67 };
68 }
70 function nextTest() {
71 if (tests.length)
72 (tests.shift())();
73 else
74 SimpleTest.finish();
75 }
76 addEventListener("load", nextTest);
77 </script>
78 </body>
79 </html>