1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_meta_viewport0.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 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 + <script src="viewport_helpers.js"></script> 1.12 +</head> 1.13 +<body> 1.14 + <p>No <meta name="viewport"> tag</p> 1.15 + <script type="application/javascript;version=1.7"> 1.16 + "use strict"; 1.17 + 1.18 + SimpleTest.waitForExplicitFinish(); 1.19 + 1.20 + let tests = []; 1.21 + 1.22 + tests.push(function test1() { 1.23 + SpecialPowers.pushPrefEnv(scaleRatio(1.0), 1.24 + function() { 1.25 + let info = getViewportInfo(800, 480); 1.26 + is(info.defaultZoom, 0, "initial scale is unspecified"); 1.27 + is(info.minZoom, 0, "minumum scale defaults to the absolute minumum"); 1.28 + is(info.maxZoom, 10, "maximum scale defaults to the absolute maximum"); 1.29 + is(info.width, 980, "width is the default width"); 1.30 + is(info.height, 588, "height is proportional to displayHeight"); 1.31 + is(info.autoSize, false, "autoSize is disabled by default"); 1.32 + is(info.allowZoom, true, "zooming is enabled by default"); 1.33 + 1.34 + info = getViewportInfo(490, 600); 1.35 + is(info.width, 980, "width is still the default width"); 1.36 + is(info.height, 1200, "height is proportional to the new displayHeight"); 1.37 + 1.38 + nextTest(); 1.39 + }); 1.40 + }); 1.41 + 1.42 + tests.push(function test2() { 1.43 + SpecialPowers.pushPrefEnv(scaleRatio(1.5), 1.44 + function() { 1.45 + let info = getViewportInfo(800, 480); 1.46 + is(info.width, 980, "width is still the default width"); 1.47 + is(info.height, 588, "height is still proportional to displayHeight"); 1.48 + 1.49 + nextTest(); 1.50 + }); 1.51 + }); 1.52 + 1.53 + function getViewportInfo(aDisplayWidth, aDisplayHeight) { 1.54 + let defaultZoom = {}, allowZoom = {}, minZoom = {}, maxZoom = {}, 1.55 + width = {}, height = {}, autoSize = {}; 1.56 + 1.57 + let cwu = SpecialPowers.getDOMWindowUtils(window); 1.58 + cwu.getViewportInfo(aDisplayWidth, aDisplayHeight, defaultZoom, allowZoom, 1.59 + minZoom, maxZoom, width, height, autoSize); 1.60 + return { 1.61 + defaultZoom: defaultZoom.value, 1.62 + minZoom: minZoom.value, 1.63 + maxZoom: maxZoom.value, 1.64 + width: width.value, 1.65 + height: height.value, 1.66 + autoSize: autoSize.value, 1.67 + allowZoom: allowZoom.value 1.68 + }; 1.69 + } 1.70 + 1.71 + function nextTest() { 1.72 + if (tests.length) 1.73 + (tests.shift())(); 1.74 + else 1.75 + SimpleTest.finish(); 1.76 + } 1.77 + addEventListener("load", nextTest); 1.78 + </script> 1.79 +</body> 1.80 +</html>