1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_meta_viewport6.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,83 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <meta charset="utf-8"> 1.8 + <title>meta viewport test</title> 1.9 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.10 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.11 + <meta name="viewport" content="width=2000, minimum-scale=0.75"> 1.12 + <script src="viewport_helpers.js"></script> 1.13 +</head> 1.14 +<body> 1.15 + <p>width=2000, minimum-scale=0.75</p> 1.16 + <script type="application/javascript;version=1.7"> 1.17 + "use strict"; 1.18 + 1.19 + SimpleTest.waitForExplicitFinish(); 1.20 + 1.21 + let tests = []; 1.22 + 1.23 + tests.push(function test1() { 1.24 + SpecialPowers.pushPrefEnv(scaleRatio(1.0), 1.25 + function() { 1.26 + let info = getViewportInfo(800, 480); 1.27 + is(info.minZoom, 0.75, "minumum scale is set explicitly"); 1.28 + is(info.defaultZoom, 0.75, "initial scale is bounded by the minimum scale"); 1.29 + is(info.maxZoom, 10, "maximum scale defaults to the absolute maximum"); 1.30 + is(info.width, 2000, "width is set explicitly"); 1.31 + is(info.height, 1200, "height is proportional to displayHeight"); 1.32 + is(info.autoSize, false, "autoSize is disabled by default"); 1.33 + is(info.allowZoom, true, "zooming is enabled by default"); 1.34 + 1.35 + info = getViewportInfo(2000, 1000); 1.36 + is(info.minZoom, 0.75, "minumum scale is still set explicitly"); 1.37 + is(info.defaultZoom, 1, "initial scale fits the width"); 1.38 + is(info.width, 2000, "width is set explicitly"); 1.39 + is(info.height, 1000, "height is proportional to the new displayHeight"); 1.40 + 1.41 + nextTest(); 1.42 + }); 1.43 + }); 1.44 + 1.45 + tests.push(function test2() { 1.46 + SpecialPowers.pushPrefEnv(scaleRatio(1.5), 1.47 + function() { 1.48 + let info = getViewportInfo(800, 480); 1.49 + is(info.minZoom, 1.125, "minumum scale is converted to device pixel scale"); 1.50 + is(info.defaultZoom, 1.125, "initial scale is bounded by the minimum scale"); 1.51 + is(info.maxZoom, 15, "maximum scale defaults to the absolute maximum"); 1.52 + is(info.width, 2000, "width is still set explicitly"); 1.53 + is(info.height, 1200, "height is still proportional to displayHeight"); 1.54 + 1.55 + nextTest(); 1.56 + }); 1.57 + }); 1.58 + 1.59 + function getViewportInfo(aDisplayWidth, aDisplayHeight) { 1.60 + let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {}, 1.61 + width = {}, height = {}, autoSize = {}; 1.62 + 1.63 + let cwu = SpecialPowers.getDOMWindowUtils(window); 1.64 + cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom, 1.65 + minZoom, maxZoom, width, height, autoSize); 1.66 + return { 1.67 + defaultZoom: defaultZoom.value, 1.68 + minZoom: minZoom.value, 1.69 + maxZoom: maxZoom.value, 1.70 + width: width.value, 1.71 + height: height.value, 1.72 + autoSize: autoSize.value, 1.73 + allowZoom: allowZoom.value 1.74 + }; 1.75 + } 1.76 + 1.77 + function nextTest() { 1.78 + if (tests.length) 1.79 + (tests.shift())(); 1.80 + else 1.81 + SimpleTest.finish(); 1.82 + } 1.83 + addEventListener("load", nextTest); 1.84 + </script> 1.85 +</body> 1.86 +</html>