content/base/test/test_meta_viewport4.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <meta charset="utf-8">
michael@0 5 <title>meta viewport test</title>
michael@0 6 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 8 <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
michael@0 9 <script src="viewport_helpers.js"></script>
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <p>initial-scale=1.0, user-scalable=no</p>
michael@0 13 <script type="application/javascript;version=1.7">
michael@0 14 "use strict";
michael@0 15
michael@0 16 SimpleTest.waitForExplicitFinish();
michael@0 17
michael@0 18 let tests = [];
michael@0 19
michael@0 20 tests.push(function test1() {
michael@0 21 SpecialPowers.pushPrefEnv(scaleRatio(1.0),
michael@0 22 function() {
michael@0 23 let info = getViewportInfo(800, 480);
michael@0 24 is(info.defaultZoom, 1, "initial zoom is set explicitly");
michael@0 25 is(info.width, 800, "width fits the initial zoom level");
michael@0 26 is(info.height, 480, "height fits the initial zoom level");
michael@0 27 is(info.autoSize, true, "initial-scale=1 enables autoSize");
michael@0 28 is(info.allowZoom, false, "zooming is explicitly disabled");
michael@0 29
michael@0 30 info = getViewportInfo(480, 800);
michael@0 31 is(info.defaultZoom, 1, "initial zoom is still set explicitly");
michael@0 32 is(info.width, 480, "width changes to match the displayWidth");
michael@0 33 is(info.height, 800, "height changes to match the displayHeight");
michael@0 34
michael@0 35 nextTest();
michael@0 36 });
michael@0 37 });
michael@0 38
michael@0 39 tests.push(function test2() {
michael@0 40 SpecialPowers.pushPrefEnv(scaleRatio(1.5),
michael@0 41 function() {
michael@0 42 let info = getViewportInfo(800, 480);
michael@0 43 is(info.defaultZoom, 1.5, "initial zoom is adjusted for device pixel ratio");
michael@0 44 is(info.width, 533, "width fits the initial zoom");
michael@0 45 is(info.height, 320, "height fits the initial zoom");
michael@0 46
michael@0 47 nextTest();
michael@0 48 });
michael@0 49 });
michael@0 50
michael@0 51 function getViewportInfo(aDisplayWidth, aDisplayHeight) {
michael@0 52 let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {},
michael@0 53 width = {}, height = {}, autoSize = {};
michael@0 54
michael@0 55 let cwu = SpecialPowers.getDOMWindowUtils(window);
michael@0 56 cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom,
michael@0 57 minZoom, maxZoom, width, height, autoSize);
michael@0 58 return {
michael@0 59 defaultZoom: defaultZoom.value,
michael@0 60 minZoom: minZoom.value,
michael@0 61 maxZoom: maxZoom.value,
michael@0 62 width: width.value,
michael@0 63 height: height.value,
michael@0 64 autoSize: autoSize.value,
michael@0 65 allowZoom: allowZoom.value
michael@0 66 };
michael@0 67 }
michael@0 68
michael@0 69 function nextTest() {
michael@0 70 if (tests.length)
michael@0 71 (tests.shift())();
michael@0 72 else
michael@0 73 SimpleTest.finish();
michael@0 74 }
michael@0 75 addEventListener("load", nextTest);
michael@0 76 </script>
michael@0 77 </body>
michael@0 78 </html>

mercurial